Skip to content

Commit

Permalink
refactor(services): Remove redundant assistant deletion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
csulit committed Oct 25, 2024
1 parent 4fc1ba8 commit ede06da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/openai-assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,21 @@ 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();

if (lastMessageForRun) {
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 "";
};

0 comments on commit ede06da

Please sign in to comment.