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

Fix APIRemovedInV1 error by downgrading OpenAI library to v0.28 #39

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

alexfazio
Copy link
Contributor

This commit resolves the APIRemovedInV1 error in the Google Colab notebook by downgrading the OpenAI Python library to version 0.28. The error was caused by attempting to access the deprecated openai.ChatCompletion method in versions 1.0.0 and above.

Pinning the library to the older version ensures compatibility with the existing codebase and allows the code to function correctly without accessing the deprecated method.
Screenshot · Arc gpt_prompt_engineer ipynb - Colab · 2024-04-10 at 19 31 59@2x

---------------------------------------------------------------------------
APIRemovedInV1                            Traceback (most recent call last)
[<ipython-input-11-5fb2904844c6>](https://localhost:8080/#) in <cell line: 1>()
----> 1 generate_optimal_prompt(description, test_cases, NUMBER_OF_PROMPTS, use_wandb)

2 frames
[/usr/local/lib/python3.10/dist-packages/openai/lib/_old_api.py](https://localhost:8080/#) in __call__(self, *_args, **_kwargs)
     37 
     38     def __call__(self, *_args: Any, **_kwargs: Any) -> Any:
---> 39         raise APIRemovedInV1(symbol=self._symbol)
     40 
     41 

APIRemovedInV1: 

You tried to access openai.ChatCompletion, 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`

A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
<img width="1396" alt="Screenshot · Arc gpt_prompt_engineer ipynb - Colab · 2024-04-10 at 19 31 59@2x" src="https://github.com/mshumer/gpt-prompt-engineer/assets/34505954/23c46d88-4072-4134-a4fd-83c6274d566b">

… APIRemovedInV1 issue

In this commit, I have addressed an `APIRemovedInV1` issue in the Google Colab notebook on GitHub by updating the OpenAI Python library installation to version `0.28`. 

By pinning the library to the older version, the code now functions correctly without attempting to access the deprecated openai.ChatCompletion method. 

This update ensures compatibility with the existing codebase and resolves the issue.
@mshumer mshumer merged commit bfe4257 into mshumer:main Apr 12, 2024
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

Successfully merging this pull request may close these issues.

2 participants