Merge pull request #4 from StayNTouch/revert-1-gpt3_5

Revert "To use GPT-3.5-Turbo"
This commit is contained in:
Arun Murugan 2024-05-21 13:55:10 -04:00 committed by GitHub
commit ca28787e9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1305 additions and 1304 deletions

6
dist/index.js vendored
View file

@ -146,14 +146,14 @@ function getAIResponse(prompt) {
presence_penalty: 0, presence_penalty: 0,
}; };
try { try {
const response = yield openai.chat.completions.create(Object.assign(Object.assign({}, queryConfig), { messages: [ const response = yield openai.chat.completions.create(Object.assign(Object.assign(Object.assign({}, queryConfig), (OPENAI_API_MODEL === "gpt-4-1106-preview"
? { response_format: { type: "json_object" } }
: {})), { messages: [
{ {
role: "system", role: "system",
content: prompt, content: prompt,
}, },
] })); ] }));
// Log the raw response for debugging
console.log('Raw response:', response);
const res = ((_b = (_a = response.choices[0].message) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.trim()) || "{}"; const res = ((_b = (_a = response.choices[0].message) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.trim()) || "{}";
return JSON.parse(res).reviews; return JSON.parse(res).reviews;
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -126,6 +126,10 @@ async function getAIResponse(prompt: string): Promise<Array<{
try { try {
const response = await openai.chat.completions.create({ const response = await openai.chat.completions.create({
...queryConfig, ...queryConfig,
// return JSON if the model supports it:
...(OPENAI_API_MODEL === "gpt-4-1106-preview"
? { response_format: { type: "json_object" } }
: {}),
messages: [ messages: [
{ {
role: "system", role: "system",
@ -134,9 +138,6 @@ async function getAIResponse(prompt: string): Promise<Array<{
], ],
}); });
// Log the raw response for debugging
console.log('Raw response:', response);
const res = response.choices[0].message?.content?.trim() || "{}"; const res = response.choices[0].message?.content?.trim() || "{}";
return JSON.parse(res).reviews; return JSON.parse(res).reviews;
} catch (error) { } catch (error) {