Commit
•
a7d579b
1
Parent(s):
1ced004
Fix : Handle empty list error with a default response (#8)
Browse files- Fix : Handle empty list error with a default response (7251e5c485ed4a47c9c9ca859f96c125f9d9bdd6)
Co-authored-by: Anand <pvanand@users.noreply.huggingface.co>
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"):
|