Fix : Handle empty list error with a default response
Browse files
app.py
CHANGED
@@ -27,7 +27,12 @@ if user_input := st.chat_input("What is up?"):
|
|
27 |
bot_reply = response.json()
|
28 |
|
29 |
# Extract assistant response
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Display assistant response in chat message container
|
33 |
with st.chat_message("assistant"):
|
|
|
27 |
bot_reply = response.json()
|
28 |
|
29 |
# Extract assistant response
|
30 |
+
if bot_reply !=[]:
|
31 |
+
assistant_response = bot_reply[0]["text"]
|
32 |
+
# Handle empty api responses
|
33 |
+
else:
|
34 |
+
assistant_response = 'API request returned with an empty list []. Please continue with a different question'
|
35 |
+
|
36 |
|
37 |
# Display assistant response in chat message container
|
38 |
with st.chat_message("assistant"):
|