Moved to o1 models

This commit is contained in:
Will Poynter 2024-10-01 11:41:14 +01:00
parent a9a064dfa1
commit 4701f87d09
No known key found for this signature in database
GPG key ID: AB3BE72A7CA5B1A9
5 changed files with 33186 additions and 20720 deletions

View file

@ -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

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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);