DEV Community

Shaurya Tiwari
Shaurya Tiwari

Posted on

Help me with this setup hurrdle please, I have tried the conventional upgrade commands and even opaenai upgrade with migrate.

APIRemovedInV1 Traceback (most recent call last)
Cell In[5], line 1
----> 1 get_completion("What is 1+1?")

Cell In[3], line 3
1 def get_completion(prompt, model="gpt-3.5-turbo"):
2 messages = [{"role": "user", "content": prompt}]
----> 3 response = openai.ChatCompletion.create(
4 model=model,
5 messages=messages,
6 temperature=0,
7 )
8 return response.choices[0].message["content"]

File ~/Desktop/AI_agents/agents/lib/python3.11/site-packages/openai/lib/old_api.py:39, in APIRemovedInV1Proxy.call(self, _args, *_kwargs)
38 def __call
_(self, _args: Any, *_kwargs: Any) -> Any:
---> 39 raise APIRemovedInV1(symbol=self._symbol)

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

Top comments (0)