Enhance knowledge base functionality and integrate S3 storage support

- Add new models for `KnowledgeDocument` and `KnowledgeChunk` to manage document ingestion and chunking.
- Implement S3-compatible storage integration for knowledge documents, allowing for file uploads and retrieval.
- Introduce API endpoints for managing knowledge bases and documents, including creation, deletion, and searching.
- Update frontend components to support knowledge base configuration and document management, improving user interaction.
- Enhance backend services for knowledge processing and retrieval, ensuring robust handling of document statuses and errors.
This commit is contained in:
Xin Wang
2026-07-12 13:58:47 +08:00
parent 01c563a3e7
commit de58f30014
21 changed files with 995 additions and 34 deletions

View File

@@ -134,8 +134,9 @@ docker compose up # 前台起 pg + api(:8000)+ ui(:3030),日志
docker compose up -d # 后台起;看日志 docker compose logs -f api
docker compose down # 停止全部
# 可选:对象存储 / 后台任务
docker compose --profile data up # + rustfs(S3) / redis
# 知识库依赖 RustFS默认 compose 会一起启动。Redis 仍是可选服务。
docker compose up -d postgres rustfs api ui
docker compose --profile data up -d redis
# 可选:公网部署(WebRTC 需 TURN)
docker compose --profile remote up -d
```
@@ -143,6 +144,20 @@ docker compose --profile remote up -d
> 首次 `up` 会构建 api 镜像(装全量 `requirements.txt`,含 pipecat,较慢)。
> 之后改 Python 代码靠 `--reload` 热更新,不用重建;只有改 `requirements.txt` 才 `docker compose build api`。
## 极简知识库 MVP
知识库入口为前端「组件 / 知识库」。使用前先在「组件 / 模型」配置并启用
一个 Embedding 资源,然后:
1. 创建知识库并选择 Embedding 模型。
2. 上传 PDF、DOCX、TXT、Markdown、CSV、JSON 或 HTML或者直接添加文字。
3. 文档状态会从 `pending` 变为 `processing`,最终进入 `ready``failed`
4. 失败记录会保留,可在页面重试;完成后可预览分块并使用「检索测试」验证召回。
5. 在提示词助手的 pipeline 模式下选择知识库。每轮 LLM 推理前会自动检索并注入相关片段。
当前后台处理使用 FastAPI 进程内任务,适合 MVP。服务重启时未完成任务会转为失败
可在页面重试;需要多实例或高吞吐时再迁移到 Redis/ARQ worker。
## 待联调 / TODO
- [ ] 联调 Pipecat 1.3.0 语音链路与各 OpenAI 兼容服务