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 04392c0 commit fb32b49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion next/api/src/service/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { z } from 'zod';
export const TicketClassifyPrompt = (categories: Category[]) => `
你是我的内容分类助手,我会为你提供各种分类和它们的描述,以及一个内容,我需要你帮助为内容分类,并给出你认为的置信度。
分类后输出如下 JSON 格式:"""
{ "category": "..", "confidence": 0.123456789 }
{"category":"..","confidence":0.123456789}
"""
category 表示分类的 ID,confidence 表示你给出的置信度。 如果你觉得这个工单不属于任何分类,输出 null。
Expand Down Expand Up @@ -84,6 +84,7 @@ export class OpenAIService {
).choices[0].message?.content;

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

0 comments on commit fb32b49

Please sign in to comment.