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
178 lines
4.8 KiB
HTTP
178 lines
4.8 KiB
HTTP
###
|
||
# PKB模块迁移 - API测试脚本
|
||
# 测试v1和v2路由的功能完整性和一致<EFBFBD>?
|
||
###
|
||
|
||
@baseUrl = http://localhost:3000
|
||
@userId = user-mock-001
|
||
|
||
### ============================================
|
||
### 阶段3.1: 健康检<EFBFBD>?
|
||
### ============================================
|
||
|
||
### 1. PKB v2健康检<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/health
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.2: 知识库CRUD测试
|
||
### ============================================
|
||
|
||
### 2. 获取知识库列表(v1<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/knowledge-bases
|
||
Accept: application/json
|
||
|
||
### 3. 获取知识库列表(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases
|
||
Accept: application/json
|
||
|
||
### 4. 创建知识库(v2<EFBFBD>?
|
||
POST {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases
|
||
Content-Type: application/json
|
||
|
||
{
|
||
"name": "测试知识库v2-{{$timestamp}}",
|
||
"description": "这是一个通过v2 API创建的测试知识库"
|
||
}
|
||
|
||
### 5. 创建知识库(v1 - 对比<EFBFBD>?
|
||
POST {{baseUrl}}/api/v1/knowledge-bases
|
||
Content-Type: application/json
|
||
|
||
{
|
||
"name": "测试知识库v1-{{$timestamp}}",
|
||
"description": "这是一个通过v1 API创建的测试知识库"
|
||
}
|
||
|
||
### 6. 获取知识库详情(v2<EFBFBD>?
|
||
# 替换为实际的知识库ID
|
||
@kbId = f6ebe476-c50f-4222-83d2-c2525edc6054
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||
Accept: application/json
|
||
|
||
### 7. 获取知识库详情(v1 - 对比<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}
|
||
Accept: application/json
|
||
|
||
### 8. 更新知识库(v2<EFBFBD>?
|
||
PUT {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||
Content-Type: application/json
|
||
|
||
{
|
||
"name": "更新后的知识库名称v2",
|
||
"description": "通过v2 API更新的描<EFBFBD>?
|
||
}
|
||
|
||
### 9. 获取知识库统计(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/stats
|
||
Accept: application/json
|
||
|
||
### 10. 获取知识库统计(v1 - 对比<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/stats
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.3: RAG检索测<EFBFBD>?
|
||
### ============================================
|
||
|
||
### 11. RAG检索(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=阿尔兹海默症的治疗方<EFBFBD>?top_k=5
|
||
Accept: application/json
|
||
|
||
### 12. RAG检索(v1 - 对比<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/search?query=阿尔兹海默症的治疗方<EFBFBD>?top_k=5
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.4: 文档选择(全文阅读模式)
|
||
### ============================================
|
||
|
||
### 13. 获取文档选择(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/document-selection?max_files=7&max_tokens=750000
|
||
Accept: application/json
|
||
|
||
### 14. 获取文档选择(v1 - 对比<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/knowledge-bases/{{kbId}}/document-selection?max_files=7&max_tokens=750000
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.5: 文档管理测试
|
||
### ============================================
|
||
|
||
### 15. 获取文档列表(通过知识库详情)
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}
|
||
Accept: application/json
|
||
|
||
### 16. 获取单个文档详情(v2<EFBFBD>?
|
||
# 替换为实际的文档ID
|
||
@docId = your-document-id
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/documents/{{docId}}
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.6: 批处理功能测<EFBFBD>?
|
||
### ============================================
|
||
|
||
### 17. 获取批处理模板(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/batch-tasks/batch/templates
|
||
Accept: application/json
|
||
|
||
### 18. 创建批处理任务(v2<EFBFBD>?
|
||
POST {{baseUrl}}/api/v1/pkb/batch-tasks/batch/execute
|
||
Content-Type: application/json
|
||
|
||
{
|
||
"kb_id": "{{kbId}}",
|
||
"document_ids": [],
|
||
"template_type": "preset",
|
||
"template_id": "clinical_research_method",
|
||
"model_type": "deepseek-v3",
|
||
"task_name": "测试批处理任务v2"
|
||
}
|
||
|
||
### ============================================
|
||
### 阶段3.7: 边界条件测试
|
||
### ============================================
|
||
|
||
### 19. 测试不存在的知识库(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/00000000-0000-0000-0000-000000000000
|
||
Accept: application/json
|
||
|
||
### 20. 测试无效的查询参数(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=&top_k=0
|
||
Accept: application/json
|
||
|
||
### 21. 测试超大top_k参数(v2<EFBFBD>?
|
||
GET {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{kbId}}/search?query=测试&top_k=1000
|
||
Accept: application/json
|
||
|
||
### ============================================
|
||
### 阶段3.8: 清理测试数据(可选)
|
||
### ============================================
|
||
|
||
### 22. 删除测试知识库(v2<EFBFBD>?
|
||
# @testKbId = 从创建响应中获取的ID
|
||
DELETE {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{testKbId}}
|
||
|
||
###
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|