Fixed Comfyui-zhenzhen
Complete Fix Explanation
File: `D:\USERFILES\ComfyUI\ComfyUI\custom_nodes\Comfyui-zhenzhen\Comfly.py`
Problem Description
The `Comfly_sora2` class was throwing a `NameError: name 'baseurl' is not defined` when attempting to generate videos. The error occurred at lines 6114 and 6127 where the code tried to use the `baseurl` variable:
endpoint = f"{baseurl}/v2/videos/generations"Root Cause
The `baseurl` variable is defined as a global variable in the `Comfly_api_set` class (line 76), but the `Comfly_sora2` class's `process` method did not properly reference this global variable. If users didn't use the `Comfly_api_set` node first to initialize `baseurl`, the variable would be undefined, causing the error.
Solution Applied
Added global variable handling at the beginning of the `process` method in the `Comfly_sora2` class:
Modified Section (lines 6056-6061):
def process(self, prompt, model, aspect_ratio="16:9", duration="10", hd=False, apikey="",
image1=None, image2=None, image3=None, image4=None, seed=0):
global baseurl
if 'baseurl' not in globals() or not baseurl:
baseurl = "https://ai.t8star.cn"Key Changes
Line 6058: Added `global baseurl` declaration to access the global variable
Lines 6060-6061: Added a safety check that initializes `baseurl` with the default value `"https://ai.t8star.cn"` if it's not defined or empty
Why This Default URL?
According to the project's GitHub repository (https://github.com/T8mars/Comfyui-zhenzhen), this extension uses a custom API relay service at `https://ai.t8star.cn`, not the official OpenAI API. The `Comfly_api_set` class defines four possible base URLs:
"zhenzhen": `https://ai.t8star.cn` (default)
"hk": `https://hk-api.gptbest.vip`
"us": `https://api.gptbest.vip`
"ip": Custom IP address
Result
Now the `Comfly_sora2` node can work independently without requiring users to first run the `Comfly_api_set` node. If `baseurl` hasn't been set, it automatically defaults to the project's primary API endpoint (`https://ai.t8star.cn`).
...
Even after National Day, we are able to generate Sora2 at 0.13 yuan per generation. It's so bargain. However, I'm not sure that how long it will remain available at that price.
