feat(knowledge): Phase A 知识库可见性隔离 + 结构化数据源 + 蒸馏Worker
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- knowledge_items 增加 visibility(public/private) + account_id 字段
- 新建 structured_sources + structured_rows 表 (Excel JSONB 行级存储)
- 结构化数据源 CRUD API (5 路由: list/get/rows/delete/query)
- 安全查询: JSONB GIN 索引 + 可见性过滤 + 行数限制
- 蒸馏 Worker: 复用 Provider Key Pool 调 DeepSeek/Qwen API
- L0 质量过滤: 长度/隐私检测
- create_item 增加 is_admin 参数控制可见性默认值
- generate_embedding: extract_keywords_from_text 改为 pub 复用

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-04-12 18:36:05 +08:00
parent b8fb76375c
commit c3593d3438
10 changed files with 846 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
//! 知识库模块 — 行业知识管理、RAG 检索、版本控制
//! 知识库模块 — 行业知识管理、RAG 检索、版本控制、结构化数据
pub mod types;
pub mod service;
@@ -36,4 +36,10 @@ pub fn routes() -> axum::Router<crate::state::AppState> {
.route("/api/v1/knowledge/analytics/top-items", get(handlers::analytics_top_items))
.route("/api/v1/knowledge/analytics/quality", get(handlers::analytics_quality))
.route("/api/v1/knowledge/analytics/gaps", get(handlers::analytics_gaps))
// 结构化数据源管理
.route("/api/v1/structured/sources", get(handlers::list_structured_sources))
.route("/api/v1/structured/sources/:id", get(handlers::get_structured_source))
.route("/api/v1/structured/sources/:id/rows", get(handlers::list_structured_source_rows))
.route("/api/v1/structured/sources/:id", delete(handlers::delete_structured_source))
.route("/api/v1/structured/query", post(handlers::query_structured))
}