优化ComfyKit实例管理逻辑, 提升调用runninghub时的稳定性
This commit is contained in:
@@ -51,14 +51,15 @@ class TTSService(ComfyBaseService):
|
||||
DEFAULT_WORKFLOW = None # No hardcoded default, must be configured
|
||||
WORKFLOWS_DIR = "workflows"
|
||||
|
||||
def __init__(self, config: dict):
|
||||
def __init__(self, config: dict, core=None):
|
||||
"""
|
||||
Initialize TTS service
|
||||
|
||||
Args:
|
||||
config: Full application config dict
|
||||
core: PixelleVideoCore instance (for accessing shared ComfyKit)
|
||||
"""
|
||||
super().__init__(config, service_name="tts")
|
||||
super().__init__(config, service_name="tts", core=core)
|
||||
|
||||
|
||||
async def __call__(
|
||||
@@ -222,13 +223,7 @@ class TTSService(ComfyBaseService):
|
||||
"""
|
||||
logger.info(f"🎙️ Using workflow: {workflow_info['key']}")
|
||||
|
||||
# 1. Prepare ComfyKit config (supports both selfhost and runninghub)
|
||||
kit_config = self._prepare_comfykit_config(
|
||||
comfyui_url=comfyui_url,
|
||||
runninghub_api_key=runninghub_api_key
|
||||
)
|
||||
|
||||
# 2. Build workflow parameters
|
||||
# 1. Build workflow parameters (ComfyKit config is now managed by core)
|
||||
workflow_params = {"text": text}
|
||||
|
||||
# Add optional TTS parameters (only if explicitly provided and not None)
|
||||
@@ -242,9 +237,10 @@ class TTSService(ComfyBaseService):
|
||||
|
||||
logger.debug(f"Workflow parameters: {workflow_params}")
|
||||
|
||||
# 3. Execute workflow (ComfyKit auto-detects based on input type)
|
||||
# 3. Execute workflow using shared ComfyKit instance from core
|
||||
try:
|
||||
kit = ComfyKit(**kit_config)
|
||||
# Get shared ComfyKit instance (lazy initialization + config hot-reload)
|
||||
kit = await self.core._get_or_create_comfykit()
|
||||
|
||||
# Determine what to pass to ComfyKit based on source
|
||||
if workflow_info["source"] == "runninghub" and "workflow_id" in workflow_info:
|
||||
|
||||
Reference in New Issue
Block a user