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

@@ -156,5 +156,6 @@ https://iit.xunzhengyixue.com/api/v1/iit/health

View File

@@ -57,5 +57,6 @@

View File

@@ -317,5 +317,6 @@ npx tsx src/modules/iit-manager/test-patient-wechat-url-verify.ts

View File

@@ -179,5 +179,6 @@ npm run dev

View File

@@ -58,3 +58,4 @@ main()

View File

@@ -52,3 +52,4 @@ main()

View File

@@ -47,3 +47,4 @@ main()

View File

@@ -79,3 +79,4 @@ main()

View File

@@ -42,3 +42,4 @@ main()

View File

@@ -83,3 +83,4 @@ main()

View File

@@ -30,3 +30,4 @@ main()

View File

@@ -118,3 +118,4 @@ main()

View File

@@ -89,3 +89,4 @@ main()

View File

@@ -75,3 +75,4 @@ main()

View File

@@ -117,3 +117,4 @@ main()

View File

@@ -28,3 +28,4 @@ ON CONFLICT (id) DO NOTHING;

View File

@@ -60,3 +60,4 @@ ON CONFLICT (id) DO NOTHING;

View File

@@ -76,5 +76,6 @@ WHERE table_schema = 'dc_schema'

View File

@@ -114,5 +114,6 @@ ORDER BY ordinal_position;

View File

@@ -127,5 +127,6 @@ runMigration()

View File

@@ -61,5 +61,6 @@ COMMENT ON COLUMN "dc_schema"."dc_tool_c_sessions"."column_mapping" IS '列名

View File

@@ -88,5 +88,6 @@ COMMENT ON COLUMN dc_schema.dc_tool_c_sessions.expires_at IS '过期时间(创

View File

@@ -128,5 +128,6 @@ Write-Host ""

View File

@@ -238,5 +238,6 @@ function extractCodeBlocks(obj, blocks = []) {

View File

@@ -37,3 +37,4 @@ CREATE TABLE IF NOT EXISTS platform_schema.job_common (

View File

@@ -111,3 +111,4 @@ CREATE OR REPLACE FUNCTION platform_schema.delete_queue(queue_name text) RETURNS

View File

@@ -257,5 +257,6 @@ checkDCTables();

View File

@@ -12,3 +12,4 @@ CREATE SCHEMA IF NOT EXISTS capability_schema;

View File

@@ -209,5 +209,6 @@ createAiHistoryTable()

View File

@@ -196,5 +196,6 @@ createToolCTable()

View File

@@ -193,5 +193,6 @@ createToolCTable()

View File

@@ -315,3 +315,4 @@ main()
})
.finally(() => prisma.$disconnect());

View File

@@ -122,3 +122,4 @@ main()

View File

@@ -342,3 +342,4 @@ runTests().catch(error => {

View File

@@ -88,3 +88,4 @@ testAPI().catch(console.error);

View File

@@ -118,3 +118,4 @@ async function testDeepSearch() {
// ========== 运行 ==========
testDeepSearch().catch(console.error);

View File

@@ -307,3 +307,4 @@ verifySchemas()

View File

@@ -195,3 +195,4 @@ export const jwtService = new JWTService();

View File

@@ -325,5 +325,6 @@ export function getBatchItems<T>(

View File

@@ -78,3 +78,4 @@ export interface VariableValidation {

View File

@@ -199,3 +199,4 @@ export function createOpenAIStreamAdapter(

View File

@@ -205,3 +205,4 @@ export async function streamChat(

View File

@@ -23,3 +23,4 @@ export { THINKING_TAGS } from './types';

View File

@@ -98,3 +98,4 @@ export type SSEEventType =

View File

@@ -84,3 +84,4 @@ export async function moduleRoutes(fastify: FastifyInstance) {

View File

@@ -114,3 +114,4 @@ export interface PaginatedResponse<T> {

View File

@@ -161,3 +161,4 @@ export const ROLE_DISPLAY_NAMES: Record<UserRole, string> = {

View File

@@ -236,3 +236,4 @@ async function matchIntent(query: string): Promise<{

View File

@@ -90,3 +90,4 @@ export async function uploadAttachment(
}

View File

@@ -19,3 +19,4 @@ export { aiaRoutes };

View File

@@ -361,5 +361,6 @@ runTests().catch((error) => {

View File

@@ -340,5 +340,6 @@ Content-Type: application/json

View File

@@ -276,5 +276,6 @@ export const conflictDetectionService = new ConflictDetectionService();

View File

@@ -226,5 +226,6 @@ curl -X POST http://localhost:3000/api/v1/dc/tool-c/test/execute \

View File

@@ -280,5 +280,6 @@ export const streamAIController = new StreamAIController();

View File

@@ -189,5 +189,6 @@ logger.info('[SessionMemory] 会话记忆管理器已启动', {

View File

@@ -123,5 +123,6 @@ checkTableStructure();

View File

@@ -110,5 +110,6 @@ checkProjectConfig().catch(console.error);

View File

@@ -92,5 +92,6 @@ main();

View File

@@ -549,5 +549,6 @@ URL: https://iit.xunzhengyixue.com/api/v1/iit/patient-wechat/callback

View File

@@ -184,5 +184,6 @@ console.log('');

View File

@@ -501,5 +501,6 @@ export const patientWechatService = new PatientWechatService();

View File

@@ -146,5 +146,6 @@ testDifyIntegration().catch(error => {

View File

@@ -175,5 +175,6 @@ testIitDatabase()

View File

@@ -161,5 +161,6 @@ if (hasError) {

View File

@@ -187,5 +187,6 @@ async function testUrlVerification() {

View File

@@ -268,5 +268,6 @@ main().catch((error) => {

View File

@@ -152,5 +152,6 @@ Write-Host ""

View File

@@ -245,5 +245,6 @@ export interface CachedProtocolRules {

View File

@@ -60,3 +60,4 @@ export default async function healthRoutes(fastify: FastifyInstance) {

View File

@@ -138,3 +138,4 @@ Content-Type: application/json

View File

@@ -123,3 +123,4 @@ Write-Host " - 删除任务: DELETE $BaseUrl/api/v1/rvw/tasks/{taskId}" -Foregr

View File

@@ -37,3 +37,4 @@ export * from './services/utils.js';

View File

@@ -128,3 +128,4 @@ export function validateAgentSelection(agents: string[]): void {

View File

@@ -426,5 +426,6 @@ SET session_replication_role = 'origin';

View File

@@ -128,5 +128,6 @@ WHERE key = 'verify_test';

View File

@@ -271,5 +271,6 @@ verifyDatabase()

View File

@@ -61,5 +61,6 @@ export {}

View File

@@ -84,5 +84,6 @@ Write-Host "✅ 完成!" -ForegroundColor Green

View File

@@ -11,3 +11,4 @@ SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('p

View File

@@ -174,3 +174,4 @@ DELETE {{baseUrl}}/api/v1/pkb/knowledge/knowledge-bases/{{testKbId}}

View File

@@ -371,5 +371,6 @@ runAdvancedTests().catch(error => {

View File

@@ -437,5 +437,6 @@ runAllTests()

View File

@@ -395,5 +395,6 @@ runAllTests()

View File

@@ -31,3 +31,4 @@ main()

View File

@@ -29,3 +29,4 @@ main()

View File

@@ -41,3 +41,4 @@ main()

View File

@@ -30,3 +30,4 @@ main()

View File

@@ -170,3 +170,4 @@ main()