# Agent-project **Repository Path**: AimerUna/agent-project ## Basic Information - **Project Name**: Agent-project - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-23 - **Last Updated**: 2026-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Based on the code map provided, I can see this is an AI Agent project that appears to be a smart home/robot report system. Let me create a comprehensive README.md based on the project structure. # Agent Project 智能扫地机器人报告生成 Agent ## 项目简介 本项目是一个基于大语言模型(LLM)的智能 Agent 系统,主要用于为用户提供扫地/扫拖机器人的使用报告生成服务。系统集成了 RAG(检索增强生成)、向量数据库、工具调用等功能,能够根据用户查询和外部数据生成个性化的使用报告。 ## 技术栈 - **Python 3.x** - **LangChain** - LLM 框架 - **Chroma** - 向量数据库 - **ReAct Agent** - 推理 Agent 架构 ## 项目结构 ``` agent-project/ ├── agent/ # Agent 核心模块 │ ├── chroma_db/ # Chroma 向量数据库 │ ├── react_agent.py # ReAct Agent 实现 │ └── tools/ # 工具函数 │ ├── agent_tools.py # 业务工具(天气、用户信息、外部数据等) │ └── middleware.py # 中间件(日志、动态提示词切换) ├── config/ # 配置文件 │ ├── agent.yml # Agent 配置 │ ├── chroma.yml # Chroma 配置 │ ├── prompts.yml # 提示词配置 │ └── rag.yml # RAG 配置 ├── data/ # 数据文件 │ └── external/ # 外部数据(用户使用记录) ├── logs/ # 日志文件 ├── model/ # 模型工厂 │ └── factory.py # ChatModel 和 Embeddings 工厂 ├── prompts/ # 提示词模板 │ ├── main_prompt.txt # 主提示词 │ ├── rag_summarize.txt # RAG 总结提示词 │ └── report_prompt.txt # 报告生成提示词 ├── rag/ # RAG 服务 │ ├── rag_service.py # RAG 检索服务 │ └── vector_store.py # 向量存储服务 ├── utils/ # 工具模块 │ ├── config_handler.py # 配置加载 │ ├── file_handler.py # 文件处理(CSV、PDF、TXT) │ ├── logger_handler.py # 日志处理(敏感数据脱敏) │ ├── path_tool.py # 路径工具 │ └── prompt_loader.py # 提示词加载 └── app.py # 应用入口 ``` ## 核心功能 ### 1. ReAct Agent `ReactAgent` 类实现了基于 ReAct 推理模式的 Agent,支持流式输出(`execute_stream` 方法)。 ### 2. 工具函数 系统提供多种工具供 Agent 调用: | 工具名称 | 功能描述 | |---------|---------| | `rag_summarize` | 从向量存储中检索参考资料 | | `get_weather` | 获取指定城市天气 | | `get_user_location` | 获取用户所在城市 | | `get_user_id` | 获取用户 ID | | `get_current_month` | 获取当前月份 | | `fetch_external_data` | 检索指定用户指定月份的使用记录 | | `fill_context_for_report` | 触发中间件为报告生成场景动态注入上下文 | ### 3. RAG 服务 - **向量存储**:基于 Chroma 的向量数据库存储文档 - **检索服务**:支持相似度检索和文档总结 ### 4. 中间件 - **日志脱敏**:自动过滤日志中的敏感信息 - **动态提示词切换**:根据场景动态调整提示词 ### 5. 配置管理 支持 YAML 格式的配置文件加载,包括: - Agent 配置 - 向量数据库配置 - 提示词配置 - RAG 配置 ## 安装依赖 ```bash pip install langchain chromadb langchain-openai pyyaml ``` ## 配置说明 ### config/agent.yml Agent 相关配置。 ### config/chroma.yml Chroma 向量数据库配置。 ### config/prompts.yml 提示词相关配置。 ### config/rag.yml RAG 检索配置。 ## 使用示例 ```python from agent.react_agent import ReactAgent # 初始化 Agent agent = ReactAgent() # 执行查询 result = agent.execute_stream("请帮我生成上个月的使用报告") ``` ## 日志说明 日志文件位于 `logs/` 目录下,系统会自动对日志中的敏感数据进行脱敏处理,确保用户隐私安全。 ## 外部数据 用户的使用记录存储在 `data/external/records.csv` 中,可通过 `fetch_external_data` 工具进行查询。 ## License 本项目仅供学习交流使用。