feat: 完成 issue #46 RAG 知识库模板化接入(工艺规范/SOP/国标)

- core/rag-kb:领域 RAG 知识库按模板配置(PRD 5.4/7.3,EPIC #6 子任务)
- templating.py:知识源三类分类 + 模板命名推导 + 零依赖轻量 YAML 配置加载
- documents.py:文档段落抽取分块,chunk 携带 文档/章节/段落 溯源信息
- store.py:from_template_config 按模板自动构建 + 中英混合词频检索 + 类别过滤
- config/kb.template.yaml:ti-cl4 模板 RAG 库资产示例(工艺规范/SOP/国标)
- tests:29 用例全绿(模板化/分块溯源/检索排序/类别过滤/配置校验)
This commit is contained in:
2026-08-04 16:31:31 +08:00
parent 9c3e59695a
commit 1fb1d278d5
11 changed files with 1135 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
"""测试引导:把 `core/rag-kb` 以包名 `rag_kb` 挂载到 sys.modules。
目录名 `rag-kb` 含连字符,无法直接以包名 import;挂载后模块内相对导入
(`from .templating import ...`)在 unittest 发现机制下可正常解析。
"""
import os
import sys
import types
RAG_KB_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, RAG_KB_DIR)
if "rag_kb" not in sys.modules:
pkg = types.ModuleType("rag_kb")
pkg.__path__ = [RAG_KB_DIR]
sys.modules["rag_kb"] = pkg