Skip to content

Commit

Permalink
Bugfix/Check for proper thread id and avoid throwing error (FlowiseAI…
Browse files Browse the repository at this point in the history
…#2551)

check for proper thread id and avoid throwing error
  • Loading branch information
HenryHengZJ authored Jun 2, 2024
1 parent 8c66d2c commit f2a0ffe
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ class OpenAIAssistant_Agents implements INode {
const openai = new OpenAI({ apiKey: openAIApiKey })
options.logger.info(`Clearing OpenAI Thread ${sessionId}`)
try {
if (sessionId) await openai.beta.threads.del(sessionId)
options.logger.info(`Successfully cleared OpenAI Thread ${sessionId}`)
if (sessionId && sessionId.startsWith('thread_')) {
await openai.beta.threads.del(sessionId)
options.logger.info(`Successfully cleared OpenAI Thread ${sessionId}`)
} else {
options.logger.error(`Error clearing OpenAI Thread ${sessionId}`)
}
} catch (e) {
throw new Error(e)
options.logger.error(`Error clearing OpenAI Thread ${sessionId}`)
}
}

Expand Down

0 comments on commit f2a0ffe

Please sign in to comment.