Moved to o1 models

This commit is contained in:
Will Poynter 2024-10-01 11:41:14 +01:00
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

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