From b23ab9a42a337e404ef42349d156adabe6f2af2c Mon Sep 17 00:00:00 2001 From: liangxinbing <1580466765@qq.com> Date: Mon, 10 Mar 2025 20:13:06 +0800 Subject: [PATCH] update Roadmap and format code --- README.md | 9 +-------- README_zh.md | 9 +-------- app.py | 37 ++++++++++++++++++++----------------- static/main.js | 3 +-- static/style.css | 2 +- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index debbef6..5be60fd 100644 --- a/README.md +++ b/README.md @@ -129,14 +129,7 @@ Or contact @mannaandpoem via 📧email: mannaandpoem@gmail.com ## Roadmap -After comprehensively gathering feedback from community members, we have decided to adopt a 3-4 day iteration cycle to gradually implement the highly anticipated features. - -- [ ] Enhance Planning capabilities, optimize task breakdown and execution logic -- [ ] Introduce standardized evaluation metrics (based on GAIA and TAU-Bench) for continuous performance assessment and optimization -- [ ] Expand model adaptation and optimize low-cost application scenarios -- [ ] Implement containerized deployment to simplify installation and usage workflows -- [ ] Enrich example libraries with more practical cases, including analysis of both successful and failed examples -- [ ] Frontend/backend development to improve user experience +- [ ] Improve the UI’s visual appeal to create a more intuitive and seamless user experience. ## Community Group Join our networking group on Feishu and share your experience with other developers! diff --git a/README_zh.md b/README_zh.md index 9a3dfe1..1f12b65 100644 --- a/README_zh.md +++ b/README_zh.md @@ -129,14 +129,7 @@ python run_flow.py ## 发展路线 -在全面收集了社区成员的反馈后,我们决定采用 3-4 天为周期的迭代模式,逐步实现大家期待的功能。 - -- [ ] 增强 Planning 能力,优化任务分解和执行逻辑 -- [ ] 引入标准化评测,基于 GAIA 和 TAU-Bench,持续评估并优化性能 -- [ ] 拓展模型适配,优化低成本应用场景 -- [ ] 实现容器化部署,简化安装和使用流程 -- [ ] 丰富示例库,增加更多实用案例,包含成功和失败示例的分析 -- [ ] 前后端开发,提供用户体验 +- [ ] 提高用户界面的视觉吸引力,以创建更直观和无缝的用户体验。 ## 交流群 diff --git a/app.py b/app.py index 9307852..baad1cf 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,14 @@ -from fastapi import FastAPI, Request, Body, HTTPException +import asyncio +import uuid +from datetime import datetime +from json import dumps + +from fastapi import Body, FastAPI, HTTPException, Request +from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import HTMLResponse, JSONResponse, StreamingResponse from fastapi.staticfiles import StaticFiles from fastapi.templating import Jinja2Templates -from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel -from datetime import datetime -import asyncio -import uuid -from json import dumps app = FastAPI() @@ -99,6 +100,7 @@ async def create_task(prompt: str = Body(..., embed=True)): from app.agent.manus import Manus + async def run_task(task_id: str, prompt: str): try: task_manager.tasks[task_id].status = "running" @@ -108,7 +110,7 @@ async def run_task(task_id: str, prompt: str): description="A versatile agent that can solve various tasks using multiple tools", max_steps=30 ) - + async def on_think(thought): await task_manager.update_task_step(task_id, 0, thought, "think") @@ -120,18 +122,19 @@ async def run_task(task_id: str, prompt: str): async def on_run(step, result): await task_manager.update_task_step(task_id, step, result, "run") - + from app.logger import logger - + class SSELogHandler: def __init__(self, task_id): self.task_id = task_id - + async def __call__(self, message): import re + # 提取 - 后面的内容 cleaned_message = re.sub(r'^.*? - ', '', message) - + event_type = "log" if "✨ Manus's thoughts:" in cleaned_message: event_type = "think" @@ -143,9 +146,9 @@ async def run_task(task_id: str, prompt: str): event_type = "error" elif "🏁 Special tool" in cleaned_message: event_type = "complete" - + await task_manager.update_task_step(self.task_id, 0, cleaned_message, event_type) - + sse_handler = SSELogHandler(task_id) logger.add(sse_handler) @@ -163,7 +166,7 @@ async def task_events(task_id: str): return queue = task_manager.queues[task_id] - + task = task_manager.tasks.get(task_id) if task: yield f"event: status\ndata: {dumps({ @@ -176,9 +179,9 @@ async def task_events(task_id: str): try: event = await queue.get() formatted_event = dumps(event) - + yield ": heartbeat\n\n" - + if event["type"] == "complete": yield f"event: complete\ndata: {formatted_event}\n\n" break @@ -198,7 +201,7 @@ async def task_events(task_id: str): yield f"event: {event['type']}\ndata: {formatted_event}\n\n" else: yield f"event: {event['type']}\ndata: {formatted_event}\n\n" - + except asyncio.CancelledError: print(f"Client disconnected for task {task_id}") break diff --git a/static/main.js b/static/main.js index 5015c34..49d5dd7 100644 --- a/static/main.js +++ b/static/main.js @@ -3,7 +3,7 @@ let currentEventSource = null; function createTask() { const promptInput = document.getElementById('prompt-input'); const prompt = promptInput.value.trim(); - + if (!prompt) { alert("Please enter a valid prompt"); promptInput.focus(); @@ -692,4 +692,3 @@ document.addEventListener('DOMContentLoaded', () => { }); } }); - diff --git a/static/style.css b/static/style.css index a1173fb..776304e 100644 --- a/static/style.css +++ b/static/style.css @@ -278,7 +278,7 @@ button:hover { white-space: pre-wrap; color: var(--text-color); background: var(--bg-color); - + &.log { background: var(--bg-color); border-left: 4px solid var(--text-light);