Skip to content

Commit

Permalink
Forced JSON mode on all GPT-4 Turbo models newer than the 1106 preview.
Browse files Browse the repository at this point in the history
In response to freeedcom#56.
  • Loading branch information
lukehollenback committed Apr 2, 2024
1 parent a9a064d commit bc62780
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,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"
...(OPENAI_API_MODEL === "gpt-4-turbo-preview" || OPENAI_API_MODEL === "gpt-4-0125-preview" || OPENAI_API_MODEL === "gpt-4-1106-preview"
? { response_format: { type: "json_object" } }
: {}),
messages: [
Expand Down

0 comments on commit bc62780

Please sign in to comment.