diff --git a/app.py b/app.py index cebca55..5adb62e 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,5 @@ import asyncio -import threading import uuid -import webbrowser from datetime import datetime from json import dumps @@ -12,7 +10,6 @@ from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates from pydantic import BaseModel - app = FastAPI() app.mount("/static", StaticFiles(directory="static"), name="static") @@ -175,9 +172,7 @@ async def task_events(task_id: str): task = task_manager.tasks.get(task_id) if task: - message = {"type": "status", "status": task.status, "steps": task.steps} - json_message = dumps(message) - yield f"event: status\ndata: {json_message}\n\n" + yield f"event: status\ndata: {dumps({'type': 'status','status': task.status,'steps': task.steps})}\n\n" while True: try: @@ -195,13 +190,7 @@ async def task_events(task_id: str): elif event["type"] == "step": task = task_manager.tasks.get(task_id) if task: - message = { - "type": "status", - "status": task.status, - "steps": task.steps, - } - json_message = dumps(message) - yield f"event: status\ndata: {json_message}\n\n" + yield f"event: status\ndata: {dumps({ 'type': 'status','status': task.status,'steps': task.steps })}\n\n" yield f"event: {event['type']}\ndata: {formatted_event}\n\n" elif event["type"] in ["think", "tool", "act", "run"]: yield f"event: {event['type']}\ndata: {formatted_event}\n\n" @@ -252,12 +241,7 @@ async def generic_exception_handler(request: Request, exc: Exception): ) -def open_local_browser(): - webbrowser.open_new_tab("http://localhost:5172") - - if __name__ == "__main__": - threading.Timer(3, open_local_browser).start() import uvicorn - uvicorn.run(app, host="localhost", port=5172) \ No newline at end of file + uvicorn.run(app, host="localhost", port=5172)