fix: parse nested image generation tasks

This commit is contained in:
Codex
2026-08-02 09:30:23 +08:00
parent a96b1bf9f9
commit d91c137834
4 changed files with 152 additions and 7 deletions
+3 -2
View File
@@ -16,7 +16,7 @@ from app.domain.models import (
StructureAnalysis,
StyleDirection,
)
from app.integrations.openai_compatible import OpenAICompatibleGateway
from app.integrations.openai_compatible import OpenAICompatibleGateway, safe_response_diagnostic
def crop_plan_preview(preview: bytes, region: PlanRegion | None) -> bytes:
@@ -302,7 +302,8 @@ async def generated_image_bytes(payload: dict[str, Any]) -> tuple[bytes, str]:
mime = header.split(";", 1)[0].replace("data:", "")
return base64.b64decode(encoded), mime
if not url:
raise ValueError("生图模型返回了成功响应,但没有图片地址或图片数据。")
diagnostic = json.dumps(safe_response_diagnostic(payload), ensure_ascii=False)
raise ValueError(f"平台返回体中没有可识别的图片结果。脱敏诊断:{diagnostic}")
async with httpx.AsyncClient(timeout=90, follow_redirects=True) as client:
response = await client.get(url)
response.raise_for_status()