From c37c6c19b5c58046918a58d41bf9c540579f6b7f Mon Sep 17 00:00:00 2001 From: rxdaozhang <896836861@qq.com> Date: Tue, 11 Mar 2025 02:28:00 +0800 Subject: [PATCH] Revert "fix pre commit hook bug" This reverts commit 41308f3acac33b4315325f165b1e0b5221e99cd0. --- app.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) 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)