TypeError:“模块”对象对于 OpenAI 来说是不可调用的

问题描述 投票:0回答:1
import openai as OpenAI 
client = OpenAI()

completion = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
    {"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
  ]
)


打印(完成.choices[0].message)`

我得到的回应是


TypeError                                 Traceback (most recent call last)
<ipython-input-12-6de2ef8831ea> in <cell line: 2>()`your text`
      1 import openai as OpenAI
----> 2 client = OpenAI()
      3 
      4 completion = client.chat.completions.create(
      5   model="gpt-3.5-turbo",

TypeError: 'module' object is not callable`

我尝试使用 Google Bard 和 chat gpt 解决问题,但失败了

artificial-intelligence google-colaboratory openapi openai-api
1个回答
0
投票

更新: 我能够使用

解决这个问题
client = OpenAI

completion = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
    {"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
  ]
)

print(completion.choices[0].message)
© www.soinside.com 2019 - 2024. All rights reserved.