利用 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
Upgrade MiniMax default model
harry0703dd36f6f029f0
diff --git a/app/services/llm.py b/app/services/llm.pyindex 60a56657..dda9561f 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -17,6 +17,8 @@ MIN_SCRIPT_PARAGRAPH_NUMBER = 1MAX_SCRIPT_PARAGRAPH_NUMBER = 10MAX_SCRIPT_PROMPT_LENGTH = 2000MAX_SCRIPT_SYSTEM_PROMPT_LENGTH = 8000+_THINK_BLOCK_RE = re.compile(r"<think\b[^>]*>.*?</think>", re.IGNORECASE | re.DOTALL)+_UNCLOSED_THINK_BLOCK_RE = re.compile(r"<think\b[^>]*>.*$", re.IGNORECASE | re.DOTALL)DEFAULT_SCRIPT_SYSTEM_PROMPT = """# Role: Video Script Generator@@ -48,7 +50,11 @@ def _normalize_text_response(content, llm_provider: str) -> str:f"[{llm_provider}] returned non-text content: {type(content).__name__}")- content = content.strip()+ # MiniMax M3、DeepSeek R1 这类 reasoning 模型可能会把内部推理包在+ # `<think>...</think>` 中返回。视频脚本和关键词只需要最终可朗读文本,+ # 如果不在服务层统一清理,WebUI、字幕和配音都会把思考过程当正文处理。+ content = _THINK_BLOCK_RE.sub("", content)+ content = _UNCLOSED_THINK_BLOCK_RE.sub("", content).strip()if not content:raise ValueError(f"[{llm_provider}] returned empty text content")diff --git a/config.example.toml b/config.example.tomlindex 4883d995..5d0d2faf 100644--- a/config.example.toml+++ b/config.example.toml@@ -132,12 +132,13 @@ qwen_model_name = "qwen-max"########## MiniMax API Key-# Visit https://platform.minimax.io to get your API key+# Visit https://platform.minimax.io or https://platform.minimaxi.com to get your API key# MiniMax API is OpenAI-compatible-# Available models: MiniMax-M2.7 (default), MiniMax-M2.7-highspeed+# Available models: MiniMax-M3 (default), MiniMax-M2.7, MiniMax-M2.7-highspeed+# If your API key returns 401 on api.minimax.io, try the China endpoint: https://api.minimaxi.com/v1minimax_api_key = ""minimax_base_url = "https://api.minimax.io/v1"-minimax_model_name = "MiniMax-M2.7"+minimax_model_name = "MiniMax-M3"########## Xiaomi MiMo API Key# Xiaomi MiMo API is OpenAI-compatible.diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex 1332abff..2c2a3e95 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -16,6 +16,33 @@ from app.services import llmclass TestScriptPromptOptions(unittest.TestCase):+ def test_normalize_text_response_removes_think_blocks(self):+ """+ reasoning 模型可能返回 `<think>...</think>`。脚本生成链路必须只保留+ 最终正文,避免思考过程进入字幕和配音。+ """+ result = llm._normalize_text_response(+ "<think>\nI should reason here.\n</think>\n测试成功",+ "minimax",+ )++ self.assertEqual(result, "测试成功")++ def test_normalize_text_response_rejects_think_only_response(self):+ """+ 如果模型只返回思考块而没有最终答案,应视为空内容,触发重试或明确错误。+ """+ with self.assertRaises(ValueError):+ llm._normalize_text_response("<think>hidden reasoning</think>", "minimax")++ def test_normalize_text_response_removes_unclosed_think_block(self):+ """+ 某些网关可能因为截断只返回未闭合的 `<think>`。这种内容同样不能+ 进入最终脚本;如果清理后没有正文,就应该按空响应处理。+ """+ with self.assertRaises(ValueError):+ llm._normalize_text_response("<think>hidden reasoning", "minimax")+def test_build_script_prompt_appends_advanced_requirements(self):"""高级文案要求只作为附加约束,不替换默认系统提示词。