node.js 中的这个方法不再起作用了吗?因为当时它工作正常,但现在它不再工作了,而且这段代码也是基于他们的官方文档,即 https://platform.openai.com/docs/api-reference/completions/create
我的服务器端代码:
import { Configuration, OpenAIApi } from 'openai';
//....
const configuration = new Configuration({
apiKey: API_KEY,
});
//....
const openai = new OpenAIApi(configuration);
//....
const response = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{
role: "system",
content: `You are a helpful assistant.` },
...prompt
],
temperature: 0.2,
max_tokens: 1500,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
});
//....
res.status(200).send({
bot: response.data.choices[0].message.content
});
//....
我尝试发送的数据:
{
"prompt": [
{
"role": "bot",
"content": "Something went wrong."
},
{
"role": "user",
"content": "What is wrong?"
}
]
}
我遇到了这种错误: | 消息提示的输出位于终端中,以防您想检查我是否发送了正确的消息提示。
我还尝试添加组织 ID,但仍然不起作用,也尝试将其从 v3.2.1 更新到 v3.3.0,但根本不起作用。我的账户里还有余额。
最佳答案
问题已解决,我发送了错误的 Angular 色而不是机器人,它应该是助理。所以这种格式将使一切恢复正常:
{
"prompt": [
{
"role": "assistant",
"content": "Something went wrong."
},
{
"role": "user",
"content": "What is wrong?"
}
]
}
基于https://platform.openai.com/docs/api-reference/chat/create只有 4 个 Angular 色:system
、user
、assistant
或 function
关于javascript - OpenAI gpt-3.5-turbo : Request failed with status code 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76603485/