From 5f575aabda93f16d752b4bcdb264f39bf9b447e1 Mon Sep 17 00:00:00 2001 From: Sirshendu Ganguly Date: Thu, 9 Oct 2025 22:17:12 -0400 Subject: [PATCH] Feature: Add OpenAI video models and improve error handling - Added OpenAI Sora 3.0 and 3.1 models to video inference (openai:3@0, openai:3@1) - Added OpenAI architecture to video model search dropdown - Improved video inference error handling to properly display API error messages - Replaced hardcoded seed support with flexible useSeed parameter in video inference - Added selectable output format (WEBP, PNG, JPEG, SVG) to image inference UI - Updated parameter order: useSeed, seed for better UX consistency - Removed SEED_SUPPORTED_MODELS hardcoded list for better flexibility --- modules/imageInference.py | 7 ++++++- modules/videoInference.py | 28 +++++++++++++++++++++------- modules/videoModelSearch.py | 16 ++++++++++------ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/imageInference.py b/modules/imageInference.py index 89b49b4..b07d2f5 100644 --- a/modules/imageInference.py +++ b/modules/imageInference.py @@ -121,6 +121,10 @@ class txt2img: "min": 32, "max": 128, }), + "outputFormat": (["WEBP", "PNG", "JPEG", "SVG"], { + "tooltip": "Choose the output image format.", + "default": "WEBP", + }), "batchSize": ("INT", { "tooltip": "The number of images to generate in a single request.", "default": 1, @@ -218,6 +222,7 @@ class txt2img: useSeed = kwargs.get("useSeed", True) useClipSkip = kwargs.get("useClipSkip", True) dimensions = kwargs.get("dimensions", "Square (512x512)") + outputFormat = kwargs.get("outputFormat", "WEBP") batchSize = kwargs.get("batchSize", 1) if (maskImage is not None and seedImage is None): @@ -230,7 +235,7 @@ class txt2img: "positivePrompt": positivePrompt, "model": runwareModel, "outputType": "base64Data", - "outputFormat": rwUtils.OUTPUT_FORMAT, + "outputFormat": outputFormat, "outputQuality": rwUtils.OUTPUT_QUALITY, "numberResults": batchSize, } diff --git a/modules/videoInference.py b/modules/videoInference.py index 70e8cd7..5979e8f 100644 --- a/modules/videoInference.py +++ b/modules/videoInference.py @@ -144,10 +144,14 @@ class txt2vid: "default": "mp4", "tooltip": "Choose the output video format.", }), + "useSeed": ("BOOLEAN", { + "tooltip": "Enable to include seed parameter in API request. Disable if your model doesn't support seed.", + "default": True, + }), "seed": ("INT", { - "tooltip": "A value used to randomize the video generation. If you want to make videos reproducible (generate the same video multiple times), you can use the same seed value. Leave empty or 0 to auto-generate. Note: Only supported by Wan models.", - "default": 0, - "min": 0, + "tooltip": "A value used to randomize the video generation. If you want to make videos reproducible (generate the same video multiple times), you can use the same seed value. Leave empty or 0 to auto-generate.", + "default": 1, + "min": 1, "max": 9223372036854776000, }), "batchSize": ("INT", { @@ -208,6 +212,7 @@ class txt2vid: outputFormat = kwargs.get("outputFormat", "mp4") batchSize = kwargs.get("batchSize", 1) seed = kwargs.get("seed", 1) + useSeed = kwargs.get("useSeed", True) # Handle model input - could be dict or string if isinstance(runwareVideoModel, dict): @@ -247,9 +252,9 @@ class txt2vid: # Add duration parameter - unified for all models genConfig[0]["duration"] = duration - # Add seed parameter only for supported models + # Add seed parameter only if enabled - if model in videoModelSearch.SEED_SUPPORTED_MODELS: + if useSeed: genConfig[0]["seed"] = seed if (negativePrompt is not None and negativePrompt != ""): @@ -341,11 +346,20 @@ class txt2vid: # Extract more detailed error info if available if "responseContent" in error_info: response_content = error_info["responseContent"] - detailed_message = response_content.get("message", "") + # Handle both string and dict response content + if isinstance(response_content, str): + detailed_message = response_content + elif isinstance(response_content, dict): + detailed_message = response_content.get("message", str(response_content)) + else: + detailed_message = str(response_content) + if detailed_message: error_message = f"{error_message}\nProvider Error: {detailed_message}" - raise Exception(f"Video generation failed: {error_message}") + # Include taskUUID for debugging + task_uuid = error_info.get("taskUUID", "unknown") + raise Exception(f"Video generation failed (Task: {task_uuid}): {error_message}") if pollResult and "data" in pollResult and len(pollResult["data"]) > 0: video_data = pollResult["data"][0] diff --git a/modules/videoModelSearch.py b/modules/videoModelSearch.py index 1934319..e44d4ae 100644 --- a/modules/videoModelSearch.py +++ b/modules/videoModelSearch.py @@ -43,6 +43,10 @@ class videoModelSearch: "runware:200@1 (Wan 2.1 1.3B)", "runware:200@2 (Wan 2.1 14B)", ], + "OpenAI": [ + "openai:3@1 (OpenAI Sora 3.1)", + "openai:3@0 (OpenAI Sora 3.0)", + ], } # Model dimensions mapping @@ -88,13 +92,12 @@ class videoModelSearch: # Wan Models "runware:200@1": {"width": 853, "height": 480}, # Wan 2.1 1.3B "runware:200@2": {"width": 853, "height": 480}, # Wan 2.1 14B + + # OpenAI Models + "openai:3@1": {"width": 1280, "height": 720}, # OpenAI Sora 3.1 + "openai:3@0": {"width": 1280, "height": 720}, # OpenAI Sora 3.0 } - # Models that support seed parameter - SEED_SUPPORTED_MODELS = [ - "runware:200@1", # Wan 2.1 1.3B - "runware:200@2", # Wan 2.1 14B - ] @classmethod def INPUT_TYPES(cls): @@ -116,7 +119,8 @@ class videoModelSearch: "MiniMax", "PixVerse", "Vidu", - "Wan" + "Wan", + "OpenAI" ], { "tooltip": "Choose Video Model Architecture To Filter Results.", "default": "KlingAI",