Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,9 @@ if "messages" not in st.session_state:
|
|
| 16 |
for msg in st.session_state.messages:
|
| 17 |
st.chat_message(msg["role"]).write(msg["content"])
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
# Input for new prompts
|
| 20 |
prompt = st.chat_input("Enter your question:")
|
| 21 |
if prompt:
|
|
@@ -30,10 +33,9 @@ if prompt:
|
|
| 30 |
# Use a spinner to indicate that the model is generating a response
|
| 31 |
with st.spinner('Thinking...'):
|
| 32 |
client = OpenAI(api_key=openai_api_key)
|
| 33 |
-
response = client.chat.completions.create(model=
|
| 34 |
msg = response.choices[0].message.content
|
| 35 |
|
| 36 |
# Append and display the assistant's response
|
| 37 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 38 |
st.chat_message("assistant").write(msg)
|
| 39 |
-
|
|
|
|
| 16 |
for msg in st.session_state.messages:
|
| 17 |
st.chat_message(msg["role"]).write(msg["content"])
|
| 18 |
|
| 19 |
+
# Select model using a dropdown
|
| 20 |
+
model_choice = st.selectbox('Choose a model:', ['gpt-3.5-turbo', 'gpt-4-turbo'])
|
| 21 |
+
|
| 22 |
# Input for new prompts
|
| 23 |
prompt = st.chat_input("Enter your question:")
|
| 24 |
if prompt:
|
|
|
|
| 33 |
# Use a spinner to indicate that the model is generating a response
|
| 34 |
with st.spinner('Thinking...'):
|
| 35 |
client = OpenAI(api_key=openai_api_key)
|
| 36 |
+
response = client.chat.completions.create(model=model_choice, messages=st.session_state.messages)
|
| 37 |
msg = response.choices[0].message.content
|
| 38 |
|
| 39 |
# Append and display the assistant's response
|
| 40 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 41 |
st.chat_message("assistant").write(msg)
|
|
|