Skip to content

Commit

Permalink
feat(next/api): update openai prompt & log result
Browse files Browse the repository at this point in the history
  • Loading branch information
uffy committed May 29, 2024
1 parent fb32b49 commit 2011ebf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions next/api/src/service/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ export class OpenAIService {

const SystemPrompt = TicketClassifyPrompt(categories);

const UserPrompt = `内容:"""\n${content}\n"""`;

const res = await (async () => {
try {
const res = (
Expand All @@ -74,7 +72,7 @@ export class OpenAIService {
},
{
role: 'user',
content: UserPrompt,
content: content,
},
],
temperature: 0.6,
Expand All @@ -84,15 +82,15 @@ export class OpenAIService {
).choices[0].message?.content;

if (res) {
console.log(`OpenAI category classify: user=${content}, result=${res}`);
console.log(`OpenAI category classify: user=${content}, result=${res}, prompt=${SystemPrompt}`);
try {
return OpenAIOutputSchema.parse(JSON.parse(res.trim()));
} catch {
console.log(`parse GPT result error:`, res);
console.log(`OpenAI category classify: parse result failed:`, res);
}
}
} catch (err) {
console.error(err);
console.error(`OpenAI category classify: error:`, err);
return;
}
})();
Expand Down

0 comments on commit 2011ebf

Please sign in to comment.