Просмотр исходного кода

Merge branch 'feature/luojunhui/20260520-decode-server-post-clear' of Server/LongArticleTaskServer into master

luojunhui 2 дней назад
Родитель
Сommit
03e16cb1f4
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      app/infra/internal/aigc_decode_server.py

+ 11 - 1
app/infra/internal/aigc_decode_server.py

@@ -6,6 +6,16 @@ from app.infra.shared import AsyncHttpClient
 class AigcDecodeServer:
     base_url: str = "https://aigc-api.aiddit.com"
 
+    @staticmethod
+    def _sanitize_images(posts: List[Dict]) -> List[Dict]:
+        for post in posts:
+            images = post.get("images")
+            if images:
+                post["images"] = [
+                    img for img in images if img and img.startswith(("http://", "https://"))
+                ]
+        return posts
+
     async def submit_decode(
         self, config_id: int, posts: List[Dict], skip_completed: bool = False
     ) -> Dict:
@@ -18,7 +28,7 @@ class AigcDecodeServer:
             "params": {
                 "configId": config_id,
                 "skipCompleted": skip_completed,
-                "posts": posts,
+                "posts": self._sanitize_images(posts),
             }
         }
         async with AsyncHttpClient() as client: