You didn’t pass your messages and model options to createChatCompletion(). It should instead look something like this: const response = await openai.createChatCompletion({ model: "gpt-3.5-turbo", messages: messages, });
It should be response.data.choices[0].message instead of response.choices[0].message.content;
Not sure where does this text come from. Perhaps it should be botResponse += response.data.choices[0].message instead of botResponse += text?
The curly brackets outside of botResponse += text seems unnecessary to me.
What is not working exactly? The bot is not responding or does it reply with some error messages. If there are some error messages, can you paste them here too?
you need to add .content in order to get the repsone content from the api:
response.data.choices[0].message.content;
botResponse += response.data.choices[0].message.content;
however it is not clear for me what is causing this issue, so my advice is to try and use chatgpt to help you solve this problem, like copy paste the full code and ask chatgpt to check if there is any issues with your code, add the error message you get and see what it will say, here is an example on how to do it:
i am trying to create a bot, this bot is supposed to do xxxxxxxxxx , i am using gpt3.5-turbo api and node.js, below is the code, however whenever i run the code i get the following error: xxxxxxxxxxxx
please help.
the code:
xxxxxxxxx