Procházet zdrojové kódy

Merge branch 'feature/luojunhui/2025-11-14-article-features' of Server/LongArticleTaskServer into master

luojunhui před 2 dny
rodič
revize
3558ba24b7
1 změnil soubory, kde provedl 41 přidání a 3 odebrání
  1. 41 3
      applications/tasks/llm_tasks/process_title.py

+ 41 - 3
applications/tasks/llm_tasks/process_title.py

@@ -695,9 +695,47 @@ class ExtractTitleFeatures(Const):
         await self.update_status_batch(
             id_list, self.INIT_STATUS, self.PROCESSING_STATUS
         )
-        feature_dict = fetch_deepseek_completion(
-            model="default", prompt=prompt, output_type="json"
-        )
+
+        try:
+            feature_dict = fetch_deepseek_completion(
+                model="default", prompt=prompt, output_type="json"
+            )
+        except Exception as e:
+            await self.aliyun_log.log(
+                contents={
+                    "task": "extract_title_features",
+                    "function": "deal",
+                    "message": "fetch deepseek completion failed",
+                    "status": "fail",
+                    "data": {
+                        "error_message": str(e),
+                        "error_type": type(e).__name__,
+                        "traceback": traceback.format_exc(),
+                    },
+                }
+            )
+            await self.update_status_batch(
+                id_list, self.PROCESSING_STATUS, self.FAIL_STATUS
+            )
+            return
+        if not feature_dict:
+            await self.aliyun_log.log(
+                contents={
+                    "task": "extract_title_features",
+                    "function": "deal",
+                    "message": "fetch deepseek completion return empty",
+                    "status": "fail",
+                    "data": {
+                        "error_message": "fetch deepseek completion return empty",
+                        "error_type": "EmptyResponseError",
+                        "traceback": traceback.format_exc(),
+                    },
+                }
+            )
+            await self.update_status_batch(
+                id_list, self.PROCESSING_STATUS, self.FAIL_STATUS
+            )
+            return
 
         for title in tqdm(title_list):
             features = feature_dict.get(title, {})