Jelajahi Sumber

Fix walk trigger source labels

Sam Lee 3 minggu lalu
induk
melakukan
b17e6db207
2 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 6 1
      content_agent/flow_ledger_service.py
  2. 1 1
      tests/test_flow_ledger_api.py

+ 6 - 1
content_agent/flow_ledger_service.py

@@ -677,7 +677,7 @@ def _walk_status_label(status: str) -> str:
 
 
 def _walk_from_label(action: dict[str, Any], query: dict[str, Any] | None, bundle: dict[str, Any]) -> str:
-    from_type = _text(action.get("from_node_type"))
+    from_type = _text(action.get("from_node_type")).lower()
     from_node_id = _text(action.get("from_node_id"))
     if "query" in from_type:
         source_query = next((item for item in bundle["queries"] if _text(item.get("search_query_id")) == from_node_id), None) or query
@@ -708,9 +708,14 @@ def _walk_trigger_label(action: dict[str, Any]) -> str:
     hashtag = _text(action.get("hashtag") or raw.get("hashtag"))
     if hashtag:
         return f"标签:#{hashtag.lstrip('#')}"
+    edge = _walk_lane_id(action)
+    if edge in {"hashtag_to_query", "tag_query"}:
+        return "标签:未生成(先被扩展门槛拦下)"
     author = _text(action.get("author_id") or raw.get("author_id") or action.get("platform_author_id") or raw.get("platform_author_id"))
     if author:
         return f"作者:{author}"
+    if edge in {"author_to_works", "video_to_author", "author_works"}:
+        return "作者:未进入作者作品扩展"
     cursor = _text(action.get("page_cursor") or raw.get("page_cursor") or action.get("cursor") or raw.get("cursor"))
     if cursor:
         return f"翻页游标:{cursor}"

+ 1 - 1
tests/test_flow_ledger_api.py

@@ -221,7 +221,7 @@ def test_flow_ledger_api_returns_business_v4_ledger(tmp_path, monkeypatch):
                 "edge_id": "hashtag_to_query",
                 "hashtag": "拉伸",
                 "depth": 1,
-                "from_node_type": "content",
+                "from_node_type": "Content",
                 "from_node_id": "douyin_001",
                 "to_node_id": "q_002",
                 "walk_status": "success",