利用 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: response parsing bug for gemini
elf-mouseee7306d216ea
diff --git a/app/services/llm.py b/app/services/llm.pyindex e6228189..40e56dae 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -86,7 +86,7 @@ def _generate_response(prompt: str) -> str:if llm_provider == "gemini":import google.generativeai as genai- genai.configure(api_key=api_key)+ genai.configure(api_key=api_key, transport='rest')generation_config = {"temperature": 0.5,@@ -118,11 +118,15 @@ def _generate_response(prompt: str) -> str:generation_config=generation_config,safety_settings=safety_settings)- convo = model.start_chat(history=[])+ try:+ response = model.generate_content(prompt)+ candidates = response.candidates+ generated_text = candidates[0].content.parts[0].text+ except (AttributeError, IndexError) as e:+ print("Gemini Error:", e)++ return generated_text- convo.send_message(prompt)- return convo.last.text-if llm_provider == "cloudflare":import requestsresponse = requests.post(@@ -180,9 +184,9 @@ Generate a script for a video, depending on the subject of the video.1. the script is to be returned as a string with the specified number of paragraphs.2. do not under any circumstance reference this prompt in your response.3. get straight to the point, don't start with unnecessary things like, "welcome to this video".-4. you must not include any type of markdown or formatting in the script, never use a title.-5. only return the raw content of the script.-6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.+4. you must not include any type of markdown or formatting in the script, never use a title.+5. only return the raw content of the script.+6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.7. you must not mention the prompt, or anything about the script itself. also, never talk about the amount of paragraphs or lines. just write the script.8. respond in the same language as the video subject.