Kaynağa Gözat

feat: 修改聚类参数

jihuaqiang 1 ay önce
ebeveyn
işleme
7f89f7b9aa
1 değiştirilmiş dosya ile 5 ekleme ve 24 silme
  1. 5 24
      tasks/pattern.py

+ 5 - 24
tasks/pattern.py

@@ -104,33 +104,18 @@ def _save_pattern_contents(task_id: str, contents: List[ContentParam]) -> bool:
     return True
 
 
-def _trigger_pattern_workflow(task_id: str, pattern_name: str, contents: List[ContentParam]) -> Dict[str, Any]:
-    """发起真正的聚类请求"""
+def _trigger_pattern_workflow(task_id: str) -> Dict[str, Any]:
+    """发起真正的聚类请求,只携带 task_id"""
     try:
         url = "http://localhost:8100/pattern/workflow/topic/pattern"
 
-        weight_score_map = {
-            c.channel_content_id: c.weight_score for c in contents if c.weight_score is not None
-        }
-        request_contents = [
-            {
-                "channel_content_id": c.channel_content_id,
-                "title": c.title or "",
-                "body_text": c.body_text or "",
-            }
-            for c in contents
-        ]
-
         payload = {
-            "task_id": task_id,
-            "pattern_name": pattern_name,
-            "weight_score_map": weight_score_map,
-            "contents": request_contents,
+            "task_id": task_id
         }
 
         resp = requests.post(url, json=payload, timeout=10)
 
-        if resp.status_code != 0:
+        if resp.status_code != 200:
             logger.error(
                 f"发起聚类任务失败,HTTP 状态码异常,status={resp.status_code}, task_id={task_id}"
             )
@@ -203,11 +188,7 @@ def begin_pattern_task(param: PatternContentParam) -> Dict[str, Any]:
             )
 
         # 4. 发起真正的聚类请求
-        trigger_result = _trigger_pattern_workflow(
-            task.task_id,
-            param.pattern_name,
-            param.contents,
-        )
+        trigger_result = _trigger_pattern_workflow(task.task_id)
         if trigger_result.get("code") != ERROR_CODE_SUCCESS:
             return _build_error_response(
                 ERROR_CODE_FAILED,