Skip to content

peterpark236/multi-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗 Tesla Sales Agent Simulation (特斯拉销售 AI 模拟系统)

Python FastAPI Vue LangGraph License

基于 LangGraph 的双 Agent 销售对话模拟系统

English | 中文


📖 项目简介

这是一个基于 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+

📦 安装与配置

1. 克隆项目

git clone https://github.com/peterpark236/multi-agent.git
cd multi-agent

2. 后端配置

# 进入后端目录
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 服务。此配置项直接使用阿里云的百炼服务。

3. 前端配置

# 进入前端目录
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


🎮 使用指南

基础操作

  1. 自动播放:点击右上角"自动播放"按钮,系统每 3.5 秒自动执行一轮对话
  2. 手动对话:点击底部"下一轮对话"按钮,逐步控制对话进程
  3. 时间跳跃:点击"跳过3天"按钮,触发记忆总结功能
  4. 查看思维链:点击消息上方的"查看思维链"查看 Agent 内心活动
  5. 重置对话:点击左上角刷新图标重新开始

界面布局

  • 左侧栏: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              # 本文档

🔧 核心功能说明

记忆管理机制

系统采用三层记忆架构:

  1. 即时记忆:最近 6 条消息的完整细节(滑动窗口)
  2. 长期记忆:通过 LLM 总结的对话摘要(智能压缩)
  3. 状态持久化:基于 LangGraph 的 MemorySaver,通过 thread_id 隔离会话

详细说明请查看:记忆管理机制文档

API 端点

端点 方法 功能
/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 - 图标库

📊 系统特色

1. 双 Agent 对话流

graph LR
    A[Sales Agent] -->|推销话术| B[Customer Agent]
    B -->|提出疑虑| A
    A -->|解答/引导| B
    B -->|购买意向变化| A
Loading

2. 智能记忆压缩

对话历史 (100+ 消息)
    ↓ [时间跳跃]
LLM 总结 (150 字摘要)
    ↓
注入到下次对话的 System Prompt

3. 实时状态追踪

  • Sales Agent: 策略分析、情绪管理
  • Customer Agent: 购买意向评分、预算状态

🤝 贡献指南

欢迎提交 Issue 和 Pull Request!

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

📄 许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件


📮 联系方式


🙏 致谢


⭐ 如果这个项目对你有帮助,请给一个 Star!

Made with ❤️ by [Your Name]


📖 Project Overview (English)

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.

🚀 Quick Start (English)

Prerequisites

Python 3.10+, Node.js 16+, npm 8+

Installation

# 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

Run

# 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

🛠️ Tech Stack

  • Backend: FastAPI, LangGraph, LangChain
  • Frontend: Vue 3, Pinia, TailwindCSS
  • LLM: Compatible with OpenAI API format

About

这是一个基于 **LangGraph** 和 **大语言模型(LLM)** 的智能销售对话模拟系统。系统模拟了特斯拉销售顾问与潜在客户之间的真实对话场景,通过双 Agent 架构实现自动化的销售话术训练和客户心理分析。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors