python - 无效请求错误 : Must provide an 'engine' parameter while invoking openAI API for text generation

标签 python openai-api

我正在尝试 OpenAI 中给出的这段代码。

链接:- API for text generation

代码

import openai

prompt = """We’re releasing an API for accessing new AI models developed by OpenAI. Unlike most AI systems which are designed for one use-case, the API today provides a general-purpose “text in, text out” interface, allowing users to try it on virtually any English language task. You can now request access in order to integrate the API into your product, develop an entirely new application, or help us explore the strengths and limits of this technology."""

response = openai.Completion.create(model="davinci", prompt=prompt, stop="\n", temperature=0.9, max_tokens=100)

print(response)

我遇到了一个错误

错误

"Must provide an 'engine' parameter to create a %s" % cls, "engine". openai.error.InvalidRequestError: Must provide an 'engine' parameter to create a <class 'openai.api_resources.completion.Completion'>

我正在使用 python 3.7.6

最佳答案

您似乎混淆了引擎参数和模型参数。请查看此文档以了解正确的调用方式:https://beta.openai.com/docs/developer-quickstart/python-bindings

请将 model = "davinci" 更改为 engine = "davinci" 你应该可以开始了。

关于python - 无效请求错误 : Must provide an 'engine' parameter while invoking openAI API for text generation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65667929/

相关文章:

python - 使用 categorical_crossentropy 时出错

python - 如何使用python从网站中提取所有链接

python - 如何在热图中强调更微妙的特征(较小的数字)?

windows - 如何写 Yes 命令作为这个问题的答案?谢谢

next.js - OpenAI GPT-3 API 错误 : 'text' does not exist TS(2339) & 'prompt' does not exist on type 'CreateChatCompletion' TS(2345)

python - 使用 GPT API 创建多消息对话

python - 创建嵌套字典的迭代问题

python - 如何在networkx中使用python随机排列图的节点?

openai-api - 谁能告诉我我在 OpenAI 的 createChatCompletion 上得到 `error invalid_request_error`