Python OpenAI API 类型错误

问题描述 投票:0回答:1

我在尝试使用 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。 但他们都有实际版本。

python typeerror urllib3 openai-api chatgpt-api
1个回答
0
投票

我有一个类似的案例。您使用的 OpenAI API 库的版本可能存在问题。尝试将库更新到最新版本,看看是否能解决问题。

pip install openai --upgradelibaray

© www.soinside.com 2019 - 2024. All rights reserved.