feat(pkb): Integrate pgvector and create Dify replacement plan

Summary:
- Migrate PostgreSQL to pgvector/pgvector:pg15 Docker image
- Successfully install and verify pgvector 0.8.1 extension
- Create comprehensive Dify-to-pgvector migration plan
- Update PKB module documentation with pgvector status
- Update system documentation with pgvector integration

Key changes:
- docker-compose.yml: Switch to pgvector/pgvector:pg15 image
- Add EkbDocument and EkbChunk data model design
- Design R-C-R-G hybrid retrieval architecture
- Add clinical data JSONB fields (pico, studyDesign, regimen, safety, criteria, endpoints)
- Create detailed 10-day implementation roadmap

Documentation updates:
- PKB module status: pgvector RAG infrastructure ready
- System status: pgvector 0.8.1 integrated
- New: Dify replacement development plan (01-Dify替换为pgvector开发计划.md)
- New: Enterprise medical knowledge base solution V2

Tested: PostgreSQL with pgvector verified, frontend and backend functionality confirmed
This commit is contained in:
2026-01-20 00:00:58 +08:00
parent 1ece9a4ae8
commit dfc0fe0b9a
289 changed files with 1897 additions and 41 deletions

View File

@@ -1,13 +1,13 @@
# AIclinicalresearch 系统当前状态与开发指南
> **文档版本:** v3.7
> **文档版本:** v3.8
> **创建日期:** 2025-11-28
> **维护者:** 开发团队
> **最后更新:** 2026-01-18
> **重大进展:** 🎉 **ASL 智能文献检索DeepSearchMVP 完成**
> - 🆕 集成 unifuncs DeepSearch APIAI 驱动的 PubMed 自动检索
> - ✅ SSE 实时流式显示 AI 思考过程
> - ✅ 自然语言输入,自动生成检索策略
> **最后更新:** 2026-01-19
> **重大进展:** 🎉 **pgvector 向量数据库集成完成PKB RAG 基础设施就绪**
> - 🆕 pgvector 0.8.1 已安装,支持 HNSW/IVFFlat 索引
> - ✅ 与阿里云 RDS pgvector 0.8.0 完全兼容
> - ✅ PKB 模块 RAG 检索功能基础设施已就绪
> **部署状态:** ✅ 生产环境运行中 | 公网地址http://8.140.53.236/
> **文档目的:** 快速了解系统当前状态为新AI助手提供上下文
@@ -100,7 +100,8 @@
- 架构增量演进legacy + common + modules
**数据库**
- PostgreSQL 15 Docker: postgres:15-alpine
- PostgreSQL 15 Docker: pgvector/pgvector:pg15
- **pgvector 0.8.1** ✅ 2026-01-19 新增(向量数据库扩展,支持 RAG
- 12个Schema隔离platform/aia/pkb/asl/dc/iit/ssa/st/rvw/admin/common/capability ✅新增)
**云原生部署**
@@ -120,9 +121,52 @@
---
## 🚀 当前开发状态2026-01-18
## 🚀 当前开发状态2026-01-19
### 🏆 最新进展:AIA V2.1 Prompt管理集成2026-01-18
### 🏆 最新进展:pgvector 向量数据库集成2026-01-19
#### ✅ pgvector 0.8.1 安装成功
**背景**
- PKB 模块需要实现 RAG 检索功能
- 原计划依赖 Dify 知识库,现改为 PostgreSQL 原生 pgvector 方案
- 与 Postgres-Only 架构理念一致,减少外部依赖
**完成工作**
- ✅ Docker 镜像迁移:`postgres:15-alpine``pgvector/pgvector:pg15`
- ✅ pgvector 扩展安装:版本 0.8.1
- ✅ 数据安全执行双重备份SQL dump + Volume tarball
- ✅ 功能验证:前后端服务重启后功能全部正常
- ✅ 数据完整性用户数据、pg-boss 队列函数全部正常
**技术细节**
| 项目 | 说明 |
|------|------|
| Docker 镜像 | `pgvector/pgvector:pg15` |
| pgvector 版本 | 0.8.1 |
| 支持索引类型 | HNSW、IVFFlat |
| 最大向量维度 | 16000 维 |
| 阿里云 RDS 兼容性 | ✅ 完全兼容RDS 为 0.8.0 |
**版本兼容性说明**
- 开发环境pgvector 0.8.1
- 生产环境(阿里云 RDSpgvector 0.8.0
- 兼容性0.8.x 系列向后兼容,数据格式和 API 一致
**文件变更**
- `docker-compose.yml`:更新 postgres 服务镜像
- `Dockerfile.postgres-pgvector`:自定义构建文件(备用)
- `backup_before_pgvector_20260119.sql`:迁移前备份
- `postgres_volume_backup_20260119.tar`Volume 备份
**下一步**
- 设计 `pkb_schema.document_embeddings` 向量表
- 集成 Embedding 服务OpenAI/智谱)
- 实现 RAG 检索 API
---
### 🏆 历史进展AIA V2.1 Prompt管理集成2026-01-18
#### ✅ AIA 模块 Prompt 管理系统集成
@@ -378,7 +422,7 @@ data: [DONE]\n\n
**详细文档:** [AIA模块状态与开发指南](../../03-业务模块/AIA-AI智能问答/00-模块当前状态与开发指南.md)
#### 3. PKB模块 - 个人知识库 🎉 **前端V3设计完成**
#### 3. PKB模块 - 个人知识库 🎉 **pgvector RAG基础设施就绪**
**开发进度**
-**后端API**100%完成v1 + v2双路由运行
@@ -387,7 +431,7 @@ data: [DONE]\n\n
-**全文阅读模式**90%完成Chat组件集成
-**逐篇精读模式**85%完成(文档选择+对话)
- 🔧 **批处理模式**70%完成UI完成API待调试
- **RAG检索模式**0%(后端待实现
- 🟡 **RAG检索模式**基础设施就绪pgvector 0.8.1 已安装),业务逻辑待实现
**核心功能**
- 知识库CRUD + 文档管理
@@ -400,11 +444,12 @@ data: [DONE]\n\n
- ✅ Zustand状态管理
- ✅ 复用shared/components/Chat通用组件
- ✅ 单层Header + 紧凑工作模式栏设计
-**pgvector 0.8.1 已集成**2026-01-19
**待解决问题**
- 🔧 批处理API执行待调试
- 🔧 知识资产页面导航条待完善
- 🔧 UI与原型图精细化对比
- 🔧 RAG 检索业务逻辑待实现向量表设计、Embedding服务
**详细文档**[PKB模块当前状态](../03-业务模块/PKB-个人知识库/00-模块当前状态与开发指南.md)
@@ -896,7 +941,8 @@ AIclinicalresearch/
| **2026-01-02** | **REDCap对接方案** 🏆 | ✅ REDCap环境部署 + DET+REST API方案确定 |
| **2026-01-07 上午** | **PKB前端V3** 🎉 | ✅ PKB模块前端V3设计实现完成Dashboard+Workspace+3种工作模式 |
| **2026-01-07 下午** | **PKB批处理完善** 🏆 | ✅ 批处理完整流程调试通过(执行+进度+结果导出)+ 文档上传功能 + UI优化 |
| **当前** | **PKB模块生产可用** | ✅ 核心功能全部实现90%),具备生产环境部署条件 |
| **2026-01-19** | **pgvector集成** 🎉 | ✅ pgvector 0.8.1 安装成功PKB RAG基础设施就绪 |
| **当前** | **PKB模块生产可用** | ✅ 核心功能全部实现90%pgvector已集成RAG业务逻辑待开发 |
| **2026-01-07 晚** | **RVW模块开发完成** 🎉 | ✅ Phase 1-3完成后端迁移+数据库扩展+前端重构) |
---
@@ -1001,7 +1047,8 @@ AIclinicalresearch/
### 环境要求
```
Node.js: v22.18.0+
PostgreSQL: 15+当前使用15.14
PostgreSQL: 15+当前使用15.14Docker镜像: pgvector/pgvector:pg15
pgvector: 0.8.1(向量数据库扩展)
npm: 10+
```
@@ -1194,14 +1241,15 @@ if (items.length >= 50) {
## 🌟 技术亮点
1.**Platform-Only 架构**:统一任务管理,零代码重复 🏆 **新!**
2.**智能双模式处理**:小任务快速响应,大任务可靠执行 🏆 **新!**
3.**适配器模式**:存储/缓存/日志支持本地↔云端零代码切换
4.**10个Schema一次性完成**:架构一次到位
5.**Prisma自动路由**Schema迁移后代码无需修改
6.**4个LLM集成**DeepSeek、Qwen、GPT、Claude
7.**增量演进**:新旧并存,降低风险
8.**云原生就绪**为SAE部署做好准备
1.**Platform-Only 架构**:统一任务管理,零代码重复 🏆
2.**智能双模式处理**:小任务快速响应,大任务可靠执行 🏆
3.**pgvector 向量数据库**PostgreSQL 原生 RAG 支持 🏆 **2026-01-19 新增!**
4.**适配器模式**:存储/缓存/日志支持本地↔云端零代码切换
5.**12个Schema隔离**:架构一次到位
6.**Prisma自动路由**Schema迁移后代码无需修改
7.**4个LLM集成**DeepSeek、Qwen、GPT、Claude
8.**增量演进**新旧并存,降低风险
9.**云原生就绪**为SAE部署做好准备
---
@@ -1213,9 +1261,9 @@ if (items.length >= 50) {
---
**文档版本**v3.1
**最后更新**2026-01-10
**下次更新**RVW生产环境部署 或 ASL智能文献筛选模块启动
**文档版本**v3.8
**最后更新**2026-01-19
**下次更新**PKB RAG检索功能实现 或 生产环境pgvector部署
---