|
|
@@ -5,19 +5,20 @@
|
|
|
@Project : lq-agent-api
|
|
|
@File : parent_tool.py
|
|
|
@IDE : VsCode
|
|
|
-@Author : 王旭明
|
|
|
+@Author : wandaan
|
|
|
@Date : 2025-12-30
|
|
|
@Description: 父文档增强工具 - 提供父文档查询和拼接功能
|
|
|
"""
|
|
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
|
+from foundation.infrastructure.config.config import config_handler
|
|
|
from foundation.observability.logger.loggering import review_logger as logger
|
|
|
|
|
|
|
|
|
# =============================== 配置 ===============================
|
|
|
|
|
|
-PARENT_COLLECTION = "rag_parent_hybrid" # 父文档集合名称
|
|
|
+PARENT_COLLECTION = config_handler.get('rag_collections', 'PARENT_COLLECTION', 'rag_parent_hybrid')
|
|
|
PARENT_OUTPUT_FIELDS = ["parent_id", "text"] # 父文档查询字段
|
|
|
|
|
|
|
|
|
@@ -66,7 +67,7 @@ def fetch_parent_document(
|
|
|
def fetch_parent_chunks_by_parent_id(
|
|
|
milvus_manager,
|
|
|
parent_id: str,
|
|
|
- collection_name: str = "rag_parent_hybrid", # 子块集合
|
|
|
+ collection_name: str = None, # 从配置读取
|
|
|
output_fields: List[str] = None
|
|
|
) -> Optional[List[Dict[str, Any]]]:
|
|
|
"""
|
|
|
@@ -82,7 +83,10 @@ def fetch_parent_chunks_by_parent_id(
|
|
|
子块片段列表,按 pk 排序,如果不存在返回 None
|
|
|
"""
|
|
|
if output_fields is None:
|
|
|
- output_fields = ["pk", "text", "parent_id", "file_name", "title"]
|
|
|
+ output_fields = ["pk", "text", "parent_id"]
|
|
|
+
|
|
|
+ if collection_name is None:
|
|
|
+ collection_name = config_handler.get('rag_collections', 'PARENT_COLLECTION', 'rag_parent_hybrid')
|
|
|
|
|
|
try:
|
|
|
rows = milvus_manager.condition_query(
|