Skip to content

Error: module 'openai' has no attribute 'completion' #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kaspiasz opened this issue Nov 7, 2023 · 1 comment
Closed

Error: module 'openai' has no attribute 'completion' #722

kaspiasz opened this issue Nov 7, 2023 · 1 comment

Comments

@kaspiasz
Copy link

kaspiasz commented Nov 7, 2023

It was working before the update. Are there any alternatives to initialize the process?

def analyze_text_with_gpt4(text):
    response = openai.ChatCompletion.create(
        model="gpt-4-1106-preview",
        messages=[
            {"role": "system", "content": "You are a helpful research assistant."},
            {"role": "user", "content": f"....: {text}"}
        ],
    )
    return response['choices'][0]['message']['content']

Except for switching back to the v0.28.

@RobertCraigie
Copy link
Collaborator

You want this:

from openai import OpenAI

client = OpenAI()

def analyze_text_with_gpt4(text):
    response = client.chat.completions.create(
        model="gpt-4-1106-preview",
        messages=[
            {"role": "system", "content": "You are a helpful research assistant."},
            {"role": "user", "content": f"....: {text}"}
        ],
    )
    return response.choices[0].message.content

Please try the migration CLI, it will make upgrading much easier!

openai migrate

@RobertCraigie RobertCraigie closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants