# agents **Repository Path**: isyangwei/agents ## Basic Information - **Project Name**: agents - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-29 - **Last Updated**: 2025-07-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 智能体系统 (Multi-Agent System) 基于LangGraph框架构建的多智能体协作系统,包含产品经理、架构师、后端开发、前端开发、测试等多个角色的智能体。 ## 系统架构 ``` agents/ ├── config.py # 配置文件 ├── base_agent.py # 基础Agent类和LLM集成 ├── agents.py # 各角色Agent实现 ├── mcp_tools.py # MCP工具集成 ├── graph.py # LangGraph工作流 ├── main.py # 主程序入口 ├── requirements.txt # 依赖包 └── README.md # 说明文档 ``` ## 核心组件 ### 1. 基础组件 - **BaseLLM**: 封装DeepSeek模型调用 - **BaseAgent**: 智能体基类,提供通用功能 - **Config**: 系统配置管理 ### 2. 智能体角色 - **ProductManagerAgent**: 产品经理,负责需求分析和产品规划 - **ArchitectAgent**: 架构师,负责系统设计和技术选型 - **BackendDeveloperAgent**: 后端开发,负责服务端开发 - **FrontendDeveloperAgent**: 前端开发,负责用户界面开发 - **QAEngineerAgent**: 测试工程师,负责质量保证 ### 3. 工具系统 - **MCPTool**: 工具基类 - **FileReaderTool**: 文件读取 - **FileWriterTool**: 文件写入 - **WebSearchTool**: 网络搜索 - **DatabaseTool**: 数据库操作 ### 4. 工作流引擎 - **MultiAgentSystem**: 基于LangGraph的多智能体协作系统 - **AgentState**: 状态管理 - **工作流**: 产品经理 → 架构师 → 后端开发 → 前端开发 → 测试 → 协调器 ## 安装和使用 ### 1. 安装依赖 ```bash pip install -r requirements.txt ``` ### 2. 配置API密钥 在 `config.py` 中设置DeepSeek API密钥,或通过环境变量: ```bash export DEEPSEEK_API_KEY="your-api-key" ``` ### 3. 运行系统 ```bash python main.py ``` ## 使用方式 ### 1. 单个Agent测试 ```python from agents import ProductManagerAgent agent = ProductManagerAgent() result = agent.process("设计一个在线教育平台") print(result) ``` ### 2. 多Agent协作 ```python from graph import MultiAgentSystem system = MultiAgentSystem() result = system.run("开发用户管理系统") print(result["result"]) ``` ### 3. 工具使用 ```python agent = ProductManagerAgent() # 文件操作 result = agent.use_tool("file_writer", file_path="output.txt", content="内容") # 网络搜索 result = agent.use_tool("web_search", query="Python最佳实践") ``` ## 交互模式 运行 `main.py` 后会进入交互模式,支持: 1. 单个Agent对话 2. 多Agent协作处理 3. 实时任务分配 ## 扩展开发 ### 1. 添加新的Agent角色 ```python from base_agent import BaseAgent class NewRoleAgent(BaseAgent): def __init__(self): super().__init__("角色名", "Role", "描述") def get_system_prompt(self) -> str: return "你的系统提示词..." ``` ### 2. 添加新的工具 ```python from mcp_tools import MCPTool class CustomTool(MCPTool): def __init__(self): super().__init__("tool_name", "工具描述") def execute(self, **kwargs): # 实现工具逻辑 pass def get_schema(self): # 返回参数schema pass ``` ### 3. 自定义工作流 修改 `graph.py` 中的 `_build_graph` 方法来定义新的协作流程。 ## 特性 - ✅ 基于LangGraph的状态管理 - ✅ 多智能体协作工作流 - ✅ MCP工具集成 - ✅ DeepSeek模型集成 - ✅ 可扩展的Agent角色 - ✅ 交互式使用界面 - ✅ 完整的测试用例 ## 注意事项 1. 确保API密钥配置正确 2. 工具调用需要相应的权限 3. 大型任务可能需要较长处理时间 4. 建议在测试环境中验证工作流程