利用 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): retain narration in Markdown link labels
Rudy Celekli0fff8473b2ca
diff --git a/app/services/llm.py b/app/services/llm.pyindex 03e73360..4485fcb7 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -839,6 +839,14 @@ def generate_script(response = response.replace("*", "")response = response.replace("#", "")+ # Link labels are narration; discard destinations before stripping+ # bracketed stage directions. Common parenthesized URL components fit.+ response = re.sub(+ r"\[([^\]\n]+)\]\((?:[^()\n]|\([^()\n]*\))*\)",+ lambda match: match.group(1),+ response,+ )+# Remove markdown syntax. Use non-greedy .*? so each bracket/paren# group is removed independently; the greedy form would eat all text# between the first opener and the last closer on the same line.diff --git a/test/services/test_script_markdown_link_labels.py b/test/services/test_script_markdown_link_labels.pynew file mode 100644index 00000000..25ac4851--- /dev/null+++ b/test/services/test_script_markdown_link_labels.py@@ -0,0 +1,9 @@+from unittest.mock import patch++from app.services import llm+++def test_generated_script_retains_narration_in_markdown_link_labels():+ response = "Visit [the museum](https://example.org/museum) today."+ with patch.object(llm, "_generate_response", return_value=response):+ assert llm.generate_script("museum") == "Visit the museum today."