You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to achieve the above in OpenAI Assistants API.
let assistantId = assistantDetails.assistantId;
// Create a thread using the assistantId
const thread = await openai.beta.threads.create();
// Pass in the user question into the existing thread
await openai.beta.threads.messages.create(thread.id, {
role: "user",
content: outputString,
});
// Create a run
const run = await openai.beta.threads.runs.create(thread.id, {
assistant_id: assistantId,
});
// Imediately fetch run-status, which will be "in_progress"
let runStatus = await openai.beta.threads.runs.retrieve(
thread.id,
run.id
);
// Get the last assistant message from the messages array
const messages = await openai.beta.threads.messages.list(thread.id);
// Find the last message for the current run
const lastMessageForRun = messages.data
.filter(
(message) =>
message.run_id === run.id && message.role === "assistant"
)
.pop();
let assistanceResponse = lastMessageForRun.content[0].text.value;
```
The text was updated successfully, but these errors were encountered:
I'm trying to achieve the above in OpenAI Assistants API.
The text was updated successfully, but these errors were encountered: