Spaces:
Paused
Paused
History realtime update
Browse files
app.py
CHANGED
|
@@ -185,12 +185,15 @@ class GradioEvents:
|
|
| 185 |
elif t == "done":
|
| 186 |
break
|
| 187 |
|
|
|
|
|
|
|
|
|
|
| 188 |
yield {
|
| 189 |
chatbot: gr.update(value=display_messages),
|
| 190 |
state: gr.update(value=state_value),
|
| 191 |
}
|
| 192 |
|
| 193 |
-
#
|
| 194 |
ctx["history"] = display_messages
|
| 195 |
|
| 196 |
yield {
|
|
@@ -206,6 +209,7 @@ class GradioEvents:
|
|
| 206 |
"content": f'<span style="color: var(--color-red-400)">{exc}</span>',
|
| 207 |
"metadata": {"title": "💥 Error"},
|
| 208 |
})
|
|
|
|
| 209 |
yield {
|
| 210 |
chatbot: gr.update(value=display_messages),
|
| 211 |
state: gr.update(value=state_value),
|
|
|
|
| 185 |
elif t == "done":
|
| 186 |
break
|
| 187 |
|
| 188 |
+
# Update history in real-time so state always has latest messages
|
| 189 |
+
ctx["history"] = display_messages
|
| 190 |
+
|
| 191 |
yield {
|
| 192 |
chatbot: gr.update(value=display_messages),
|
| 193 |
state: gr.update(value=state_value),
|
| 194 |
}
|
| 195 |
|
| 196 |
+
# Final sync (ensures tool output messages are saved)
|
| 197 |
ctx["history"] = display_messages
|
| 198 |
|
| 199 |
yield {
|
|
|
|
| 209 |
"content": f'<span style="color: var(--color-red-400)">{exc}</span>',
|
| 210 |
"metadata": {"title": "💥 Error"},
|
| 211 |
})
|
| 212 |
+
ctx["history"] = display_messages
|
| 213 |
yield {
|
| 214 |
chatbot: gr.update(value=display_messages),
|
| 215 |
state: gr.update(value=state_value),
|