gpt4 book ai didi

Python OpenAI API 类型错误

转载 作者:行者123 更新时间:2023-12-02 22:48:12 25 4
gpt4 key购买 nike

我正在尝试使用 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'

问题是什么?

我尝试更新需求(urrlib3Requestsopenai)和 Python。但它们都有实际版本。

最佳答案

我也遇到过类似的情况。您使用的 OpenAI API 库的版本可能存在问题。尝试将库更新到最新版本,看看是否可以解决问题。

pip install openai --upgradelibaray

关于Python OpenAI API 类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75985331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com