This is the error I’m facing:
{
“name”: “AttributeError”,
“message”: “module ‘openai’ has no attribute ‘error’”,
“stack”: "---------------------------------------------------------------------------
APIRemovedInV1 Traceback (most recent call last)
File c:\Users\shikh\helper_functions.py:20, in print_llm_response(prompt)
19 raise ValueError("Input must be a string enclosed in quotes.")
—> 20 response = openai.ChatCompletion.create(
21 model="gpt-3.5-turbo",
22 messages=[
23 {
24 "role": "system",
25 "content": "You are a helpful but terse AI assistant who gets straight to the point.",
26 },
27 {"role": "user", "content": prompt},
28 ],
29 temperature=0.0,
30 ).choices[0][‘message’][‘content’]
31 print("*" * 100)
File c:\Users\shikh\AppData\Local\Programs\Python\Python312\Lib\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 GitHub - openai/openai-python: The official Python library for the OpenAI API 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: v1.0.0 Migration Guide · openai/openai-python · Discussion #742 · GitHub
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Cell In[1], line 4
1 from helper_functions import print_llm_response, get_llm_response, get_chat_completion
3 # Example usage
----> 4 print_llm_response("capital of france?")
File c:\Users\shikh\helper_functions.py:37, in print_llm_response(prompt)
35 except TypeError as e:
36 print("Error:", str(e))
—> 37 except openai.error.OpenAIError as e:
38 print("API error:", str(e))
39 time.sleep(60)
AttributeError: module ‘openai’ has no attribute ‘error’"
}