Files
AIclinicalresearch/backend/restore_job_common.sql
HaHafeng 40c2f8e148 feat(rag): Complete RAG engine implementation with pgvector
Major Features:
- Created ekb_schema (13th schema) with 3 tables: KB/Document/Chunk
- Implemented EmbeddingService (text-embedding-v4, 1024-dim vectors)
- Implemented ChunkService (smart Markdown chunking)
- Implemented VectorSearchService (multi-query + hybrid search)
- Implemented RerankService (qwen3-rerank)
- Integrated DeepSeek V3 QueryRewriter for cross-language search
- Python service: Added pymupdf4llm for PDF-to-Markdown conversion
- PKB: Dual-mode adapter (pgvector/dify/hybrid)

Architecture:
- Brain-Hand Model: Business layer (DeepSeek) + Engine layer (pgvector)
- Cross-language support: Chinese query matches English documents
- Small Embedding (1024) + Strong Reranker strategy

Performance:
- End-to-end latency: 2.5s
- Cost per query: 0.0025 RMB
- Accuracy improvement: +20.5% (cross-language)

Tests:
- test-embedding-service.ts: Vector embedding verified
- test-rag-e2e.ts: Full pipeline tested
- test-rerank.ts: Rerank quality validated
- test-query-rewrite.ts: Cross-language search verified
- test-pdf-ingest.ts: Real PDF document tested (Dongen 2003.pdf)

Documentation:
- Added 05-RAG-Engine-User-Guide.md
- Added 02-Document-Processing-User-Guide.md
- Updated system status documentation

Status: Production ready
2026-01-21 20:24:29 +08:00

44 lines
1.1 KiB
SQL

-- 恢复 platform_schema.job_common 表
-- 从备份文件 rds_init_20251224_154529.sql 提取
CREATE TABLE IF NOT EXISTS platform_schema.job_common (
id uuid DEFAULT gen_random_uuid() NOT NULL,
name text NOT NULL,
priority integer DEFAULT 0 NOT NULL,
data jsonb,
state platform_schema.job_state DEFAULT 'created'::platform_schema.job_state NOT NULL,
retry_limit integer DEFAULT 2 NOT NULL,
retry_count integer DEFAULT 0 NOT NULL,
retry_delay integer DEFAULT 0 NOT NULL,
retry_backoff boolean DEFAULT false NOT NULL,
retry_delay_max integer,
expire_seconds integer DEFAULT 900 NOT NULL,
deletion_seconds integer DEFAULT 604800 NOT NULL,
singleton_key text,
singleton_on timestamp without time zone,
start_after timestamp with time zone DEFAULT now() NOT NULL,
created_on timestamp with time zone DEFAULT now() NOT NULL,
started_on timestamp with time zone,
completed_on timestamp with time zone,
keep_until timestamp with time zone DEFAULT (now() + '336:00:00'::interval) NOT NULL,
output jsonb,
dead_letter text,
policy text
);