Skip to content
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

Repeated Error: openai.Completion Not Supported in OpenAI Python >=1.0.0 Despite Multiple Fix Attempts (Python Versions and API Key Methods) #1788

Open
1 task done
HosungYou opened this issue Oct 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@HosungYou
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

I am encountering a recurring error when trying to access openai.Completion. The error message suggests that this is no longer supported in versions of the OpenAI Python library greater than 1.0.0. Despite following the official migration guide and pinning to earlier versions (e.g., openai==0.28), the issue remains unresolved. I have tried various solutions such as:

Downgrading Python from 3.12 to 3.10, and even 3.9
Adjusting API key access methods (environment variables, hardcoding, etc.)
Attempting multiple different virtual environments
Following the migration instructions from the OpenAI repository and discussions, such as using openai migrate.
No matter what I try, I keep encountering the following error:

vbnet
Copy code
You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28
Despite using the suggested approach to pin the version (pip install openai==0.28), the issue remains unresolved. Additionally, following the migration guide (#742) didn't yield any success.

To Reproduce

Steps to reproduce the behavior:

  1. Set up a Python virtual environment with Python 3.10.
  2. Install openai using pip install openai==0.27.0 or any version before 1.0.0.
  3. Attempt to use openai.Completion.create() in any script.
  4. The above error consistently occurs.

Code snippets

Code snippets
Heres the code I used to trigger the error:

python
Copy code
import openai
openai.api_key = 'sk-xxxxxxx'

response = openai.Completion.create(
    engine="davinci",
    prompt="Tell me a joke.",
    max_tokens=50
)
print(response.choices[0].text)
Error output:
vbnet
Copy code
You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.

You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`

What I Tried:
Downgrading the Python version from 3.12 to 3.10.
Using different versions of the OpenAI library (0.27.0, 0.28.0, and 0.29.0).
Setting API keys via environment variables and directly in the code.
Trying the migration tool (openai migrate) but to no avail.
Ensuring all dependencies (like google-api-python-client and pdfplumber) are up to date and properly installed.

OS

macOS Monterey

Python version

Python 3.10.15 (also tried Python 3.12.5)

Library version

openai v1.0.1 (Issue also persists with version 0.27.0 and 0.28.0)

@HosungYou HosungYou added the bug Something isn't working label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant