文件变更

This commit is contained in:
2026-04-20 14:05:57 +08:00
parent 3c906e91d9
commit 4e981e9dcf
28 changed files with 474 additions and 490 deletions

View File

@@ -0,0 +1,23 @@
# app/rag_initializer.py
from app.rag.tools import create_rag_tool_sync
from rag_core import create_parent_retriever
from app.logger import info, warning
async def init_rag_tool(local_llm_creator):
"""初始化 RAG 工具,失败返回 None"""
try:
info("🔄 正在初始化 RAG 检索系统...")
retriever = create_parent_retriever(
collection_name="rag_documents",
search_k=5,
)
rewrite_llm = local_llm_creator()
rag_tool = create_rag_tool_sync(
retriever, rewrite_llm,
num_queries=3, rerank_top_n=5
)
info("✅ RAG 检索工具初始化成功")
return rag_tool
except Exception as e:
warning(f"⚠️ RAG 检索工具初始化失败: {e}")
return None