AttributeError: module 'openai' has no attribute 'openai_response'
Describe the bug
Just ran the documentation code on Jupyter notebook and got in python3.9/site-packages/openai/util.py:112 if isinstance(resp, openai.openai_response.OpenAIResponse): 113 organization = resp.organization 114 response_ms = resp.response_ms
AttributeError: module 'openai' has no attribute 'openai_response'
To Reproduce
pip install -U openai in jupyter notebook
Code snippets
import openai
openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
OS
macOS m1
Python version
Python v3.9.12
Library version
openai-python v0.27.0
Can you share a link to the code you are referencing?
this is the link of the code snippet (Chat Completion Introduction): https://platform.openai.com/docs/guides/chat/introduction
@kaanbursa I had the same issue after installing openai v0.27.0. Try to restart jupyter notebook kernel. It helped me. Another variant is to run python script instead of jupyter notebook
Yeah, this code works as is, please try using a virtual environment inside of Jupyter and it should do the trick!