# OpenManus **Repository Path**: hong0220/OpenManus ## Basic Information - **Project Name**: OpenManus - **Description**: 开源的 OpenManus 实现 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-11 - **Last Updated**: 2026-05-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 直接使用 ```bash # 1. 克隆项目 git clone https://github.com/henryalps/OpenManus.git cd OpenManus # 2. 启动系统 docker-compose up --build ``` ### 本地开发 ```bash # 1. 安装依赖 pip install -r requirements.txt npm install # 2. 配置环境变量 # 创建 .env 文件,配置 LLM API 密钥 # 3. 启动后端 uvicorn src.server:app --reload python -m uvicorn src.server:app --reload python -m uvicorn src.server:app --host 0.0.0.0 --port 8000 --reload # 4. 启动前端 npm run dev ``` ### 调试 ``` Web 界面:http://localhost:3000 API 文档:http://localhost:8000/docs 帮我规划一个巴黎五日游,预算中等,喜欢艺术和美食 分析特斯拉股票最近一个月的走势 分析特斯拉股票趋势并生成报告 用 Python 写一个简单的计算器程序 研究人工智能在医疗领域的最新应用 帮我研究电动汽车市场,包括: 1.主要厂商和市场份额 2.最新技术趋势 3.未来发展前景 请提供数据和来源链接 python src/client.py --task "Plan a 3-day trip to Tokyo" curl http://localhost:8000/status curl -X POST http://localhost:8000/api/chat/stream \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "帮我规划一个北京五日游" } ], "debug": false }' ``` ### 完整的数据流过程 ``` 1. 用户输入 ↓ 2. Web UI / CLI Client ↓ (HTTP POST /api/chat/stream) 3. FastAPI Server ↓ (验证请求) 4. Workflow Service ↓ (格式化消息) 5. LangGraph Workflow ↓ ├─→ Coordinator Node │ ↓ (调用 LLM) │ ├─→ LLM Manager │ │ ↓ (选择适当的 LLM) │ │ └─→ 返回响应 │ ↓ ├─→ Planner Node │ ↓ (制定计划) │ └─→ 更新状态 │ ↓ ├─→ Supervisor Node │ ↓ (路由决策) │ ├─→ Researcher Node │ │ ↓ (使用工具) │ │ ├─→ Search Tool │ │ ├─→ Crawl Tool │ │ └─→ 返回结果 │ │ │ ├─→ Coder Node │ │ ↓ (使用工具) │ │ ├─→ Code Executor │ │ ├─→ Python REPL │ │ └─→ 返回结果 │ │ │ ├─→ Browser Node │ │ ↓ (使用工具) │ │ ├─→ Web Browser │ │ └─→ 返回结果 │ │ │ └─→ Reporter Node │ ↓ (生成报告) │ └─→ 返回最终结果 │ 6. 流式返回给客户端 ↓ (SSE Events) 7. 用户看到结果 ``` ### 状态对象的变化 ```python # 初始状态 state = { "messages": [HumanMessage(content="用户任务")], "full_plan": "", "next": "", "deep_thinking_mode": False, "search_before_planning": False } # Coordinator 处理后 state = { "messages": [ HumanMessage(content="用户任务"), AIMessage(content="协调器响应") ], "full_plan": "", "next": "planner", # 决定交给 planner ... } # Planner 处理后 state = { "messages": [...], "full_plan": "1. 步骤一\n2. 步骤二\n3. 步骤三", "next": "supervisor", ... } # Supervisor 路由后 state = { "messages": [...], "full_plan": "...", "next": "researcher", # 决定执行研究 ... } # Researcher 执行后 state = { "messages": [ ..., AIMessage(content="研究发现...") ], "full_plan": "...", "next": "supervisor", # 返回 supervisor ... } # 最终 Reporter 处理后 state = { "messages": [ ..., AIMessage(content="最终报告...") ], "full_plan": "...", "next": "__end__", # 结束 ... } ``` ### 添加新智能体 1. 在 `src/agents/` 创建新的agent实现 2. 在 `src/agents/nodes/` 创建对应的node 3. 在 `graph.py` 中添加节点和边 4. 在 `config/agents.py` 中配置LLM映射 5. 在 `TEAM_MEMBERS` 中添加新成员 ### 添加新工具 1. 在 `src/tools/` 创建工具实现 2. 使用 `@create_logged_tool` 装饰器包装 3. 在对应agent中集成工具 4. 更新提示模板说明工具用法 ### 自定义工作流 - 修改 `graph.py` 中的节点连接关系 - 调整监督器的决策逻辑 - 定制状态结构满足特定需求 ### 提示词模板示例 ``` 你是一个{agent_role}代理。 你的职责是: 1. {responsibility_1} 2. {responsibility_2} 3. {responsibility_3} 可用工具: {available_tools} 当前任务: {task_description} 请按照以下步骤执行: 1. 分析任务 2. 制定策略 3. 执行操作 4. 返回结果 输出格式: {output_format} ``` ### 容器构建 ``` # 查看日志 docker-compose logs unified # 构建并启动 docker-compose up -d # 清理并重建 docker-compose down docker system prune -a docker-compose up --build # 检查端口占用 lsof -i :8000 ```