mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-19 17:16:48 +00:00
Support newer OpenAI models
This commit is contained in:
parent
a9a064dfa1
commit
64a327d459
5 changed files with 5705 additions and 2490 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
node_modules
|
||||
.idea
|
||||
lib/**/*
|
||||
.yarn
|
||||
|
|
5588
dist/index.js
vendored
5588
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
|
@ -110,6 +110,11 @@ ${chunk.changes
|
|||
`;
|
||||
}
|
||||
|
||||
function modelSupportsJsonResponse(model: string): boolean {
|
||||
const supportedModels = ["gpt-4o", "gpt-4o-mini", "gpt-4.5-preview", "o3-mini", "o1", "o1-mini"];
|
||||
return supportedModels.includes(model);
|
||||
}
|
||||
|
||||
async function getAIResponse(prompt: string): Promise<Array<{
|
||||
lineNumber: string;
|
||||
reviewComment: string;
|
||||
|
@ -127,7 +132,7 @@ 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"
|
||||
...(modelSupportsJsonResponse(OPENAI_API_MODEL)
|
||||
? { response_format: { type: "json_object" } }
|
||||
: {}),
|
||||
messages: [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"lib": ["esnext"],
|
||||
"module": "commonjs",
|
||||
"outDir": "./lib",
|
||||
"rootDir": "./src",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue