Revert "fix pre commit hook bug"

This reverts commit 41308f3acac33b4315325f165b1e0b5221e99cd0.
This commit is contained in:
rxdaozhang 2025-03-11 02:28:00 +08:00
parent a256d5589a
commit c37c6c19b5

22
app.py
View File

@ -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)
uvicorn.run(app, host="localhost", port=5172)