I tried to use Threads to get answer from an Assistant that pre-created. It worked when trying in the Playground. However, when using it the the code it’s always failed. Any ideas?
OpenAI v4.91.0
Sample code:
// Read request body
const { message } = await readBody(event)
// Create or retrieve thread
const thread = await openai.beta.threads.create()
// Add message to thread
const userMessage = await openai.beta.threads.messages.create(thread.id, {
role: 'user',
content: message
})
console.log('User message:', userMessage)
// Run the thread and wait for the result
const run = await openai.beta.threads.runs.createAndPoll(thread.id, {
assistant_id: String(ASSISTANT_ID),
})
console.log('Run:', run)
// Get messages
const messages = await openai.beta.threads.messages.list(run.thread_id)
/// FAILED
Well the reason I think this is not all the code is there is no api keys asked and no model specified in the code provided, so I lacked context where this was used in.
I am using nodejs in production and GPT-4o works allright.
I have seen the issue “Sorry, something went wrong” and there are couple of gotchas which cause it.
It is possible that the model is the reason, when we do something which the model doesn’t support, if you can eleborate on the prompt and if you had tools activated ..it could help understand the issue better.