Browse Source

素材解构-taskBatch 由 200升级为 2000
并且降低并发

luojunhui 4 days ago
parent
commit
a24a0575da

+ 2 - 1
app/domains/llm_tasks/decode_material/_const.py

@@ -1,7 +1,8 @@
 class DecodeMaterialConst:
     CONFIG_ID = 69
-    TASK_BATCH = 200
+    TASK_BATCH = 2000
     SUBMIT_BATCH = 50
+    API_INTERVAL = 0.5  # AIGC API 批次间间隔(秒),控制请求频率
 
     class TaskStatus:
         INIT = 0

+ 5 - 0
app/domains/llm_tasks/decode_material/_utils.py

@@ -1,3 +1,4 @@
+import asyncio
 from typing import Dict, List
 
 from app.infra.internal.aigc_decode_server import AigcDecodeServer
@@ -29,6 +30,8 @@ class MaterialDecodeUtils(DecodeMaterialConst):
                         "status": "FAILED",
                         "errorMessage": f"batch submit failed: {response}",
                     }
+            if i + self.SUBMIT_BATCH < len(posts):
+                await asyncio.sleep(self.API_INTERVAL)
         return result
 
     async def query_decode_results_batch(
@@ -51,6 +54,8 @@ class MaterialDecodeUtils(DecodeMaterialConst):
                         "status": "API_ERROR",
                         "errorMessage": f"query API failed: {response}",
                     }
+            if i + self.SUBMIT_BATCH < len(content_ids):
+                await asyncio.sleep(self.API_INTERVAL)
         return result
 
     @staticmethod

+ 1 - 0
app/domains/llm_tasks/decode_material/fetch_decode_results.py

@@ -95,6 +95,7 @@ class FetchMaterialDecodeResults(DecodeMaterialConst):
             handler=self._process_batch,
             description="批量查询素材解构结果",
             unit="batch",
+            max_concurrency=3,
         )
 
         await self.log_service.log(