OpenAI not returning a result?

题意:OpenAI 没有返回结果吗?

问题背景:

I'm trying to use the OpenAI beta but I can't seem to get a result. I'm accessing the API via an NPM package (openai-api - npm). I have that setup and working but when I make a request the response I'm getting is missing any content in the response object.

我正在尝试使用 OpenAI 的 beta 版本,但似乎无法获得结果。我是通过 NPM 包(openai-api - npm)来访问 API 的。我已经设置好了并且它正在工作,但当我发起请求时,我得到的响应对象中没有包含任何内容。

Here's my code        这是我的代码

const suggestedDescription = await openai.complete( {
        engine: 'davinci',
        prompt: metadata.description,
        maxTokens: 20,
        temperature: 0,
        topP: 1,
        presencePenalty: 0,
        frequencyPenalty: 0,
        stop: ['...']
      } );

The resulting object looks like this:        生成的对象看起来像这样:

suggestedDescription { text: '', index: 0, logprobs: null, finish_reason: 'stop' }

Any thoughts?        你怎么看?

问题解决:

don't use openai-api anymore, it's not supported officially. use npm i openai instead.

不要再使用 openai-api 了,因为它不是官方支持的。请使用 npm i openai 来安装。

Code example would be something like this:

代码示例大致如下:

export const askOpenAi = async () => {
const prompt = `input: What is human life expectancy in the United States?
output:`
const response = await openai.createCompletion("text-davinci-001", {
    prompt: prompt,
    temperature: 0,
    max_tokens: 100,
    top_p: 1,
    frequency_penalty: 0,
    presence_penalty: 0,
    stop: ["input:"],
});
return response.data;
}

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值