利用 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
- 增加Cloudflare workers ai作为llm后端 - 增加一些gitignore
highkay05da4a37669a
diff --git a/.gitignore b/.gitignoreindex dd7e7884..00b64c87 100644--- a/.gitignore+++ b/.gitignore@@ -9,4 +9,6 @@/app/utils/__pycache__//*/__pycache__/*.vscode-/**/.streamlit\ No newline at end of file+/**/.streamlit+__pycache__+logs/\ No newline at end of filediff --git a/app/services/llm.py b/app/services/llm.pyindex fca6bcaf..fda371f4 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -57,6 +57,11 @@ def _generate_response(prompt: str) -> str:api_key = config.app.get("qwen_api_key")model_name = config.app.get("qwen_model_name")base_url = "***"+ elif llm_provider == "cloudflare":+ api_key = config.app.get("cloudflare_api_key")+ model_name = config.app.get("cloudflare_model_name")+ account_id = config.app.get("cloudflare_account_id")+ base_url = "***"else:raise ValueError("llm_provider is not set, please set it in the config.toml file.")@@ -115,6 +120,22 @@ def _generate_response(prompt: str) -> str:convo.send_message(prompt)return convo.last.text++ if llm_provider == "cloudflare":+ import requests+ response = requests.post(+ f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model_name}",+ headers={"Authorization": f"Bearer {api_key}"},+ json={+ "messages": [+ {"role": "system", "content": "You are a friendly assistant"},+ {"role": "user", "content": prompt}+ ]+ }+ )+ result = response.json()+ logger.info(result)+ return result["result"]["response"]if llm_provider == "azure":client = AzureOpenAI(diff --git a/webui/Main.py b/webui/Main.pyindex 2712b282..9631d39b 100644--- a/webui/Main.py+++ b/webui/Main.py@@ -175,7 +175,7 @@ with st.expander(tr("Basic Settings"), expanded=False):# qwen (通义千问)# gemini# ollama- llm_providers = ['OpenAI', 'Moonshot', 'Azure', 'Qwen', 'Gemini', 'Ollama', 'G4f', 'OneAPI']+ llm_providers = ['OpenAI', 'Moonshot', 'Azure', 'Qwen', 'Gemini', 'Ollama', 'G4f', 'OneAPI', "Cloudflare"]saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()saved_llm_provider_index = 0for i, provider in enumerate(llm_providers):@@ -190,6 +190,7 @@ with st.expander(tr("Basic Settings"), expanded=False):llm_api_key = config.app.get(f"{llm_provider}_api_key", "")llm_base_url = config.app.get(f"{llm_provider}_base_url", "")llm_model_name = config.app.get(f"{llm_provider}_model_name", "")+ llm_account_id = config.app.get(f"{llm_provider}_account_id", "")st_llm_api_key = st.text_input(tr("API Key"), value=llm_api_key, type="password")st_llm_base_url = st.text_input(tr("Base Url"), value=llm_base_url)st_llm_model_name = st.text_input(tr("Model Name"), value=llm_model_name)@@ -200,6 +201,11 @@ with st.expander(tr("Basic Settings"), expanded=False):if st_llm_model_name:config.app[f"{llm_provider}_model_name"] = st_llm_model_name+ if llm_provider == 'cloudflare':+ st_llm_account_id = st.text_input(tr("Account ID"), value=llm_account_id)+ if st_llm_account_id:+ config.app[f"{llm_provider}_account_id"] = st_llm_account_id+config.save_config()with right_config_panel:diff --git a/webui/i18n/en.json b/webui/i18n/en.jsonindex 47bd0731..f9458a93 100644--- a/webui/i18n/en.json+++ b/webui/i18n/en.json@@ -55,6 +55,7 @@"LLM Provider": "LLM Provider","API Key": "API Key (:red[Required])","Base Url": "Base Url",+ "Account ID": "Account ID (Get from Cloudflare dashboard)","Model Name": "Model Name","Please Enter the LLM API Key": "Please Enter the **LLM API Key**","Please Enter the Pexels API Key": "Please Enter the **Pexels API Key**",diff --git a/webui/i18n/zh.json b/webui/i18n/zh.jsonindex 7d71d05b..7019c271 100644--- a/webui/i18n/zh.json+++ b/webui/i18n/zh.json@@ -55,6 +55,7 @@"LLM Provider": "大模型提供商","API Key": "API Key (:red[必填,需要到大模型提供商的后台申请])","Base Url": "Base Url (可选)",+ "Account ID": "账户ID (Cloudflare的dash面板url中获取)","Model Name": "模型名称 (:blue[需要到大模型提供商的后台确认被授权的模型名称])","Please Enter the LLM API Key": "请先填写大模型 **API Key**","Please Enter the Pexels API Key": "请先填写 **Pexels API Key**",