Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,18 +38,17 @@ def respond(
|
|
38 |
):
|
39 |
token = message.choices[0].delta.content
|
40 |
|
41 |
-
#
|
42 |
try:
|
43 |
json.loads(token)
|
44 |
except json.JSONDecodeError:
|
45 |
-
yield
|
46 |
break
|
47 |
|
48 |
response += token
|
49 |
yield response
|
50 |
except Exception as e:
|
51 |
yield f"Error: {e}"
|
52 |
-
|
53 |
"""
|
54 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
55 |
"""
|
|
|
38 |
):
|
39 |
token = message.choices[0].delta.content
|
40 |
|
41 |
+
# If the token is not a valid JSON string, yield it as is
|
42 |
try:
|
43 |
json.loads(token)
|
44 |
except json.JSONDecodeError:
|
45 |
+
yield token
|
46 |
break
|
47 |
|
48 |
response += token
|
49 |
yield response
|
50 |
except Exception as e:
|
51 |
yield f"Error: {e}"
|
|
|
52 |
"""
|
53 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
54 |
"""
|