Closed
Description
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'm trying to create a simple BOT however getting the below error.
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: #742
Validations:
Environment Check done
Upgraded OpenAI Python Library
Restarted Kernel
Validated API key
To Reproduce
Code attached
Code snippets
# Streamlit UI
st.title("Vitamin Quiz Bot")
# Initialize session state
if 'iteration' not in st.session_state:
st.session_state.iteration = 0
st.session_state.quiz_active = False
# Main loop for the quiz
user_input = st.text_input("You (Iteration {}):".format(st.session_state.iteration))
if user_input.lower() == "lets begin the quiz":
st.session_state.quiz_active = True
if st.session_state.quiz_active:
# Generate a question
chat_history = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Generate a question about vitamins and minerals for a 3rd-grade quiz."},
]
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=chat_history,
max_tokens=50,
temperature=0.7,
)
question = response['choices'][0]['message']['content'].strip()
# Display the question
st.text("Bot: {}".format(question))
# Get user's response
user_response = st.text_input("You:")
# Evaluate the response
if st.button("Submit"):
st.text("You said: {}".format(user_response))
OS
windows
Python version
Python 3.12.1
Library version
openai 1.5.0