I am trying to ask question a specific assistant ( trained before ) but getting this error.
#code
`app.post(‘/ask’, async (req, res) => {
try {
const { question } = req.body;
const response = await openaiClient.assistants.complete(“asst_87GJOLpKrQGen2MrjIIiLO5U”, {
messages: [{ role: ‘user’, content: question }],
});
const assistantReply = response.data[0].content;
res.json({ reply: assistantReply });
} catch (error) {
console.error('Error asking question:', error);
res.status(500).json({ error: 'Failed to ask question' });
}
});`
Here is the issue iam facing
Error asking question: TypeError: Cannot read property 'complete' of undefined at /Users/md.golamrabbani/Desktop/ai-assisnt/index.js:20:56 at Layer.handle [as handle_request] (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/layer.js:95:5) at next (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/route.js:149:13) at Route.dispatch (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/route.js:119:3) at Layer.handle [as handle_request] (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/layer.js:95:5) at /Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/index.js:346:12) at next (/Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/express/lib/router/index.js:280:10) at /Users/md.golamrabbani/Desktop/ai-assisnt/node_modules/body-parser/lib/read.js:137:5 at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
I have tried using api first then tried with the sdk but getting this error
Golam Rabbani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.