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
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Code Review
|
- name: Code Review
|
||||||
uses: freeedcom/ai-codereviewer@main
|
uses: researchwiseai/ai-codereviewer@moving-to-o1
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY_V2 }}
|
||||||
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
OPENAI_API_MODEL: "o1-mini"
|
||||||
exclude: "yarn.lock,dist/**"
|
exclude: "yarn.lock,dist/**"
|
||||||
|
|
26108
dist/index.js
vendored
26108
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> {
|
}> | null> {
|
||||||
const queryConfig = {
|
const queryConfig = {
|
||||||
model: OPENAI_API_MODEL,
|
model: OPENAI_API_MODEL,
|
||||||
temperature: 0.2,
|
temperature: 0.1,
|
||||||
max_tokens: 700,
|
max_tokens: 700,
|
||||||
top_p: 1,
|
top_p: 1,
|
||||||
frequency_penalty: 0,
|
frequency_penalty: 0,
|
||||||
|
@ -127,18 +127,20 @@ async function getAIResponse(prompt: string): Promise<Array<{
|
||||||
const response = await openai.chat.completions.create({
|
const response = await openai.chat.completions.create({
|
||||||
...queryConfig,
|
...queryConfig,
|
||||||
// return JSON if the model supports it:
|
// 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: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: "system",
|
role: "user",
|
||||||
content: prompt,
|
content: prompt,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = response.choices[0].message?.content?.trim() || "{}";
|
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;
|
return JSON.parse(res).reviews;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue