这是一个基于 LangGraph 和 大语言模型(LLM) 的智能销售对话模拟系统。系统模拟了特斯拉销售顾问与潜在客户之间的真实对话场景,通过双 Agent 架构实现自动化的销售话术训练和客户心理分析。
- 🤖 双 Agent 架构:独立的销售顾问 AI 和客户 AI,真实模拟销售场景
- 🧠 双轨记忆系统 (RAG + Reranker):宏观摘要 + ChromaDB 向量微观检索解决长对话失忆问题
- 💬 思维链可视化:实时展示 Agent 的内心思考过程和销售策略
- ⏭️ 时间跳跃功能:模拟间隔对话场景,验证长期记忆能力
- 🎯 动态状态追踪:实时显示客户购买意向、预算状态等关键指标
- 🎨 现代化 UI:基于 Vue 3 + TailwindCSS 的流畅交互界面
┌─────────────────────────────────────────────────────────┐
│ Frontend (Vue 3) │
│ ┌──────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Sales │ │ Chat Stream │ │ Customer │ │
│ │ Status │ │ (Messages) │ │ Status │ │
│ └──────────┘ └──────────────┘ └──────────────┘ │
└────────────────────┬────────────────────────────────────┘
│ HTTP API (Axios)
┌────────────────────▼────────────────────────────────────┐
│ Backend (FastAPI + LangGraph) │
│ ┌──────────────────────────────────────────────────┐ │
│ │ LangGraph State Machine │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │ │
│ │ │ Sales │◄─┤ Memory ├─►│ Customer │ │ │
│ │ │ Agent │ │ Saver │ │ Agent │ │ │
│ │ └────┬─────┘ └──────────┘ └──────┬───────┘ │ │
│ │ │ RAG + Reranker 检索 │ │ │
│ │ ▼ ▼ │ │
│ │ ┌──────────────────────────────────────────┐ │ │
│ │ │ ChromaDB 向量库 │ │ │
│ │ └──────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────┘ │
└────────────────────┬────────────────────────────────────┘
│
┌──────▼───────┐
│ LLM & API │
│ (Qwen/Rerank)│
└──────────────┘
- Python: 3.10+
- Node.js: 16+
- npm: 8+
git clone https://github.com/peterpark236/multi-agent.git
cd multi-agent# 进入后端目录
cd backend
# 安装 Python 依赖
pip install -r requirements.txt
# 配置环境变量
# 创建 .env 文件并添加以下内容:.env 文件内容:
API_KEY=your-api-key-here
BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
MODEL=qwen3-max-2026-01-23
# RAG: 嵌入模型和 Reranker API,也共用上方 API_KEY
EMBEDDING_MODEL=text-embedding-v3
RERANKER_MODEL=gte-rerank💡 提示:支持任何兼容 OpenAI API 格式的 LLM 服务。此配置项直接使用阿里云的百炼服务。
# 进入前端目录
cd ../frontend
# 安装依赖
npm install方式一:分别启动(推荐开发)
# 终端 1:启动后端
cd backend
python main.py
# 后端运行在 http://localhost:8019
# 终端 2:启动前端
cd frontend
npm run dev
# 前端运行在 http://localhost:5173方式二:一键启动(需配置脚本)
# Windows
start.bat
# Linux/Mac
./start.sh打开浏览器访问:http://localhost:5173
- 自动播放:点击右上角"自动播放"按钮,系统每 3.5 秒自动执行一轮对话
- 手动对话:点击底部"下一轮对话"按钮,逐步控制对话进程
- 时间跳跃:点击"跳过3天"按钮,触发记忆总结功能
- 查看思维链:点击消息上方的"查看思维链"查看 Agent 内心活动
- 重置对话:点击左上角刷新图标重新开始
- 左侧栏:Sales Agent 的心理活动和销售策略
- 中间区域:对话消息流
- 右侧栏:Customer 的购买意向进度和预算状态
multi-agent/
├── backend/ # 后端服务
│ ├── main.py # FastAPI 入口
│ ├── graph.py # LangGraph 状态机定义
│ ├── .env # 环境变量配置
│ └── requirements.txt # Python 依赖
│
├── frontend/ # 前端应用
│ ├── src/
│ │ ├── App.vue # 主组件
│ │ ├── store/
│ │ │ └── chat.ts # Pinia 状态管理 + API
│ │ └── main.ts # 入口文件
│ ├── package.json # Node 依赖
│ └── vite.config.ts # Vite 配置
│
├── prompt.md # Prompt 设计说明
└── README.md # 本文档
系统采用三层记忆架构:
- 即时记忆:最近 6 条消息的完整细节(滑动窗口)
- 长期记忆:通过 LLM 总结的对话摘要(智能压缩)
- 状态持久化:基于 LangGraph 的
MemorySaver,通过thread_id隔离会话
详细说明请查看:记忆管理机制文档
| 端点 | 方法 | 功能 |
|---|---|---|
/chat/start |
POST | 创建新对话,返回 thread_id |
/chat/next_step |
POST | 执行下一轮对话 |
/chat/time_jump |
POST | 触发时间跳跃,生成摘要 |
- FastAPI - 现代高性能 Web 框架
- LangGraph - State Machine 引擎
- LangChain - LLM 应用框架
- ChromaDB - 向量数据库 (RAG 核心)
- DashScope - 阿里云 AI 接口工具 (Embedding & Reranker)
- Python-dotenv - 环境变量管理
- Vue 3 - 渐进式 JavaScript 框架
- Pinia - Vue 状态管理
- Axios - HTTP 客户端
- TailwindCSS - 原子化 CSS 框架
- Lucide Icons - 图标库
graph LR
A[Sales Agent] -->|推销话术| B[Customer Agent]
B -->|提出疑虑| A
A -->|解答/引导| B
B -->|购买意向变化| A
对话历史 (100+ 消息)
↓ [时间跳跃]
LLM 总结 (150 字摘要)
↓
注入到下次对话的 System Prompt
- Sales Agent: 策略分析、情绪管理
- Customer Agent: 购买意向评分、预算状态
欢迎提交 Issue 和 Pull Request!
- Fork 本仓库
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
本项目采用 MIT 许可证 - 详见 LICENSE 文件
- Issues: GitHub Issues
- Email: your.email@example.com
⭐ 如果这个项目对你有帮助,请给一个 Star!
Made with ❤️ by [Your Name]
A dual-agent sales conversation simulation system powered by LangGraph and Large Language Models (LLMs). This project simulates realistic conversations between a Tesla sales consultant and potential customers for sales training and customer psychology analysis.
Python 3.10+, Node.js 16+, npm 8+# Clone repository
git clone https://github.com/peterpark236/multi-agent.git
cd multi-agent
# Backend setup
cd backend
pip install -r requirements.txt
# Create .env file with your API credentials
# Frontend setup
cd ../frontend
npm install# Terminal 1: Backend
cd backend
python main.py
# Runs on http://localhost:8019
# Terminal 2: Frontend
cd frontend
npm run dev
# Runs on http://localhost:5173- Backend: FastAPI, LangGraph, LangChain
- Frontend: Vue 3, Pinia, TailwindCSS
- LLM: Compatible with OpenAI API format