# agent **Repository Path**: arieszhao/agent ## Basic Information - **Project Name**: agent - **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-11-02 - **Last Updated**: 2025-11-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 智能工具调用智能体系统 这是一个高度智能的工具调用智能体系统,包含规划Agent、执行Agent、总结Agent和一个工具库,支持多轮会话和上下文管理,以及多用户多主题对话。 ## 项目结构 ``` AgentNew/ ├── agent/ # 后端项目(Spring Boot + WebFlux + Spring AI) ├── web/ # 前端项目(Vue + Arco Design) └── doc/ # 文档 ``` ## 技术栈 ### 后端 - Spring Boot 3.2.0 - Spring WebFlux(响应式编程) - Spring AI(连接 Ollama) - Ollama(本地大模型:qwen2.5:4b) ### 前端 - Vue 3 - Arco Design Vue - Vite - Axios ## 快速开始 ### 前置要求 1. Java 17+ 2. Maven 3.6+ 3. Node.js 18+ 4. Ollama(需要先安装并启动,模型:qwen2.5:4b) ### 启动 Ollama ```bash # 确保 Ollama 已安装 ollama serve # 下载模型(如果还没有) ollama pull qwen2.5:4b ``` ### 启动后端 ```bash cd agent mvn clean install mvn spring-boot:run ``` 后端服务将在 http://localhost:8080 启动 ### 启动前端 ```bash cd web npm install npm run dev ``` 前端服务将在 http://localhost:3000 启动 ## 功能特性 ### 后端功能 - ✅ 交互路由:自动判断输入类型(简单指令/复杂任务) - ✅ 规划Agent:将复杂任务拆解为多个子任务 - ✅ 执行Agent:执行子任务,支持重试和参数调整 - ✅ 总结Agent:生成执行总结 - ✅ 工具库:可扩展的工具系统 - ✅ 会话管理:多用户多主题对话支持 - ✅ SSE流式输出:实时推送思考过程和任务状态 ### 前端功能 - ✅ 会话列表:管理多个对话会话 - ✅ 聊天窗口:实时显示消息和思考过程 - ✅ 任务展示:显示任务执行状态和子任务进度 - ✅ SSE事件日志:悬浮窗口显示所有SSE事件 ## API 文档 ### 创建会话 ``` POST /api/chat/conversations Body: { "userId": "user1", "topic": "新会话" } ``` ### 发送消息 ``` POST /api/chat/message Body: { "conversationId": "...", "userId": "user1", "userInput": "..." } ``` ### SSE事件流 ``` GET /api/chat/events/{conversationId} ``` ### 获取会话列表 ``` GET /api/chat/conversations/{userId} ``` ## 开发说明 ### 添加新工具 在 `agent/src/main/java/com/agent/tool/impl/BasicTools.java` 中添加新工具: ```java toolRegistry.register(Tool.builder() .id("your_tool_id") .name("工具名称") .description("工具描述") .parameters(...) .executor(new YourToolExecutor()) .build()); ``` ### SSE事件类型 - `THINKING`: 思考过程 - `TASK_STATUS`: 任务状态更新 - `PLAN_RESULT`: 规划结果 - `EXECUTION_RESULT`: 执行结果 - `TOOL_CALL`: 工具调用 - `SUMMARY_RESULT`: 总结结果 - `ERROR`: 错误信息 - `FINAL_RESPONSE`: 最终响应 ## 注意事项 1. 确保 Ollama 服务运行在 http://localhost:11434 2. 模型名称需要与 Ollama 中的模型名称一致 3. 前端代理配置在 `web/vite.config.js` 中 4. 所有数据目前存储在内存中,重启后会丢失 ## 后续扩展 - [ ] 支持专项任务的规划Agent - [ ] 添加更多工具 - [ ] 持久化存储(数据库) - [ ] 用户认证和授权 - [ ] 更完善的错误处理 - [ ] 更智能的参数调整策略