如何解决InvalidRequestError:在调用 openAI API 以生成文本时必须提供“引擎”参数
我正在尝试 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)
我收到一个错误
错误
"必须提供一个 'engine' 参数来创建一个 %s" % cls,"engine"。
openai.error.InvalidRequestError:必须提供一个“引擎”参数来创建一个
我使用的是 python 3.7.6
解决方法
您似乎将引擎参数与模型参数混淆了。请查看此文档以了解正确的调用方式:https://beta.openai.com/docs/developer-quickstart/python-bindings
请将 model = "davinci"
改为 engine = "davinci"
你应该没事了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。