利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix: update gemini defaults and legacy fallback
Harry6bfbc282ae6a
diff --git a/app/services/llm.py b/app/services/llm.pyindex 9e3c698e..047ae891 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -12,6 +12,8 @@ from openai.types.chat import ChatCompletionfrom app.config import config_max_retries = 5+_DEFAULT_GEMINI_MODEL = "gemini-2.5-flash"+_DEPRECATED_GEMINI_MODELS = {"gemini-pro", "gemini-1.0-pro"}def _normalize_text_response(content, llm_provider: str) -> str:@@ -78,6 +80,15 @@ def _generate_response(prompt: str) -> str:api_key = config.app.get("gemini_api_key")model_name = config.app.get("gemini_model_name")base_url = config.app.get("gemini_base_url", "")+ # Gemini 旧模型名已经陆续下线,这里自动兼容历史配置,+ # 避免用户沿用旧值时直接收到 404。+ if not model_name:+ model_name = _DEFAULT_GEMINI_MODEL+ elif model_name in _DEPRECATED_GEMINI_MODELS:+ logger.warning(+ f"gemini model '{model_name}' is deprecated, fallback to '{_DEFAULT_GEMINI_MODEL}'"+ )+ model_name = _DEFAULT_GEMINI_MODELelif llm_provider == "qwen":api_key = config.app.get("qwen_api_key")model_name = config.app.get("qwen_model_name")@@ -165,7 +176,7 @@ def _generate_response(prompt: str) -> str:raise ValueError(f"{llm_provider}: model_name is not set, please set it in the config.toml file.")- if not base_url:+ if not base_url and llm_provider not in ["gemini"]:raise ValueError(f"{llm_provider}: base_url is not set, please set it in the config.toml file.")diff --git a/config.example.toml b/config.example.tomlindex 2cf5a35e..58992880 100644--- a/config.example.toml+++ b/config.example.toml@@ -84,7 +84,7 @@ azure_api_version = "2024-02-15-preview"########## Gemini API Keygemini_api_key = ""-gemini_model_name = "gemini-1.0-pro"+gemini_model_name = "gemini-2.5-flash"########## Qwen API Key# Visit https://dashscope.console.aliyun.com/apiKey to get your API key