Hello! I'm trying to update my JS code to use the newest ChatGPT API that was released.
The previous code was the following:
async function openai_reply(message) {
const completion = await openai.createCompletion({
model: "text-davinci-003",
prompt: message,
temperature: 0.7,
max_tokens: 256,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0
});
return completion.data.choices[0].text;
}
I tried then, based on this documentation page (https://platform.openai.com/docs/guides/chat), to update my code accordingly to the following:
async function openai_reply(message) {
const completion = await openai.createCompletion({
model: "gpt-3.5-turbo",
messages: [
{
"role": "system",
"content": "You are an assistant called Peedy"
},
{
"role": "user",
"content": message
}
]
});
return completion.data.choices[0].text;
}
But i'm getting error 400 with the last function.
What i'm doing wrong?
An API for accessing new AI models developed by OpenAI