Files
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

64 lines
1.5 KiB
Markdown
Raw Permalink 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.
# AI 客服系统 (LangChain + LangGraph)
极简版 AI 客服系统,基于 LangChain 和 LangGraph 构建。
## 功能特性
- 🤖 基于 RAG 的知识库问答
- 💬 多轮对话支持(带记忆)
- 📚 PDF/TXT 文档自动导入
- 🌐 Web 聊天界面
- 🔧 工具调用(可扩展查订单等功能)
## 项目结构
```
ai-chatbot-service/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI 主服务
│ ├── chatbot.py # LangGraph 客服逻辑
│ ├── knowledge.py # 知识库管理
│ └── config.py # 配置
├── static/
│ └── chat.js # 前端聊天逻辑
├── templates/
│ └── index.html # 聊天界面
├── knowledge_base/ # 知识库文档
├── data/ # 数据库文件
├── requirements.txt
└── README.md
```
## 快速开始
### 1. 安装依赖
```bash
pip install -r requirements.txt
```
### 2. 配置 API Key
编辑 `app/config.py`,设置你的 DeepSeek API Key。
### 3. 准备知识库
将 FAQ 文档放入 `knowledge_base/` 目录(支持 .txt, .pdf, .md)
### 4. 初始化知识库
```bash
cd app
python -c "from knowledge import init_knowledge_base; init_knowledge_base()"
```
### 5. 启动服务
```bash
python app/main.py
```
访问 http://localhost:8890 开始聊天!
## API 接口
- `POST /chat` - 发送消息
- `GET /history/{session_id}` - 获取对话历史
- `POST /upload` - 上传知识库文档