利用 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
enhanced exception handling for generating terms
harryfc6844dd1921
diff --git a/app/services/llm.py b/app/services/llm.pyindex 5177779a..ac05137e 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -295,6 +295,7 @@ Please note that you must use English for generating video search terms; Chineselogger.info(f"subject: {video_subject}")search_terms = []+ response = ""for i in range(_max_retries):try:response = _generate_response(prompt)@@ -304,12 +305,15 @@ Please note that you must use English for generating video search terms; Chinesecontinueexcept Exception as e:- match = re.search(r'\[.*]', response)- if match:- try:- search_terms = json.loads(match.group())- except json.JSONDecodeError:- pass+ logger.warning(f"failed to generate video terms: {str(e)}")+ if response:+ match = re.search(r'\[.*]', response)+ if match:+ try:+ search_terms = json.loads(match.group())+ except Exception as e:+ logger.warning(f"failed to generate video terms: {str(e)}")+ passif search_terms and len(search_terms) > 0:break