Files
auto_agent/README.md
T

88 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Agent Web Chat
基于 LangGraph 的多模态对话 Agent,支持文本、图片、音频、多种类型文件输入,具备屏幕截图、浏览器控制、RAG 知识库、数据库查询、本地文件获取等工具调用能力。
## 快速开始
### 1. 克隆仓库并进入项目目录
```bash
git clone <your-repo-url>
cd Agent
Windows:
bash
python -m venv myenv
.\myenv\Scripts\activate
macOS / Linux:
bash
python -m venv myenv
source myenv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
gedit .env
必须填写的变量:
LLM_BASE_URL – 大模型 API 基础地址
LLM_API_KEY – API 密钥
LLM_MODEL – 模型名称(如 Qwen/Qwen2.5-72B-Instruct)
TTS_BASE_URL – 文本转语音服务地址(可选,若不使用音频回复可不填)
ASR_BASE_URL – 语音识别服务地址(可选)
RAG_BASE_URL – RAG 嵌入与重排序服务地址(可选)
# 启动 Web 对话服务(推荐)
# 确保在 Agent 目录下,且 PYTHONPATH 包含 src 目录
cd ./Agent
export PYTHONPATH=src:$PYTHONPATH # Linux/macOS
# 或 Windows PowerShell: $env:PYTHONPATH="src;$env:PYTHONPATH"
uvicorn web.server:app --host 0.0.0.0 --port 8765
# (可选)通过 Cloudflare Tunnel 暴露公网
cloudflared tunnel --url http://localhost:8765
# 进入项目目录并提交代码(Windows 下路径为 .\Agent\)
✅ 推送到公司
powershell
# 进入项目目录
cd Agent
# 暂存所有修改
git add .
# 提交修改(请替换双引号里的内容为实际说明)
git commit -m "修改内容的说明"
# 默认推送到公司
git push
🌐 推送到个人 GitHub
powershell
# 进入项目目录
cd Agent
# 暂存所有修改
git add .
# 提交修改(请替换双引号里的内容为实际说明)
git commit -m "修改内容的说明"
# 显式指定推送到个人仓库 (minor)
git push minor master
###循环检测
用户输入 → runtime.py 重置循环状态
→ graph.invoke 开始执行
│
├─ agent 节点 (nodes.py / call_model)
│ ├─ _build_reflection_prompt()
│ │ ├─ check_and_record_todolist_progress() ← todolist 停滞检测
│ │ │ └─ 10轮无进展 → 注入反思提示:"请反思当前卡点..."
│ │ │
│ │ └─ build_loop_reflection_prompt()
│ │ └─ detect_repeated_tool_calls() ← 连续相同工具检测
│ │ └─ 连续3次 → 注入反思提示:"你已连续多次调用同一工具..."
│ │
│ └─ LLM 调用(带反思提示引导)
│
├─ routing 节点 (routing.py / should_continue)
│ └─ should_force_end()
│ └─ 连续5次相同工具+相同参数 → 返回 END,强制终止
│
└─ 图结束后 (runtime.py / execute_agent)
└─ 检测到强制终止 → 向前端输出:
"检测到异常循环,工具 `xxx` 已连续调用 5 次..."