Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
·
4264c5b
1
Parent(s):
074c22b
reintroduce error catching, but not with global semaphore yet
Browse files
app.py
CHANGED
|
@@ -101,11 +101,11 @@ def text_stream(stream):
|
|
| 101 |
def get_stream_warning_error(stream):
|
| 102 |
error = None
|
| 103 |
warning = None
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
return warning, error
|
| 110 |
|
| 111 |
# @retry(wait=wait_random_exponential(min=0.5, max=2), stop=stop_after_attempt(3))
|
|
@@ -239,10 +239,10 @@ with main:
|
|
| 239 |
with st.chat_message(message["role"],avatar=avatar):
|
| 240 |
if message["content"] is not None:
|
| 241 |
st.markdown(message["content"])
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
|
| 247 |
if prompt := st.chat_input("Type a message!", max_chars=1000):
|
| 248 |
handle_user_input(prompt)
|
|
|
|
| 101 |
def get_stream_warning_error(stream):
|
| 102 |
error = None
|
| 103 |
warning = None
|
| 104 |
+
for chunk in stream:
|
| 105 |
+
if chunk["error"] is not None:
|
| 106 |
+
error = chunk["error"]
|
| 107 |
+
if chunk["warning"] is not None:
|
| 108 |
+
warning = chunk["warning"]
|
| 109 |
return warning, error
|
| 110 |
|
| 111 |
# @retry(wait=wait_random_exponential(min=0.5, max=2), stop=stop_after_attempt(3))
|
|
|
|
| 239 |
with st.chat_message(message["role"],avatar=avatar):
|
| 240 |
if message["content"] is not None:
|
| 241 |
st.markdown(message["content"])
|
| 242 |
+
if message["error"] is not None:
|
| 243 |
+
st.error(message["error"],icon="🚨")
|
| 244 |
+
if message["warning"] is not None:
|
| 245 |
+
st.warning(message["warning"],icon="⚠️")
|
| 246 |
|
| 247 |
if prompt := st.chat_input("Type a message!", max_chars=1000):
|
| 248 |
handle_user_input(prompt)
|