Skip to content

wustwyh/wyh_agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Agent 项目

基于智谱 AI 平台的 LLM Agent 框架。

项目结构

ai_agent/
├── README.md                 # 项目说明
├── .env                     # 环境配置文件(不提交)
├── .env.example             # 环境配置示例
├── requirements.txt          # 依赖包
├── main.py                  # 主程序入口
├── config/
│   ├── __init__.py
│   └── settings.py          # 配置管理
├── src/
│   ├── __init__.py
│   ├── llm_client.py        # LLM 客户端
│   ├── agent.py             # Agent 核心类
│   ├── tools.py             # 工具系统
│   ├── memory.py            # 记忆系统
│   └── utils.py            # 工具函数
├── tools/
│   ├── __init__.py
│   ├── calculator.py        # 计算工具
│   ├── web_search.py        # 网络搜索
│   ├── file_ops.py          # 文件操作
│   └── code_executor.py     # 代码执行
└── prompts/
    ├── __init__.py
    ├── agent_prompt.txt     # Agent 系统提示
    ├── tool_use_prompt.txt  # 工具使用提示
    └── task_planning.txt   # 任务规划提示

功能特性

  • LLM 模型调用(智谱 AI)
  • Agent 思考循环
  • 工具调用系统
  • 记忆管理
  • 任务分解和执行
  • 错误处理和重试

快速开始

  1. 安装依赖:
pip install -r requirements.txt
  1. 配置 API Key:
cp .env.example .env
# 编辑 .env 文件,填入你的智谱 API Key
  1. 运行 Agent:
python main.py

配置说明

.env 文件中配置:

  • ZHIPU_API_KEY: 智谱 AI API 密钥
  • MODEL_NAME: 模型名称(默认:glm-4)
  • MAX_STEPS: 最大步骤数
  • VERBOSE: 详细输出

Agent 循环

1. 接收用户目标
2. 思考当前状态和下一步行动
3. 决定是否需要调用工具
4. 如果需要,调用工具并获取结果
5. 将结果加入上下文
6. 检查任务是否完成
7. 未完成则继续循环
8. 完成则返回结果

About

This is a agent building practice

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages