docs: 添加README和.gitignore
This commit is contained in:
34
.gitignore
vendored
Normal file
34
.gitignore
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
*.egg-info/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Database
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Config (if contains secrets)
|
||||||
|
config.local.*
|
||||||
|
*.secret
|
||||||
94
README.md
Normal file
94
README.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# AI 对话系统
|
||||||
|
|
||||||
|
支持网页端和Matrix端实时同步对话的AI聊天系统。
|
||||||
|
|
||||||
|
## 功能特性
|
||||||
|
|
||||||
|
- **网页端对话**: 通过浏览器与AI进行对话
|
||||||
|
- **Matrix端对话**: 配置Matrix Bot,用户可通过Matrix与AI对话
|
||||||
|
- **实时同步**: 同一用户在网页端和Matrix端的对话自动同步
|
||||||
|
- **后台管理**: 用户管理、对话记录、系统配置
|
||||||
|
|
||||||
|
## 系统架构
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ AI 对话系统 │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ 网页端 (用户A) ←──┐ ┌──→ Matrix端 │
|
||||||
|
│ │ 同一会话同步 │ (用户A) │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ 后端服务 (FastAPI + WebSocket) │
|
||||||
|
│ - 会话管理 │
|
||||||
|
│ - 消息存储 │
|
||||||
|
│ - Matrix Bot 集成 │
|
||||||
|
│ - AI 模型调用 │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ 后台管理 │
|
||||||
|
│ - 用户管理 │
|
||||||
|
│ - 对话记录 │
|
||||||
|
│ - 系统配置 │
|
||||||
|
└─────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## 端口分配
|
||||||
|
|
||||||
|
- 19020: 主服务(网页端 + API)
|
||||||
|
- 后台管理: http://localhost:19020/admin
|
||||||
|
|
||||||
|
## 快速启动
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装依赖
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
# 启动服务
|
||||||
|
./start.sh
|
||||||
|
|
||||||
|
# 检查状态
|
||||||
|
./status.sh
|
||||||
|
|
||||||
|
# 停止服务
|
||||||
|
./stop.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 配置Matrix Bot
|
||||||
|
|
||||||
|
在后台管理页面配置以下参数:
|
||||||
|
|
||||||
|
| 配置项 | 说明 |
|
||||||
|
|--------|------|
|
||||||
|
| matrix_homeserver | Matrix服务器地址,如 https://matrix.tphai.com |
|
||||||
|
| matrix_username | Matrix Bot用户名,如 @ai-bot:matrix.org |
|
||||||
|
| matrix_password | Matrix Bot密码 |
|
||||||
|
|
||||||
|
配置完成后,其他Matrix用户可以直接与Bot对话。
|
||||||
|
|
||||||
|
## API接口
|
||||||
|
|
||||||
|
### 会话管理
|
||||||
|
|
||||||
|
- `GET /api/conversations` - 获取会话列表
|
||||||
|
- `POST /api/conversations` - 创建新会话
|
||||||
|
- `GET /api/conversations/{id}/messages` - 获取会话消息
|
||||||
|
- `DELETE /api/conversations/{id}` - 删除会话
|
||||||
|
|
||||||
|
### 后台管理
|
||||||
|
|
||||||
|
- `GET /api/admin/stats` - 获取统计数据
|
||||||
|
- `GET /api/admin/users` - 获取用户列表
|
||||||
|
- `GET /api/admin/conversations` - 获取对话列表
|
||||||
|
- `GET /api/admin/config` - 获取系统配置
|
||||||
|
- `POST /api/admin/config` - 更新系统配置
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
- **后端**: FastAPI + WebSocket
|
||||||
|
- **数据库**: SQLite (SQLAlchemy)
|
||||||
|
- **Matrix**: matrix-nio
|
||||||
|
- **前端**: HTML + JavaScript (原生)
|
||||||
|
- **AI**: 可配置任意LLM API(默认使用本地LLM Proxy)
|
||||||
|
|
||||||
|
## 仓库地址
|
||||||
|
|
||||||
|
http://192.168.2.8:12007/coder/ai-chat-system
|
||||||
Reference in New Issue
Block a user