我正在尝试 OpenAI 中给出的这段代码。
代码
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/