From 2011ebf3fc0fef4592dfd365e846b93a909898c0 Mon Sep 17 00:00:00 2001 From: Uffy Date: Wed, 29 May 2024 12:43:25 +0800 Subject: [PATCH] feat(next/api): update openai prompt & log result --- next/api/src/service/openai.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/next/api/src/service/openai.ts b/next/api/src/service/openai.ts index 40992de54..5e8e1b8c4 100644 --- a/next/api/src/service/openai.ts +++ b/next/api/src/service/openai.ts @@ -56,8 +56,6 @@ export class OpenAIService { const SystemPrompt = TicketClassifyPrompt(categories); - const UserPrompt = `内容:"""\n${content}\n"""`; - const res = await (async () => { try { const res = ( @@ -74,7 +72,7 @@ export class OpenAIService { }, { role: 'user', - content: UserPrompt, + content: content, }, ], temperature: 0.6, @@ -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; } })();