feat(pkb): Replace Dify with self-developed pgvector RAG engine

Major milestone: Successfully replaced Dify external service with PostgreSQL + pgvector RAG engine

Backend changes:
- Refactor ragService.ts: Remove dual-track mode, keep only pgvector
- Refactor knowledgeBaseService.ts: Remove Dify creation logic
- Refactor documentService.ts: Remove Dify upload/polling logic
- DifyClient.ts: Convert to deprecated stub file (for legacy compatibility)
- common/rag/index.ts: Update exports
- common/rag/types.ts: Remove Dify types, keep generic RAG types
- config/env.ts: Remove Dify configuration

Frontend changes:
- DashboardPage.tsx: Add delete knowledge base dropdown menu
- KnowledgeBaseList.tsx: Enhance quota warning display
- CreateKBDialog.tsx: Add quota exceeded modal with guidance
- knowledgeBaseApi.ts: Add auth interceptor

Documentation:
- Update PKB module status guide (v2.3)
- Update system status guide (v4.0)

Performance metrics:
- Single query latency: 2.5s
- Single query cost: 0.0025 CNY
- Cross-language accuracy improvement: +20.5%

Remaining tasks:
- OSS storage integration
- pg_bigm extension installation

Tested: End-to-end test passed (create KB -> upload doc -> vector search)
This commit is contained in:
2026-01-21 22:35:50 +08:00
parent 40c2f8e148
commit 483c62fb6f
14 changed files with 741 additions and 1018 deletions

View File

@@ -47,9 +47,19 @@ export async function createKnowledgeBase(
});
} catch (error: any) {
console.error('Failed to create knowledge base:', error);
// 处理配额超限错误
if (error.code === 'QUOTA_EXCEEDED') {
return reply.status(400).send({
success: false,
code: 'QUOTA_EXCEEDED',
message: error.message,
});
}
return reply.status(500).send({
success: false,
message: error.message || 'Failed to create knowledge base',
message: error.message || '创建知识库失败,请稍后重试',
});
}
}