Skip to content

Commit 41308f3

Browse files
committed
fix pre commit hook bug
1 parent 77df977 commit 41308f3

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

app.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import asyncio
2+
import threading
23
import uuid
4+
import webbrowser
35
from datetime import datetime
46
from json import dumps
57

@@ -10,6 +12,7 @@
1012
from fastapi.templating import Jinja2Templates
1113
from pydantic import BaseModel
1214

15+
1316
app = FastAPI()
1417

1518
app.mount("/static", StaticFiles(directory="static"), name="static")
@@ -172,7 +175,9 @@ async def event_generator():
172175

173176
task = task_manager.tasks.get(task_id)
174177
if task:
175-
yield f"event: status\ndata: {dumps({'type': 'status','status': task.status,'steps': task.steps})}\n\n"
178+
message = {"type": "status", "status": task.status, "steps": task.steps}
179+
json_message = dumps(message)
180+
yield f"event: status\ndata: {json_message}\n\n"
176181

177182
while True:
178183
try:
@@ -190,7 +195,13 @@ async def event_generator():
190195
elif event["type"] == "step":
191196
task = task_manager.tasks.get(task_id)
192197
if task:
193-
yield f"event: status\ndata: {dumps({ 'type': 'status','status': task.status,'steps': task.steps })}\n\n"
198+
message = {
199+
"type": "status",
200+
"status": task.status,
201+
"steps": task.steps,
202+
}
203+
json_message = dumps(message)
204+
yield f"event: status\ndata: {json_message}\n\n"
194205
yield f"event: {event['type']}\ndata: {formatted_event}\n\n"
195206
elif event["type"] in ["think", "tool", "act", "run"]:
196207
yield f"event: {event['type']}\ndata: {formatted_event}\n\n"
@@ -241,7 +252,12 @@ async def generic_exception_handler(request: Request, exc: Exception):
241252
)
242253

243254

255+
def open_local_browser():
256+
webbrowser.open_new_tab("http://localhost:5172")
257+
258+
244259
if __name__ == "__main__":
260+
threading.Timer(3, open_local_browser).start()
245261
import uvicorn
246262

247-
uvicorn.run(app, host="localhost", port=5172)
263+
uvicorn.run(app, host="localhost", port=5172)

0 commit comments

Comments
 (0)