Archived
feat: make CivitAI and ComfyUI server URLs configurable via environment variables
This commit is contained in:
1 parent
bea3ff3120
commit
a886e2d327
4 files changed
+42
-12
No files matched your search
+29
-7
@@ -2,9 +2,14 @@
|
||||
Basic SDXL Text to Image workflow.
|
||||
Schema is defined in basic_sdxl.yaml (auto-generated from WorkflowParams).
|
||||
"""
|
||||
import os
|
||||
import comfy_script.runtime as runtime
|
||||
from comfy_script.runtime import *
|
||||
from comfy_script.runtime import _client_id
|
||||
load('http://127.0.0.1:8188/')
|
||||
|
||||
# ComfyUI server URL - configurable via environment variable
|
||||
COMFYUI_SERVER_URL = os.environ.get('COMFYUI_SERVER_URL', 'http://127.0.0.1:8188/')
|
||||
load(COMFYUI_SERVER_URL)
|
||||
|
||||
from comfy_script.runtime.nodes import *
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
@@ -273,22 +278,39 @@ class SDXLWorkflow(BaseWorkflow):
|
||||
def run_workflow(**kwargs):
|
||||
"""
|
||||
Entry point for the workflow.
|
||||
|
||||
|
||||
Special kwargs (not passed to WorkflowParams):
|
||||
save_mode: "disk" | "temporary" | "stream" - how to save output images
|
||||
params_raw: dict - original parameters from frontend (for PNG metadata/recall)
|
||||
client_id: str - custom client_id for WebSocket events (optional)
|
||||
"""
|
||||
# Extract special parameters before creating WorkflowParams
|
||||
save_mode = kwargs.pop('save_mode', 'disk')
|
||||
params_raw = kwargs.pop('params_raw', None)
|
||||
|
||||
custom_client_id = kwargs.pop('client_id', None)
|
||||
|
||||
required = ['prompt', 'checkpoints', 'seed', 'steps', 'negativePrompt', 'dimensions', 'cfg']
|
||||
missing = [f for f in required if f not in kwargs]
|
||||
if missing:
|
||||
raise ValueError(f"Missing required fields: {', '.join(missing)}")
|
||||
|
||||
|
||||
params = WorkflowParams(**kwargs)
|
||||
|
||||
|
||||
# Create and run workflow with save settings
|
||||
workflow = SDXLWorkflow(params, params_raw=params_raw, save_mode=save_mode)
|
||||
return workflow.run()
|
||||
|
||||
# If custom client_id provided, temporarily override comfy_script's client_id
|
||||
original_client_id = getattr(runtime, '_client_id', None)
|
||||
if custom_client_id and original_client_id:
|
||||
runtime._client_id = custom_client_id
|
||||
|
||||
try:
|
||||
result = workflow.run()
|
||||
# Use custom client_id in response if provided
|
||||
if custom_client_id:
|
||||
result['client_id'] = custom_client_id
|
||||
return result
|
||||
finally:
|
||||
# Restore original client_id
|
||||
if custom_client_id and original_client_id:
|
||||
runtime._client_id = original_client_id
|
||||
Reference in new issue
Block a user