Spaces:
Sleeping
Sleeping
Fix chat SSE events to match frontend protocol (result+done instead of success)
Browse files- backend/api/demo.py +13 -7
backend/api/demo.py
CHANGED
|
@@ -275,21 +275,27 @@ async def execute_query_stream(req: ExecuteQueryRequest):
|
|
| 275 |
|
| 276 |
if attempt_success:
|
| 277 |
success = True
|
|
|
|
| 278 |
yield {"data": json.dumps({
|
| 279 |
-
"type": "
|
| 280 |
"rows": rows,
|
| 281 |
"row_count": len(rows),
|
| 282 |
-
|
|
|
|
|
|
|
|
|
|
| 283 |
})}
|
| 284 |
done = True
|
| 285 |
break
|
| 286 |
|
| 287 |
total_reward = compute_episode_reward(all_step_rewards, success)
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
"
|
| 292 |
-
|
|
|
|
|
|
|
| 293 |
|
| 294 |
# Record GEPA history
|
| 295 |
gepa = get_gepa()
|
|
|
|
| 275 |
|
| 276 |
if attempt_success:
|
| 277 |
success = True
|
| 278 |
+
# Emit events matching the frontend's expected protocol
|
| 279 |
yield {"data": json.dumps({
|
| 280 |
+
"type": "result",
|
| 281 |
"rows": rows,
|
| 282 |
"row_count": len(rows),
|
| 283 |
+
})}
|
| 284 |
+
yield {"data": json.dumps({
|
| 285 |
+
"type": "done",
|
| 286 |
+
"attempts": attempt,
|
| 287 |
})}
|
| 288 |
done = True
|
| 289 |
break
|
| 290 |
|
| 291 |
total_reward = compute_episode_reward(all_step_rewards, success)
|
| 292 |
+
|
| 293 |
+
if not success:
|
| 294 |
+
# All attempts exhausted without success
|
| 295 |
+
yield {"data": json.dumps({
|
| 296 |
+
"type": "error",
|
| 297 |
+
"message": "Agent exhausted all repair attempts",
|
| 298 |
+
})}
|
| 299 |
|
| 300 |
# Record GEPA history
|
| 301 |
gepa = get_gepa()
|