# agent-orchestration **Repository Path**: goodking/agent-orchestration ## Basic Information - **Project Name**: agent-orchestration - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-27 - **Last Updated**: 2026-03-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # DeepResearch Agent - 自由探索Agent 一个能够自主浏览网页、分析内容并生成深度研究报告的AI Agent。 ## 核心特性 ### 1. 流程编排系统 (新增) ⭐ 专业的流程编排能力,解决调研类Agent的核心痛点: - **异常恢复** - 智能错误分类、指数退避重试、熔断保护、降级策略 - **深度调研** - 5种探索策略(广度优先、深度优先、自适应、聚焦式、并行) - **灵活调度** - 状态机驱动、条件分支、并行执行、检查点恢复 - **分层架构** - Master Agent + Planner + Researcher + Analyzer ### 2. 基础功能 - **自主浏览**: 根据主题自动搜索并浏览相关网页 - **智能分析**: AI分析内容相关性,判断链接价值 - **深度探索**: 递归访问相关链接,最大深度可达10层 - **资料收集**: 自动收集、去重、分类网页内容 - **报告生成**: 生成专业的深度研究报告,支持多文件输出 - **实时监控**: Web界面实时查看探索进度和状态 - **灵活配置**: 可调整最大页面数、探索深度等参数 ## 系统架构 ``` ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ 前端 (React) │────▶│ 后端 (FastAPI) │────▶│ ExplorerAgent │ │ 控制面板 │ │ WebSocket API │ │ 核心探索引擎 │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │ ┌──────────────────────────┼──────────┐ ▼ ▼ ▼ ┌─────────┐ ┌──────────┐ ┌──────────┐ │ 浏览器工具 │ │ AI分析模块 │ │ 报告生成器 │ └─────────┘ └──────────┘ └──────────┘ ``` ## 快速开始 ### 环境要求 - Python 3.8+ - Node.js 18+ - npm 或 yarn ### 安装步骤 1. **克隆仓库** ```bash cd /mnt/okcomputer/output/app ``` 2. **安装Python依赖** ```bash pip install -r requirements.txt ``` 3. **安装Node依赖** ```bash npm install ``` 4. **启动服务** 使用启动脚本: ```bash bash start.sh ``` 或手动启动: ```bash # 终端1:启动后端 python server.py # 终端2:启动前端 npm run dev ``` 5. **访问应用** 打开浏览器访问: `http://localhost:5173` ## 流程编排系统快速开始 ### 运行示例 ```bash # 运行流程编排示例 python orchestration_example.py ``` ### 使用Master Agent进行深度调研 ```python import asyncio from orchestration import * async def main(): # 创建Master Agent master = MasterAgent() # 注册子Agent master.register_agent(PlannerAgent()) master.register_agent(ResearcherAgent("researcher")) master.register_agent(AnalyzerAgent()) # 定义研究目标 goal = ResearchGoal( topic="人工智能在医疗领域的应用", depth=3, breadth=10, max_pages=100 ) # 执行研究 result = await master.start_research(goal) print(f"访问页面: {result['stats']['pages_visited']}") print(f"收集数据: {result['stats']['data_collected']}") asyncio.run(main()) ``` ### 自定义工作流 ```python from orchestration import * # 创建工作流 builder = WorkflowBuilder() builder.start("start") builder.task("collect", collect_data, retry_policy=RetryPolicy(max_retries=3)) builder.task("analyze", analyze_data) builder.end("end") # 执行 workflow = builder.build() result = await workflow.run() ``` ## 使用指南 ### 1. 配置探索任务 - 在控制面板输入研究主题 - 设置最大页面数(10-1000) - 设置最大探索深度(1-10) ### 2. 开始探索 点击"开始探索"按钮,Agent将: 1. 搜索主题相关网页 2. 分析内容相关性 3. 提取有价值的链接 4. 递归深入探索 5. 收集整理资料 ### 3. 监控进度 - 实时查看访问页面数、收集数据数 - 查看运行日志 - 监控当前探索深度 ### 4. 生成报告 探索完成后: 1. 切换到"生成报告"标签 2. 点击"生成深度报告" 3. 查看生成的Markdown文件 ## 项目结构 ``` app/ ├── agent/ # Agent核心模块 │ ├── __init__.py │ ├── core.py # 核心引擎(简化完整版) │ ├── explorer.py # 完整探索Agent │ ├── report_generator.py # 报告生成器 │ └── tools/ # 工具模块 │ ├── __init__.py │ ├── llm.py # AI分析工具 │ ├── web_search.py # 搜索工具 │ └── browser.py # 浏览器工具 ├── orchestration/ # ⭐ 流程编排模块(新增) │ ├── __init__.py │ ├── workflow_engine.py # 工作流引擎 │ ├── master_agent.py # 主控Agent │ ├── planner_agent.py # 规划Agent │ ├── researcher_agent.py # 研究Agent │ ├── analyzer_agent.py # 分析Agent │ ├── exception_handler.py # 异常处理器 │ └── deep_research_strategy.py # 深度调研策略 ├── src/ # 前端源码 │ ├── App.tsx # 主组件 │ ├── App.css # 样式 │ └── ... ├── server.py # FastAPI后端 ├── demo_server.py # 演示后端 ├── requirements.txt # Python依赖 ├── package.json # Node依赖 ├── start.sh # 启动脚本 ├── orchestration_example.py # 流程编排示例 ├── ORCHESTRATION_DESIGN.md # 流程编排设计文档 └── README.md # 说明文档 ``` ## 核心组件 ### ExplorerAgent 核心探索Agent,负责: - 初始化探索任务 - 管理URL队列 - 访问网页并提取内容 - 分析内容相关性 - 评估链接价值 - 收集整理数据 ### ReportGenerator 报告生成器,负责: - 数据预处理(去重、筛选) - 内容智能分类 - 生成执行摘要 - 提取关键发现 - 输出Markdown报告 ### AI分析模块 基于LLM的分析工具: - `analyze_content_relevance`: 分析内容相关性 - `batch_evaluate_links`: 批量评估链接 - `categorize_content`: 内容分类 - `remove_duplicates`: 智能去重 ## 配置选项 | 参数 | 说明 | 默认值 | 范围 | |------|------|--------|------| | topic | 研究主题 | - | 任意字符串 | | max_pages | 最大页面数 | 100 | 10-1000 | | max_depth | 最大探索深度 | 3 | 1-10 | ## 报告输出 生成的报告包括: 1. **主报告** (`{topic}_主报告.md`) - 执行摘要 - 研究概述 - 主要发现 - 内容分类概览 - 详细分析 - 结论与建议 2. **分类报告** (`{topic}_{分类名}.md`) - 各类别详细内容 - 完整引用信息 3. **参考资料** (`{topic}_参考资料.md`) - 所有引用来源列表 - URL和相关度评分 ## 技术栈 - **前端**: React + TypeScript + Tailwind CSS + shadcn/ui - **后端**: FastAPI + WebSocket - **AI分析**: LLM (GPT/Claude等) - **浏览器**: Playwright/Selenium (可扩展) ## 扩展开发 ### 添加新的分析工具 在 `agent/tools/` 目录下创建新模块: ```python # agent/tools/my_tool.py async def my_analysis(data: str) -> dict: # 实现分析逻辑 return result ``` ### 自定义报告模板 修改 `agent/report_generator.py` 中的报告生成方法: ```python async def _generate_custom_report(self, data): # 自定义报告逻辑 pass ``` ## 注意事项 1. **网络访问**: 确保服务器能够访问互联网 2. **API限制**: 注意搜索API和LLM API的调用限制 3. **存储空间**: 大量页面收集会占用存储空间 4. **运行时间**: 深度探索可能需要较长时间 ## 许可证 MIT License ## 贡献 欢迎提交Issue和Pull Request!