利用 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): keep combining marks in social hashtags
L4XBb5c96936c725
diff --git a/app/services/llm.py b/app/services/llm.pyindex deef62ad..bd935d34 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -6,6 +6,7 @@ import reimport shutilimport subprocessimport tempfile+import unicodedatafrom time import perf_counterfrom typing import List@@ -1240,7 +1241,16 @@ def _normalize_hashtags(raw, count: int) -> List[str]:seen = set()result: List[str] = []for item in candidates:- tag = re.sub(r"[^\w]", "", item, flags=re.UNICODE)+ # \w does not match combining marks, so keep them explicitly: they are+ # the vowel signs and tone marks of Devanagari, Bengali, Tamil and Thai+ # tags, and dropping them misspells the tag ("#भारत" became "#भरत").+ tag = "".join(+ character+ for character in item+ if character.isalnum()+ or character == "_"+ or unicodedata.category(character).startswith("M")+ )if not tag:continuekey = tag.lower()diff --git a/test/services/test_llm.py b/test/services/test_llm.pyindex 5987012c..d7cc3850 100644--- a/test/services/test_llm.py+++ b/test/services/test_llm.py@@ -2614,6 +2614,11 @@ class TestSocialMetadata(unittest.TestCase):self.assertEqual(tags, ["#上海旅行", "#việtnam", "#badchars"])+ def test_normalize_hashtags_keeps_combining_marks(self):+ tags = llm._normalize_hashtags(["#भारत", "#বাংলা", "#தமிழ்", "#ท่องเที่ยว"], count=5)++ self.assertEqual(tags, ["#भारत", "#বাংলা", "#தமிழ்", "#ท่องเที่ยว"])+def test_parse_social_metadata_recovers_embedded_json(self):raw = 'Sure: {"title":"T","caption":"C","hashtags":["#x"]} thanks'result = llm._parse_social_metadata(raw, "tiktok")