mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-19 17:16:48 +00:00
Moved to o1 models
This commit is contained in:
parent
a9a064dfa1
commit
4701f87d09
5 changed files with 33186 additions and 20720 deletions
6
.github/workflows/code_review.yml
vendored
6
.github/workflows/code_review.yml
vendored
|
@ -12,9 +12,9 @@ jobs:
|
|||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Code Review
|
||||
uses: freeedcom/ai-codereviewer@main
|
||||
uses: researchwiseai/ai-codereviewer@moving-to-o1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_V2 }}
|
||||
OPENAI_API_MODEL: "o1-mini"
|
||||
exclude: "yarn.lock,dist/**"
|
||||
|
|
51534
dist/index.js
vendored
51534
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2352
dist/sourcemap-register.js
vendored
2352
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
12
src/main.ts
12
src/main.ts
|
@ -116,7 +116,7 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
}> | null> {
|
||||
const queryConfig = {
|
||||
model: OPENAI_API_MODEL,
|
||||
temperature: 0.2,
|
||||
temperature: 0.1,
|
||||
max_tokens: 700,
|
||||
top_p: 1,
|
||||
frequency_penalty: 0,
|
||||
|
@ -127,18 +127,20 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
|||
const response = await openai.chat.completions.create({
|
||||
...queryConfig,
|
||||
// return JSON if the model supports it:
|
||||
...(OPENAI_API_MODEL === "gpt-4-1106-preview"
|
||||
? { response_format: { type: "json_object" } }
|
||||
: {}),
|
||||
response_format: { type: "json_object" },
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
role: "user",
|
||||
content: prompt,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
||||
// Remove ```json from the response if it exists
|
||||
if (res.startsWith("```json")) {
|
||||
return JSON.parse(res.slice(7, res.length - 3)).reviews;
|
||||
}
|
||||
return JSON.parse(res).reviews;
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue