添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello
I am trying to use the gpt-4 model in my epro code when trying to run the service it gives me the following error

AttributeError: Module ‘openai’ does not have attribute ‘ChatCompletion’

For what is this? Is it possible to use that model?

If your code was using that old of a library, it’s likely not compatible with modern library.

You’d have to post code snippets for us to be able to help. Is it running after updating library? Still same error?

Yeah, I’m out of ideas. With that error, though, it sounds like it’s not loading the correct library.

Maybe set-up a test script with just basics to see if it works?

I think you have to use chat.completion in the update now, so it would look something like this:

  completion = openai.chat.completions.create(
    model=self.model,
    messages=self.get_messages(prompt, question),
    max_tokens=500,
    temperature=float(self.temperature),
response = completion.choices[0].message.content
        "model": "gpt-4-vision-preview",
        "messages": PROMPT_MESSAGES,
        "api_key": os.environ["OPENAI_API_KEY"],
        "headers": {"Openai-Version": "2023-11-07"},
        "max_tokens": 500,
    result = openai.ChatCompletion.create(**params)
    print(result.choices[0].message.content)
    return result.choices[0].message.content

Im doing everything exactly as from latest Jason AI video and on his video you can see openai.ChatCompletion.create works fine.

Is it possible it doesn’t work because of this major outage across ChatGPT and API?

@Shebi You are correct. It feels like they changed it overnight. This works in a Jupyter notebook

    import openai
    response = openai.chat.completions.create(
        model="gpt-4",
        messages=[
            {"role": "system", "content": "You are a 5 year old"},
            {"role": "user", "content": "what is pi"},
    message_content = response.choices[0].message.content
    print (message_content)