我正在尝试使用 OpenAI API 并遇到问题。 我使用了文档中的标准示例代码:
import openai
API_KEY = 'MY_API_KEY'
openai.api_key = API_KEY
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
print(response)
输出为:
TypeError: Queue.init() takes 1 positional argument but 2 were given'
问题是什么?
我尝试更新需求(urrlib3、Requests 和 openai)和 Python。 但它们都有实际版本。
最佳答案
我也遇到过类似的情况。您使用的 OpenAI API 库的版本可能存在问题。尝试将库更新到最新版本,看看是否可以解决问题。
pip install openai --upgradelibaray
关于Python OpenAI API 类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75985331/