优化llm配置的保存逻辑
This commit is contained in:
@@ -189,22 +189,24 @@ def render_advanced_settings():
|
||||
with col1:
|
||||
if st.button(tr("btn.save_config"), use_container_width=True, key="save_config_btn"):
|
||||
try:
|
||||
# Save LLM configuration
|
||||
if llm_api_key and llm_base_url and llm_model:
|
||||
# Validate and save LLM configuration
|
||||
if not (llm_api_key and llm_base_url and llm_model):
|
||||
st.error(tr("status.llm_config_incomplete"))
|
||||
else:
|
||||
config_manager.set_llm_config(llm_api_key, llm_base_url, llm_model)
|
||||
|
||||
# Save ComfyUI configuration
|
||||
# Save ComfyUI configuration (optional fields, always save what's provided)
|
||||
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
|
||||
)
|
||||
|
||||
# Save to file
|
||||
config_manager.save()
|
||||
|
||||
st.success(tr("status.config_saved"))
|
||||
safe_rerun()
|
||||
# Only save to file if LLM config is valid
|
||||
if llm_api_key and llm_base_url and llm_model:
|
||||
config_manager.save()
|
||||
st.success(tr("status.config_saved"))
|
||||
safe_rerun()
|
||||
except Exception as e:
|
||||
st.error(f"{tr('status.save_failed')}: {str(e)}")
|
||||
|
||||
|
||||
@@ -139,8 +139,10 @@
|
||||
"status.video_generated": "✅ Video generated: {path}",
|
||||
"status.video_not_found": "Video file not found: {path}",
|
||||
"status.config_saved": "✅ Configuration saved",
|
||||
"status.config_reset": "✅ Configuration reset to default",
|
||||
"status.connection_success": "✅ Connected",
|
||||
"status.config_reset": "✅ Configuration reset to defaults",
|
||||
"status.llm_config_incomplete": "⚠️ LLM configuration incomplete, please fill in API Key, Base URL and Model",
|
||||
"status.save_failed": "Save failed",
|
||||
"status.connection_success": "✅ Connection successful",
|
||||
"status.connection_failed": "❌ Connection failed",
|
||||
"progress.generating_title": "Generating title...",
|
||||
"progress.generating_narrations": "Generating narrations...",
|
||||
|
||||
@@ -140,6 +140,8 @@
|
||||
"status.video_not_found": "视频文件未找到:{path}",
|
||||
"status.config_saved": "✅ 配置已保存",
|
||||
"status.config_reset": "✅ 配置已重置为默认值",
|
||||
"status.llm_config_incomplete": "⚠️ LLM 配置不完整,请填写 API Key、Base URL 和 Model",
|
||||
"status.save_failed": "保存失败",
|
||||
"status.connection_success": "✅ 连接成功",
|
||||
"status.connection_failed": "❌ 连接失败",
|
||||
"progress.generating_title": "生成标题...",
|
||||
|
||||
Reference in New Issue
Block a user