# my_first_agent **Repository Path**: YunAbove/my_first_agent ## Basic Information - **Project Name**: my_first_agent - **Description**: 年轻人的第一个ai agent - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-02 - **Last Updated**: 2026-07-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🤖 My First Agent 一个基于 **ReAct 模式**(Reasoning + Acting)的 AI 智能体,支持工具调用、长期记忆和自然语言交互。 ## ✨ 功能 - 🕐 **获取时间** — 当前日期和时间 - 🔢 **数学计算** — 安全高效的表达式计算(支持三角函数等) - 🌤️ **查询天气** — 指定城市的实时天气 - 🌐 **网络搜索** — 实时信息搜索 - 💾 **长期记忆** — 基于向量数据库的跨对话记忆 ## 🏗️ 项目结构 ``` ├── main.py # 🎯 入口:用户交互终端 ├── agent.py # 🧠 核心:Agent 循环 + API 重试 ├── config.py # ⚙️ 配置:环境变量 + 模型 + 系统提示词 ├── memory.py # 💾 记忆系统(ChromaDB) ├── tools/ # 🔧 工具包 │ ├── __init__.py # 工具注册 │ ├── get_current_time.py │ ├── calculate.py │ ├── search_web.py │ └── get_weather.py └── chroma_data/ # 📁 向量数据库持久化 ``` ## 🚀 快速开始 ### 1. 安装依赖 ```bash pip install openai python-dotenv requests chromadb sentence-transformers numexpr ``` ### 2. 配置环境变量 设置系统环境变量(或使用 `.env` 文件): ```bash DEEPSEEK_API_KEY=sk-xxx DEEPSEEK_BASE_URL=https://api.deepseek.com/v1 JUHE_WEATHER_API_KEY=你的天气API密钥 ``` ### 3. 运行 ```bash python main.py ``` ## 💬 使用示例 ``` 你:深圳今天天气怎么样? 你:123 * 456 等于多少? 你:最近有什么新闻? 你:我之前问过什么? ``` ## ⌨️ 交互命令 | 命令 | 作用 | |---|---| | `exit` / `quit` / `q` | 退出程序 | | `reset` | 重置当前对话 | | `clear_memory` | 清空长期记忆 | ## 📚 学习笔记 - [第一课:从零构建你的Agent](https://gitee.com/hankaizhou/my_first_agent/blob/main) - [第二课:模块化重构与安全加固](https://gitee.com/hankaizhou/my_first_agent/blob/main) ## 🛠️ 技术栈 - Python 3.14 - OpenAI SDK(兼容 DeepSeek API) - ChromaDB(向量数据库) - Sentence-Transformers(文本嵌入) - numexpr(安全数学计算)