Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,13 @@ st.title("💬 Chatbot")
|
|
| 9 |
st.caption("")
|
| 10 |
|
| 11 |
# Initialize session state for storing messages if it doesn't already exist
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
# Display all previous messages
|
| 15 |
for msg in st.session_state.messages:
|
| 16 |
st.chat_message(msg["role"]).write(msg["content"])
|
| 17 |
|
| 18 |
-
# Select model using a dropdown
|
| 19 |
-
model_choice = st.selectbox('Choose a model:', ['gpt-3.5-turbo', 'gpt-4-turbo'])
|
| 20 |
|
| 21 |
# Input for new prompts
|
| 22 |
prompt = st.chat_input("Enter your question:")
|
|
@@ -38,3 +37,6 @@ if prompt:
|
|
| 38 |
# Append and display the assistant's response
|
| 39 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 40 |
st.chat_message("assistant").write(msg)
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
st.caption("")
|
| 10 |
|
| 11 |
# Initialize session state for storing messages if it doesn't already exist
|
| 12 |
+
if "messages" not in st.session_state:
|
| 13 |
+
st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}]
|
| 14 |
|
| 15 |
# Display all previous messages
|
| 16 |
for msg in st.session_state.messages:
|
| 17 |
st.chat_message(msg["role"]).write(msg["content"])
|
| 18 |
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Input for new prompts
|
| 21 |
prompt = st.chat_input("Enter your question:")
|
|
|
|
| 37 |
# Append and display the assistant's response
|
| 38 |
st.session_state.messages.append({"role": "assistant", "content": msg})
|
| 39 |
st.chat_message("assistant").write(msg)
|
| 40 |
+
|
| 41 |
+
# Select model using a dropdown
|
| 42 |
+
model_choice = st.selectbox('Choose a model:', ['gpt-3.5-turbo', 'gpt-4-turbo'])
|