I am following the steps outlined in the OpenAI documentation when it comes to assistants, I am creating a thread, adding messages to it and so on…however when I try to access the run’s status via a loop, it never leaves the “in_progress” status, I’ve run this code for 20 minutes and the status remains the same.
Here is my code:
const prompt = async (content) => {
// See: https://platform.openai.com/docs/assistants/overview?lang=node.js
const assistant = await openai.beta.assistants.retrieve("asstistant");
// Create a thread
const thread = await openai.beta.threads.create();
// Add a message to the thread
const message = await openai.beta.threads.messages.create(
thread.id,
{
role: "user",
content
}
)
// Create a run
const run = await openai.beta.threads.runs.create(
thread.id,
{ assistant_id: "some default value" }
)
console.log(run);
// Check run status
const runStatus = await openai.beta.threads.runs.retrieve(
thread.id,
run.id
)
// See: Step 5 of assistants API page on the openai docs
for (let attempts = 0;;attempts++){
if(runStatus.status === "queued" || runStatus.status === "in_progress"){
console.log(`Run status: ${runStatus.status}`)
} else {
console.log(runStatus);
// Display Assistant's response
const messages = await openai.beta.threads.messages.list(thread.id);
console.log(messages.data)
break;
}
}
}
prompt(“Hello there”)