利用 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(llm): send Claude Code prompt through stdin
Tan Phamd7b738345e22
diff --git a/app/services/llm.py b/app/services/llm.pyindex 827d1f39..6ec12a84 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -493,10 +493,12 @@ def _generate_response(prompt: str, app_config=None) -> str:except ValueError as timeout_error:raise ValueError(f"{llm_provider}: {timeout_error}") from None+ # prompt 通过 stdin 传入,不放在命令行里:Windows 上 npm 安装的+ # claude 是 claude.cmd,cmd.exe 会在第一个换行处截断参数,多行+ # prompt 和其后的隔离参数都会丢失。command = [cli_path,"-p",- prompt,"--output-format","json","--system-prompt",@@ -528,6 +530,7 @@ def _generate_response(prompt: str, app_config=None) -> str:try:completed = subprocess.run(command,+ input=prompt,capture_output=True,text=True,# The CLI always emits UTF-8. Without an explicit encoding,diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex 18f05c9f..786b3371 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -1794,6 +1794,25 @@ class TestClaudeCodeProvider(unittest.TestCase):llm.CLAUDE_CODE_SYSTEM_PROMPT,)+ def test_prompt_is_sent_through_stdin_not_argv(self):+ """Windows 上 npm 安装的 claude 是 claude.cmd,cmd.exe 会在第一个换行处截断+ 参数,多行 prompt 及其后的隔离参数都会丢失,因此 prompt 必须走 stdin。"""+ prompt = "# Role: Generator\n\n## Goals:\nwrite something"+ with (+ patch.object(llm.shutil, "which", return_value="/usr/bin/claude"),+ patch.object(+ llm.subprocess,+ "run",+ return_value=self._completed(stdout=self._cli_payload("ok")),+ ) as run,+ ):+ llm._generate_response(prompt)++ command = run.call_args.args[0]+ self.assertFalse(any("\n" in arg for arg in command))+ self.assertNotIn(prompt, command)+ self.assertEqual(run.call_args.kwargs["input"], prompt)+def test_model_name_is_only_passed_when_configured(self):"""模型名留空时应沿用 CLI 默认模型,而不是硬编码一个可能失效的 ID。"""with (