From c04b415ebd74d9397449221148199952e122fe91 Mon Sep 17 00:00:00 2001 From: puke <1129090915@qq.com> Date: Wed, 17 Dec 2025 18:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81ComfyUI=20ApiKey=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.example.yaml | 1 + pixelle_video/config/manager.py | 4 +++- pixelle_video/service.py | 2 ++ web/components/settings.py | 23 +++++++++++++++++------ web/i18n/locales/en_US.json | 2 ++ web/i18n/locales/zh_CN.json | 2 ++ 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index 02e68be..5145aa9 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -21,6 +21,7 @@ llm: comfyui: # Global ComfyUI settings comfyui_url: http://127.0.0.1:8188 # ComfyUI server URL (required for selfhost workflows) + comfyui_api_key: "" # ComfyUI API key (optional, get from https://platform.comfy.org/profile/api-keys) # Note for Docker users: Use host.docker.internal:8188 (Mac/Windows) or host IP address (Linux) runninghub_api_key: "" # RunningHub API key (required for runninghub workflows) diff --git a/pixelle_video/config/manager.py b/pixelle_video/config/manager.py index 04374bb..df88523 100644 --- a/pixelle_video/config/manager.py +++ b/pixelle_video/config/manager.py @@ -144,13 +144,15 @@ class ConfigManager: def set_comfyui_config( self, - comfyui_url: Optional[str] = None, + comfyui_url: Optional[str] = None, + comfyui_api_key: Optional[str] = None, runninghub_api_key: Optional[str] = None ): """Set ComfyUI global configuration""" updates = {} if comfyui_url is not None: updates["comfyui_url"] = comfyui_url + updates["comfyui_api_key"] = comfyui_api_key updates["runninghub_api_key"] = runninghub_api_key if updates: diff --git a/pixelle_video/service.py b/pixelle_video/service.py index 6d2df90..453cc51 100644 --- a/pixelle_video/service.py +++ b/pixelle_video/service.py @@ -116,6 +116,8 @@ class PixelleVideoCore: if comfyui_config.get("comfyui_url"): kit_config["comfyui_url"] = comfyui_config["comfyui_url"] + if comfyui_config.get("comfyui_api_key"): + kit_config["api_key"] = comfyui_config["comfyui_api_key"] if comfyui_config.get("runninghub_api_key"): kit_config["runninghub_api_key"] = comfyui_config["runninghub_api_key"] diff --git a/web/components/settings.py b/web/components/settings.py index c2a6a74..bd0b012 100644 --- a/web/components/settings.py +++ b/web/components/settings.py @@ -134,12 +134,22 @@ def render_advanced_settings(): # Local/Self-hosted ComfyUI configuration st.markdown(f"**{tr('settings.comfyui.local_title')}**") - comfyui_url = st.text_input( - tr("settings.comfyui.comfyui_url"), - value=comfyui_config.get("comfyui_url", "http://127.0.0.1:8188"), - help=tr("settings.comfyui.comfyui_url_help"), - key="comfyui_url_input" - ) + url_col, key_col = st.columns(2) + with url_col: + comfyui_url = st.text_input( + tr("settings.comfyui.comfyui_url"), + value=comfyui_config.get("comfyui_url", "http://127.0.0.1:8188"), + help=tr("settings.comfyui.comfyui_url_help"), + key="comfyui_url_input" + ) + with key_col: + comfyui_api_key = st.text_input( + tr("settings.comfyui.comfyui_api_key"), + value=comfyui_config.get("comfyui_api_key", ""), + type="password", + help=tr("settings.comfyui.comfyui_api_key_help"), + key="comfyui_api_key_input" + ) # Test connection button if st.button(tr("btn.test_connection"), key="test_comfyui", use_container_width=True): @@ -186,6 +196,7 @@ def render_advanced_settings(): # Save ComfyUI configuration config_manager.set_comfyui_config( comfyui_url=comfyui_url if comfyui_url else None, + comfyui_api_key=comfyui_api_key if comfyui_api_key else None, runninghub_api_key=runninghub_api_key if runninghub_api_key else None ) diff --git a/web/i18n/locales/en_US.json b/web/i18n/locales/en_US.json index 9b5d051..5427925 100644 --- a/web/i18n/locales/en_US.json +++ b/web/i18n/locales/en_US.json @@ -187,6 +187,8 @@ "settings.comfyui.cloud_title": "RunningHub Cloud", "settings.comfyui.comfyui_url": "ComfyUI Server URL", "settings.comfyui.comfyui_url_help": "Local or remote ComfyUI server address", + "settings.comfyui.comfyui_api_key": "ComfyUI API Key", + "settings.comfyui.comfyui_api_key_help": "Optional, get from https://platform.comfy.org/profile/api-keys", "settings.comfyui.runninghub_api_key": "RunningHub API Key", "settings.comfyui.runninghub_api_key_help": "Visit https://runninghub.ai to register and get API Key", "settings.comfyui.runninghub_hint": "No local ComfyUI? Use RunningHub Cloud:", diff --git a/web/i18n/locales/zh_CN.json b/web/i18n/locales/zh_CN.json index b2d3a16..1ac2b86 100644 --- a/web/i18n/locales/zh_CN.json +++ b/web/i18n/locales/zh_CN.json @@ -187,6 +187,8 @@ "settings.comfyui.cloud_title": "RunningHub 云端", "settings.comfyui.comfyui_url": "ComfyUI 服务器地址", "settings.comfyui.comfyui_url_help": "本地或远程 ComfyUI 服务器地址", + "settings.comfyui.comfyui_api_key": "ComfyUI API 密钥", + "settings.comfyui.comfyui_api_key_help": "可选,访问 https://platform.comfy.org/profile/api-keys 获取", "settings.comfyui.runninghub_api_key": "RunningHub API 密钥", "settings.comfyui.runninghub_api_key_help": "访问 https://runninghub.ai 注册并获取 API Key", "settings.comfyui.runninghub_hint": "没有本地 ComfyUI?可用 RunningHub 云端:",