利用 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(skill): skip LLM preflight for prepared narration and visuals
Rudy Celeklidc4abd2d3844
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.pyindex 6b9deacc..0ec102e0 100644--- a/docs/skill/mpt_agent.py+++ b/docs/skill/mpt_agent.py@@ -377,19 +377,38 @@ def has_cli_option(cli_args: list[str], option: str) -> bool:return any(item == option or item.startswith(f"{option}=") for item in cli_args)+def _last_cli_value(cli_args: list[str], option: str) -> str:+ value = ""+ for index, item in enumerate(cli_args):+ if item == option and index + 1 < len(cli_args):+ value = cli_args[index + 1]+ elif item.startswith(f"{option}="):+ value = item.split("=", 1)[1]+ return value.strip()+++def _requires_llm(cli_args: list[str]) -> bool:+ # Match task.generate_script and the local-material terms bypass.+ return not _last_cli_value(cli_args, "--video-script") or (+ selected_video_source(cli_args) != "local"+ and not _last_cli_value(cli_args, "--video-terms")+ )++def missing_config(config_path: Path, cli_args: list[str]) -> tuple[str, list[str]]:"""Return the active provider and only the fields required by this run."""text = config_path.read_text(encoding="utf-8")provider = (_plain_config_value(text, "llm_provider") or "moonshot").lower()missing: list[str] = []- if provider not in KEYLESS_LLM_PROVIDERS and not _has_configured_value(+ needs_llm = _requires_llm(cli_args)+ if needs_llm and provider not in KEYLESS_LLM_PROVIDERS and not _has_configured_value(_plain_config_value(text, f"{provider}_api_key")):missing.append(f"{provider}_api_key")- if provider == "kimi_code" and not _provider_is_ready(text, provider):+ if needs_llm and provider == "kimi_code" and not _provider_is_ready(text, provider):# 无 Key 可填,缺失的是 WebUI 登录动作而不是配置字段。missing.append("kimi_code_sign_in")- if provider == CUSTOM_OPENAI_PROVIDER:+ if needs_llm and provider == CUSTOM_OPENAI_PROVIDER:for suffix in ("base_url", "model_name"):field = f"{provider}_{suffix}"if not _has_configured_value(_plain_config_value(text, field)):diff --git a/test/services/test_skill_prepared_script_preflight.py b/test/services/test_skill_prepared_script_preflight.pynew file mode 100644index 00000000..add46a16--- /dev/null+++ b/test/services/test_skill_prepared_script_preflight.py@@ -0,0 +1,33 @@+import importlib.util+from pathlib import Path++import pytest+++spec = importlib.util.spec_from_file_location("mpt_prepared_script_fixture", Path(__file__).parents[2] / "docs" / "skill" / "mpt_agent.py")+helper = importlib.util.module_from_spec(spec)+spec.loader.exec_module(helper)++[email protected]("forwarded", [+ ["--video-script", "Prepared narration", "--video-source", "local", "--video-materials", "./owned.mp4"],+ ["--video-script=Prepared narration", "--video-source=local", "--video-materials=./owned.mp4"],+ ["--video-script", "Prepared narration", "--video-terms", "ocean waves", "--video-source", "pexels"],+])+def test_prepared_script_and_visuals_need_no_llm_credentials(tmp_path, forwarded):+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "moonshot"\nmoonshot_api_key = ""\npexels_api_keys = ["fixture"]\n', encoding="utf-8")+ assert helper.missing_config(config, forwarded) == ("moonshot", [])+++def test_stock_materials_without_terms_still_need_llm(tmp_path):+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "moonshot"\nmoonshot_api_key = ""\npexels_api_keys = ["fixture"]\n', encoding="utf-8")+ assert helper.missing_config(config, ["--video-script", "Prepared narration"])[1] == ["moonshot_api_key"]+++def test_last_empty_script_option_requires_generation_again(tmp_path):+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "moonshot"\nmoonshot_api_key = ""\n', encoding="utf-8")+ forwarded = ["--video-script", "Prepared narration", "--video-script=", "--video-source=local", "--video-materials=./owned.mp4"]+ assert helper.missing_config(config, forwarded)[1] == ["moonshot_api_key"]