利用 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): match case-insensitive runtime provider IDs
Rudy Celekli0e26450e1dd0
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.pyindex 972e3454..30d58a3d 100644--- a/docs/skill/mpt_agent.py+++ b/docs/skill/mpt_agent.py@@ -262,7 +262,7 @@ def apply_environment_config(config_path: Path) -> None:returntext = config_path.read_text(encoding="utf-8")- current_provider = _plain_config_value(text, "llm_provider") or "moonshot"+ current_provider = (_plain_config_value(text, "llm_provider") or "moonshot").lower()provider = provider or current_providerchanges: list[str] = []if os.environ.get("MPT_LLM_PROVIDER", "").strip():@@ -332,7 +332,7 @@ def reuse_existing_llm_provider(config_path: Path) -> str:values are inspected in memory and are never logged."""text = config_path.read_text(encoding="utf-8")- current_provider = _plain_config_value(text, "llm_provider") or "moonshot"+ current_provider = (_plain_config_value(text, "llm_provider") or "moonshot").lower()if _provider_is_ready(text, current_provider):return current_provider@@ -368,7 +368,7 @@ def has_cli_option(cli_args: list[str], option: str) -> bool: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"+ 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(_plain_config_value(text, f"{provider}_api_key")diff --git a/test/services/test_skill_case_insensitive_llm_provider.py b/test/services/test_skill_case_insensitive_llm_provider.pynew file mode 100644index 00000000..1147669a--- /dev/null+++ b/test/services/test_skill_case_insensitive_llm_provider.py@@ -0,0 +1,33 @@+import importlib.util+import tomllib+from pathlib import Path+from unittest.mock import patch++from app.models.llm_provider import get_llm_provider+++spec = importlib.util.spec_from_file_location("mpt_provider_case_fixture", Path(__file__).parents[2] / "docs" / "skill" / "mpt_agent.py")+helper = importlib.util.module_from_spec(spec)+spec.loader.exec_module(helper)+++def test_uppercase_keyless_provider_matches_runtime_registry(tmp_path):+ assert get_llm_provider("OLLAMA").requires_api_key is False+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "OLLAMA"\n', encoding="utf-8")+ assert helper.missing_config(config, ["--video-source=local", "--video-materials=owned.mp4"]) == ("ollama", [])+++def test_uppercase_current_provider_is_retained_before_other_configured_provider(tmp_path):+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "DEEPSEEK"\ndeepseek_api_key = "chosen-fixture"\nmoonshot_api_key = "other-fixture"\n', encoding="utf-8")+ assert helper.reuse_existing_llm_provider(config) == "deepseek"+ assert tomllib.loads(config.read_text(encoding="utf-8"))["app"]["llm_provider"] == "DEEPSEEK"+++def test_environment_key_uses_existing_lowercase_provider_field(tmp_path):+ config = tmp_path / "config.toml"+ config.write_text('[app]\nllm_provider = "OPENAI"\nopenai_api_key = ""\n', encoding="utf-8")+ with patch.dict(helper.os.environ, {"MPT_LLM_API_KEY": "new-fixture"}, clear=True):+ helper.apply_environment_config(config)+ assert tomllib.loads(config.read_text(encoding="utf-8"))["app"]["openai_api_key"] == "new-fixture"