利用 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): support the openai_image material source in the agent helper
c020627bd647b5f4cff
diff --git a/docs/skill/mpt_agent.py b/docs/skill/mpt_agent.pyindex ef195030..a3e1502c 100644--- a/docs/skill/mpt_agent.py+++ b/docs/skill/mpt_agent.py@@ -32,6 +32,9 @@ SUPPORTED_SOURCES = {"volcengine_seedance","ofox","metaso_minimax",+ # Keep this list aligned with ``_CLI_VIDEO_SOURCES`` in cli.py. A source that+ # the CLI accepts must not be rejected here as unsupported.+ "openai_image","local",}VOLCENGINE_ARK_API_KEY_URL = (@@ -382,6 +385,13 @@ def missing_config(config_path: Path, cli_args: list[str]) -> tuple[str, list[stmissing.append("metaso_minimax_api_key")if not has_cli_option(cli_args, "--confirm-metaso-minimax-charge"):missing.append("confirm_metaso_minimax_charge")+ elif source == "openai_image":+ # 与运行时的 is_openai_image_enabled() 保持一致:文生图素材源只要求端点+ # 与模型名。完全本地的 ComfyUI/SD 网关允许不配置 API Key,因此这里不+ # 能把 openai_image_api_keys 当作必填项。+ for field in ("openai_image_base_url", "openai_image_model"):+ if not _has_configured_value(_plain_config_value(text, field)):+ missing.append(field)elif source != "local":value = _plain_config_value(text, f"{source}_api_keys")if not _has_configured_value(value):@@ -417,6 +427,12 @@ def report_missing_config(provider: str, missing: list[str]) -> int:"OPENAI_COMPATIBLE_REQUIRED=""API key, API base URL, model name")+ if any(field.startswith("openai_image_") for field in missing):+ print(+ "OPENAI_IMAGE_REQUIRED="+ "openai_image_base_url, openai_image_model (the API key is optional "+ "for local gateways)"+ )if "pexels_api_keys" in missing:print(f"PEXELS_API_KEY_URL={PEXELS_API_KEY_URL}")print(f"PEXELS_API_KEY_HELP_URL={PEXELS_API_KEY_HELP_URL}")diff --git a/test/services/test_mpt_agent_skill.py b/test/services/test_mpt_agent_skill.pyindex 7292eccb..e174e6fa 100644--- a/test/services/test_mpt_agent_skill.py+++ b/test/services/test_mpt_agent_skill.py@@ -31,6 +31,9 @@ coverr_api_keys = []volcengine_seedance_api_key = ""ofox_api_key = ""metaso_minimax_api_key = ""+openai_image_base_url = ""+openai_image_model = ""+openai_image_api_keys = []oneapi_api_key = ""oneapi_base_url = ""oneapi_model_name = ""@@ -148,6 +151,55 @@ class TestMptAgentSkill(unittest.TestCase):self.assertEqual(default_missing, ["pexels_api_keys"])self.assertEqual(pixabay_missing, [])+ def test_openai_image_source_accepts_keyless_local_gateway(self):+ """文生图素材源只需要端点与模型名,本地网关允许不配置 API Key。"""+ with tempfile.TemporaryDirectory() as temp_dir:+ config_path = Path(temp_dir) / "config.toml"+ config_path.write_text(+ MINIMAL_CONFIG.replace(+ 'moonshot_api_key = ""', 'moonshot_api_key = "configured"'+ )+ .replace(+ 'openai_image_base_url = ""',+ 'openai_image_base_url = "http://127.0.0.1:7860/v1"',+ )+ .replace(+ 'openai_image_model = ""', 'openai_image_model = "local-sd"'+ ),+ encoding="utf-8",+ )++ _, missing = mpt_agent.missing_config(+ config_path, ["--video-source", "openai_image"]+ )++ self.assertEqual(missing, [])++ def test_missing_openai_image_inputs_report_endpoint_and_model(self):+ """端点或模型名缺失时必须回报字段名,且不能把可选的 Key 当作缺失。"""+ with tempfile.TemporaryDirectory() as temp_dir:+ config_path = Path(temp_dir) / "config.toml"+ config_path.write_text(+ MINIMAL_CONFIG.replace(+ 'moonshot_api_key = ""', 'moonshot_api_key = "configured"'+ ),+ encoding="utf-8",+ )++ _, missing = mpt_agent.missing_config(+ config_path, ["--video-source", "openai_image"]+ )+ output = io.StringIO()+ with redirect_stdout(output):+ code = mpt_agent.report_missing_config("moonshot", missing)++ self.assertEqual(+ missing, ["openai_image_base_url", "openai_image_model"]+ )+ self.assertEqual(code, mpt_agent.NEEDS_INPUT_EXIT_CODE)+ self.assertIn("OPENAI_IMAGE_REQUIRED=", output.getvalue())+ self.assertNotIn("LLM_PROVIDER_OPTIONS_BEGIN", output.getvalue())+def test_ofox_source_requires_key_and_explicit_charge_confirmation(self):with tempfile.TemporaryDirectory() as temp_dir:config_path = Path(temp_dir) / "config.toml"