基于阿里云通义千问 + 向量数据库的智能问答系统接口文档
http://localhost:8000
发送消息并获取AI回复,支持RAG知识库检索增强。
知识库来源:用户私有分析报告 (analysis_sections) - 通过 user_id 关联查询
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| message | string | 必填 | 用户消息内容 |
| session_id | string | 可选 | 会话ID,用于保持上下文 |
| use_rag | boolean | 可选 | 是否启用RAG检索,默认true |
| user_id | string | 必填 | 用户ID (uuid),用于查询用户私有分析报告 |
{
"message": "请介绍一下公司的营销方案",
"session_id": "abc123",
"use_rag": true,
"user_id": "34e3911e-4959-4710-bde2-da59abf743e2"
}{
"response": "根据知识库,公司的营销方案包括...",
"session_id": "abc123"
}流式聊天接口,支持Server-Sent Events (SSE) 实时返回生成内容。
与 /api/chat 相同
data: {"content": "根据"}
data: {"content": "知识库"}
data: {"done": true, "session_id": "abc123"}搜索用户私有分析报告(关键词匹配)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| query | string | 必填 | 搜索查询文本 |
| top_k | integer | 可选 | 返回结果数量,默认5 |
| user_id | string | 必填 | 用户ID (uuid),搜索该用户的私有报告 |
{
"query": "营销策略",
"top_k": 3,
"user_id": "34e3911e-4959-4710-bde2-da59abf743e2"
}[
{
"document": {
"id": 1,
"content": "相关文档内容...",
"metadata": null,
"created_at": "2025-12-12T10:00:00Z"
},
"similarity": 0.89
}
]获取所有问题模板列表,供大模型和前端使用。
{
"templates": [
{
"id": "uuid-xxx",
"question": "请介绍公司的主要业务",
"description": "查询公司业务介绍",
"category": "公司信息",
"order": 0
}
],
"total": 1
}创建新的问题模板(管理员接口)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| question | string | 必填 | 问题模板内容 |
| description | string | 可选 | 模板描述 |
| category | string | 可选 | 分类 |
| order | integer | 可选 | 排序顺序,默认0 |
{
"question": "公司有哪些产品?",
"description": "查询产品列表",
"category": "产品信息",
"order": 1
}修改问题模板(管理员接口)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| question | string | 可选 | 问题模板内容 |
| description | string | 可选 | 模板描述 |
| category | string | 可选 | 分类 |
| order | integer | 可选 | 排序顺序 |
删除问题模板(管理员接口)。
批量设置问题模板,会覆盖所有现有模板(管理员接口)。
[
{"question": "公司有哪些产品?"},
{"question": "如何联系客服?"},
{"question": "退换货政策是什么?"}
]返回聊天界面首页。
Swagger UI 交互式 API 文档,支持在线测试接口。
ReDoc 格式的 API 文档。
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 请求参数错误 |
| 422 | 请求体格式错误 |
| 500 | 服务器内部错误(如API调用失败) |
RAG Chatbot API v1.0.0 | 基于 FastAPI 构建
使用阿里云 DashScope API (通义千问 + text-embedding-v2)