Explorar el Código

feat(langgraph): microbiome 源改拉 dan_knowledge_base(source_type=article),dan 源排除 article

Xiaogang Liao hace 5 días
padre
commit
99ce39b1b6
Se han modificado 1 ficheros con 17 adiciones y 18 borrados
  1. 17 18
      cfc-langgraph/app/tools/java_client.py

+ 17 - 18
cfc-langgraph/app/tools/java_client.py

@@ -100,20 +100,19 @@ class JavaClient:
         return {}
 
     async def get_microbiome_articles(self) -> list[dict]:
-        """拉取菌群知识库文章(统一数据源 health_knowledge_base,item_type='article')
+        """拉取菌群知识库文章(统一数据源 dan_knowledge_base,source_type='article')
 
         2026-10-20 迁移:microbiome_article 表废弃,809 篇菌群知识统一到
-        health_knowledge_base 管理。分页按 id 升序稳定(ORDER BY id),
-        避免旧 /api/microbiome/article/list 接口 LIMIT/OFFSET 无稳定排序
-        导致的跨页重复(曾拉到 30 条重复 → 向量库缺内容)。
+        dan_knowledge_base 管理。分页拉 /api/admin/knowledge-base/list,
+        ORDER BY id 稳定分页,避免跨页重复。
         """
         client = await self._get_client()
         page = 1
-        size = 100
+        size = 50
         records = []
         while True:
-            resp = await client.post("/api/health/knowledge/article/list",
-                                     json={"page": page, "size": size})
+            resp = await client.post("/api/admin/knowledge-base/list",
+                                     json={"page": page, "size": size, "status": 1, "sourceType": "article"})
             data = resp.json()
             if data.get("code") != 200:
                 break
@@ -124,33 +123,33 @@ class JavaClient:
             if page * size >= int(total or 0) or not items:
                 break
             page += 1
-        # health_knowledge_base 字段 → loader/_build_chunks 所需结构
+        # dan_knowledge_base 字段(camelCase) → loader/_build_chunks 所需结构
         mapped = []
         for r in records:
             if r.get("id") is None:
                 continue
-            title = r.get("itemName") or ""
-            if not title:
-                continue
             mapped.append({
                 "id": r.get("id"),
-                "title": title,
-                "content": r.get("description") or "",
-                "category": r.get("category") or "",
+                "title": r.get("title") or "",
+                "content": r.get("content") or "",
+                "category": "",
                 "tags": "",
-                "source_url": r.get("source") or "",
-                "pub_date": str(r.get("updatedAt") or r.get("updated_at") or ""),
+                "source_url": r.get("sourceUrl") or "",
+                "pub_date": str(r.get("createdAt") or r.get("updatedAt") or ""),
             })
         return mapped
 
     async def get_dan_knowledge_base(self) -> list[dict]:
-        """拉取知识库内容(dan_knowledge_base 表,仅启用 status=1)"""
+        """拉取案例报告源(dan_knowledge_base 表,status=1,排除 article 菌群文章)
+
+        若 article 为 0 条(INSERT 前确实为 0),则该源拉 0 条,正常。
+        """
         client = await self._get_client()
         page = 1
         size = 1000
         records = []
         while True:
-            resp = await client.post("/api/admin/knowledge-base/list", json={"page": page, "size": size, "status": 1})
+            resp = await client.post("/api/admin/knowledge-base/list", json={"page": page, "size": size, "status": 1, "excludeSourceType": "article"})
             data = resp.json()
             if data.get("code") != 200:
                 break