Browse Source

dev:修复引用路径问题

ChenJiSheng 1 month ago
parent
commit
90d2d81b68
4 changed files with 26 additions and 1 deletions
  1. 0 0
      __init__.py
  2. BIN
      build_graph_app.png
  3. 25 0
      data_pipeline/training_data/test_rag.py
  4. 1 1
      views/test_views.py

+ 0 - 0
__init__.py


BIN
build_graph_app.png


+ 25 - 0
data_pipeline/training_data/test_rag.py

@@ -0,0 +1,25 @@
+import os
+import sys
+current_script_path = os.path.abspath(__file__)
+script_dir = os.path.dirname(current_script_path)
+project_root = os.path.abspath(os.path.join(script_dir, "../../"))
+if project_root not in sys.path:
+    sys.path.insert(0, project_root)
+from foundation.ai.rag.retrieval.retrieval import retrieval_manager
+
+query = "实体:通风孔;背景:在箱梁腹板上设置通风孔,用于结构内部空气流通,需保证与预应力钢筋保护层满足间距要求,并水平设置"
+collection = "first_bfp_collection"  # 你的 Milvus 集合名
+
+# 二阶段:Milvus混合检索(向量+BM25) → BGE重排
+results = retrieval_manager.multi_stage_recall(
+    collection_name=collection,
+    query_text=query,
+    hybrid_top_k=50,   # 第一阶段取多少候选
+    top_k=3,          # 最终返回条数
+    ranker_type="weighted"  # 或 "rrf"
+)
+
+print(results)
+for item in results:
+    print(item["rerank_score"], item["text_content"])
+    # 元数据在 item["metadata"](来自混合检索阶段)

+ 1 - 1
views/test_views.py

@@ -25,7 +25,7 @@ from views import test_router, get_operation_id
 from foundation.ai.agent.workflow.test_workflow_graph import test_workflow_graph
 
 from foundation.database.base.sql.async_mysql_base_dao import TestTabDAO
-from database.repositories.bus_data_query import BasisOfPreparationDAO
+from foundation.database.repositories.bus_data_query import BasisOfPreparationDAO
 from foundation.utils.tool_utils import DateTimeEncoder
 from langchain_core.prompts import ChatPromptTemplate
 from foundation.utils.yaml_utils import system_prompt_config