我正在使用 node.js 并想使用 openai API
我刚刚从 openai 游乐场复制了代码,它看起来像这样
export const askOpenAi = async () => {
const response = await openai.createCompletion("text-davinci-001", {
prompt: "\ninput: What is human life expectancy in the United States?\n",
temperature: 0,
max_tokens: 100,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
stop: ["\n", "\ninput:"],
});
return response.data;
}
openai 的返回数据是这样的
{
id: '~~~',
object: 'text_completion',
created: ~~~,
model: 'text-davinci:001',
choices: [ { text: '', index: 0, logprobs: null, finish_reason: 'stop' } ]
}
在操场上,这段代码运行良好。
我怎样才能得到正确的回应?