From ede06daf0c4cd1773349b56fb7c82ef746acce3e Mon Sep 17 00:00:00 2001 From: casulit Date: Fri, 25 Oct 2024 18:01:11 +0800 Subject: [PATCH] refactor(services): Remove redundant assistant deletion logic --- services/openai-assistant.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/openai-assistant.ts b/services/openai-assistant.ts index 88213c6..4e4e216 100644 --- a/services/openai-assistant.ts +++ b/services/openai-assistant.ts @@ -67,7 +67,7 @@ export const openaiAssistant = async (question: string) => { const lastMessageForRun = messages.data .filter( - (message) => message.run_id === run.id && message.role === "assistant", + (message) => message.run_id === run.id && message.role === "assistant" ) .pop(); @@ -75,11 +75,13 @@ export const openaiAssistant = async (question: string) => { if (lastMessageForRun.content[0].type === "text") { console.log(lastMessageForRun.content[0].text.value); await openai.beta.threads.del(thread.id); + await openai.beta.assistants.del(assistant.id); return lastMessageForRun.content[0].text.value; } } await openai.beta.threads.del(thread.id); + await openai.beta.assistants.del(assistant.id); return ""; };