AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
fix(image-gen): handle documented image_urls response shape in MiniMax backend
octo-patch53c2b2c3d3d8
diff --git a/skills/ppt-master/scripts/image_backends/backend_minimax.py b/skills/ppt-master/scripts/image_backends/backend_minimax.pyindex 6a3fd2f2..1c64848e 100644--- a/skills/ppt-master/scripts/image_backends/backend_minimax.py+++ b/skills/ppt-master/scripts/image_backends/backend_minimax.py@@ -33,6 +33,7 @@ import requestsfrom image_backends.backend_common import (MAX_RETRIES,detect_image_extension,+ download_image,http_error,is_rate_limit_error,normalize_image_size,@@ -47,6 +48,11 @@ DEFAULT_ENDPOINT = "https://api.minimaxi.com/v1/image_generation"DEFAULT_MODEL = "image-01"SUPPORTED_MODELS = {DEFAULT_MODEL}+# Request the documented default response format. The API returns hosted links+# in `data.image_urls` for "url" and inline strings in `data.image_base64` for+# "base64"; both shapes are handled when the response is parsed.+DEFAULT_RESPONSE_FORMAT = "url"+# International fallback: set MINIMAX_BASE_URL=https://api.minimax.io if neededASPECT_RATIO_SIZE_MAP = {@@ -130,7 +136,7 @@ def _resolve_dimensions(aspect_ratio: str, image_size: str) -> tuple[int, int]:def _extract_image_bytes(payload: dict) -> bytes | None:- """Extract image bytes from a MiniMax response payload."""+ """Extract inline base64 image bytes from a MiniMax response payload."""data = payload.get("data") or {}image_base64 = data.get("image_base64") or []if image_base64:@@ -138,6 +144,15 @@ def _extract_image_bytes(payload: dict) -> bytes | None:return None+def _extract_image_url(payload: dict) -> str | None:+ """Extract the first hosted image URL from a MiniMax response payload."""+ data = payload.get("data") or {}+ image_urls = data.get("image_urls") or []+ if image_urls:+ return image_urls[0]+ return None++def _generate_image(api_key: str, prompt: str,aspect_ratio: str = "1:1", image_size: str = "1K",output_dir: str = None, filename: str = None,@@ -156,7 +171,7 @@ def _generate_image(api_key: str, prompt: str,"prompt": prompt,"width": width,"height": height,- "response_format": "base64",+ "response_format": DEFAULT_RESPONSE_FORMAT,"n": 1,}@@ -181,12 +196,19 @@ def _generate_image(api_key: str, prompt: str,raise RuntimeError(f"MiniMax image generation failed: {data}")image_bytes = _extract_image_bytes(data)- if not image_bytes:- raise RuntimeError(f"MiniMax response missing image data: {data}")-- ext = detect_image_extension(image_bytes) or ".jpeg"- path = resolve_output_path(prompt, output_dir, filename, ext)- return save_image_bytes(image_bytes, path)+ if image_bytes:+ ext = detect_image_extension(image_bytes) or ".jpeg"+ path = resolve_output_path(prompt, output_dir, filename, ext)+ return save_image_bytes(image_bytes, path)++ image_url = _extract_image_url(data)+ if image_url:+ # image-01 serves JPEG; save_image_bytes realigns the extension when the+ # downloaded bytes are a different format.+ path = resolve_output_path(prompt, output_dir, filename, ".jpeg")+ return download_image(image_url, path)++ raise RuntimeError(f"MiniMax response missing image data: {data}")def generate(prompt: str,