Update app.py
Browse files
app.py
CHANGED
|
@@ -125,10 +125,11 @@ if prompt := st.chat_input():
|
|
| 125 |
)
|
| 126 |
response.raise_for_status()
|
| 127 |
|
| 128 |
-
#
|
| 129 |
-
for
|
| 130 |
-
if
|
| 131 |
-
|
|
|
|
| 132 |
except requests.exceptions.Timeout:
|
| 133 |
yield "The request timed out. Please try again later."
|
| 134 |
except requests.exceptions.RequestException as e:
|
|
@@ -147,4 +148,3 @@ if prompt := st.chat_input():
|
|
| 147 |
|
| 148 |
# Auto-save the updated chat history
|
| 149 |
save_chat_history(st.session_state["session_name"], st.session_state["messages"])
|
| 150 |
-
|
|
|
|
| 125 |
)
|
| 126 |
response.raise_for_status()
|
| 127 |
|
| 128 |
+
# Process and yield only the response field
|
| 129 |
+
for line in response.iter_lines():
|
| 130 |
+
if line:
|
| 131 |
+
data = json.loads(line.decode("utf-8"))
|
| 132 |
+
yield data.get("response", "")
|
| 133 |
except requests.exceptions.Timeout:
|
| 134 |
yield "The request timed out. Please try again later."
|
| 135 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 148 |
|
| 149 |
# Auto-save the updated chat history
|
| 150 |
save_chat_history(st.session_state["session_name"], st.session_state["messages"])
|
|
|