mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-29 12:24:16 +00:00
Moved to o1 models
This commit is contained in:
parent
a9a064dfa1
commit
4701f87d09
5 changed files with 33186 additions and 20720 deletions
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