Hello everyone!
I need your help.
Now I am working with assistant api.
I created assistant with instruction(role) and file search tool. This assistant works well in playground.
But If I use this assistant api with my nodeJS code, it can't remember the role and instructions.
I can't detect the reason.
This is my code.
"
const message = await openai.beta.threads.messages.create(
thread_id,
{
role: "user",
content: msg.body
}
);
let run = await openai.beta.threads.runs.createAndPoll(
thread_id,
{
assistant_id: assistant.id,
instructions: "You must use file search tool to generate answer",
tools: [{ "type": "file_search" }]
}
);
if (run.status === 'completed') {
const messages = await openai.beta.threads.messages.list(
run.thread_id
);
// for (const message of messages.data.reverse()) {
// console.log(`${message.role} > ${message.content[0].text.value}`);
// }
let message = messages.data[0];
console.log("this is the result message=====>", message.role, " > ", message.content[0].text.value)
return message;
} else {
console.log(run.status);
return false;
}"
Help me.🙏