利用 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
feat: add LiteLLM provider
Harry35fb1d05d2f5
diff --git a/.gitignore b/.gitignoreindex 066562a0..ed9f991b 100644--- a/.gitignore+++ b/.gitignore@@ -32,4 +32,5 @@ CLAUDE.mddebug/debug_*.pytest_*.py-streamlit.log\ No newline at end of file+!test/services/test_*.py+streamlit.logdiff --git a/app/services/llm.py b/app/services/llm.pyindex ae9157fb..a9e41050 100644--- a/app/services/llm.py+++ b/app/services/llm.py@@ -185,7 +185,10 @@ def _generate_response(prompt: str) -> str:except Exception as e:raise Exception(f"[{llm_provider}] error: {str(e)}")- if llm_provider not in ["pollinations", "ollama"]: # Skip validation for providers that don't require API key+ elif llm_provider == "litellm":+ model_name = config.app.get("litellm_model_name")++ if llm_provider not in ["pollinations", "ollama", "litellm"]: # Skip validation for providers that don't require API keyif not api_key:raise ValueError(f"{llm_provider}: api_key is not set, please set it in the config.toml file."@@ -322,6 +325,26 @@ def _generate_response(prompt: str) -> str:).json()return _normalize_text_response(response.get("result"), llm_provider)+ if llm_provider == "litellm":+ import litellm++ if not model_name:+ raise ValueError(+ f"{llm_provider}: model_name is not set, please set it in the config.toml file."+ )++ response = litellm.completion(+ model=model_name,+ messages=[{"role": "user", "content": prompt}],+ drop_params=True,+ )++ if not response or not getattr(response, "choices", None):+ raise ValueError(f"[{llm_provider}] returned empty response")++ content = response.choices[0].message.content+ return _normalize_text_response(content, llm_provider)+if llm_provider == "azure":client = AzureOpenAI(api_key=api_key,diff --git a/config.example.toml b/config.example.tomlindex ec2309d7..15db4912 100644--- a/config.example.toml+++ b/config.example.toml@@ -32,6 +32,7 @@ pixabay_api_keys = []# minimax# ernie (文心一言)# modelscope (魔搭社区)+# litellm (100+ providers via LiteLLM gateway)llm_provider = "openai"########## Pollinations AI Settings@@ -121,6 +122,22 @@ modelscope_api_key = ""modelscope_base_url = "https://api-inference.modelscope.cn/v1/"modelscope_model_name = "Qwen/Qwen3-32B"+########## LiteLLM (AI Gateway — 100+ providers)+# LiteLLM routes to any LLM provider via a unified interface.+# Use this for providers not directly supported above: Anthropic (native API),+# AWS Bedrock, Google Vertex AI, Cohere, Mistral, Together AI, etc.+# Visit https://docs.litellm.ai/docs/providers for the full list.+#+# LiteLLM reads provider API keys from environment variables automatically:+# OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, AWS_ACCESS_KEY_ID, etc.+# Set the appropriate env var for your chosen provider before running.+#+# Model name in LiteLLM format: "provider/model-name"+# Examples: "openai/gpt-4o", "anthropic/claude-sonnet-4-20250514",+# "bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0",+# "gemini/gemini-2.5-flash", "ollama/llama3"+litellm_model_name = "openai/gpt-4o-mini"+# Subtitle Provider, "edge" or "whisper"# If empty, the subtitle will not be generatedsubtitle_provider = "edge"diff --git a/pyproject.toml b/pyproject.tomlindex c1eb0259..72611bb3 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -31,6 +31,7 @@ dependencies = ["requests==2.33.1","socksio==1.0.0","pydub==0.25.1",+ "litellm==1.60.0",][tool.hatch.build.targets.wheel]diff --git a/requirements.txt b/requirements.txtindex cc8a63c5..0c8a66ac 100644--- a/requirements.txt+++ b/requirements.txt@@ -17,3 +17,4 @@ pyyaml==6.0.3requests==2.33.1socksio==1.0.0pydub==0.25.1+litellm==1.60.0diff --git a/test/services/test_llm.py b/test/services/test_llm.pynew file mode 100644index 00000000..bfe7b7b2--- /dev/null+++ b/test/services/test_llm.py@@ -0,0 +1,115 @@+import os+import sys+import types+import unittest+from pathlib import Path+from unittest.mock import patch++sys.path.insert(0, str(Path(__file__).parent.parent.parent))++from app.config import config+from app.services import llm+++class TestLiteLLMProvider(unittest.TestCase):+ def setUp(self):+ self.original_app_config = dict(config.app)++ def tearDown(self):+ config.app.clear()+ config.app.update(self.original_app_config)++ def _use_litellm_provider(self, model_name="openai/gpt-4o-mini"):+ config.app["llm_provider"] = "litellm"+ config.app["litellm_model_name"] = model_name++ def test_litellm_provider_returns_normalized_text(self):+ """+ 验证 LiteLLM provider 的主路径不依赖真实网络和私有 API key。++ 这里用 fake module 注入 `sys.modules`,直接覆盖动态 import 的+ `litellm.completion()`,确保测试稳定覆盖 `_generate_response()` 里的+ litellm 分支。+ """+ self._use_litellm_provider()++ fake_litellm = types.SimpleNamespace()++ def _completion(**kwargs):+ self.assertEqual(kwargs["model"], "openai/gpt-4o-mini")+ self.assertEqual(+ kwargs["messages"], [{"role": "user", "content": "Say hello"}]+ )+ self.assertTrue(kwargs["drop_params"])+ message = types.SimpleNamespace(content="hello\nworld")+ choice = types.SimpleNamespace(message=message)+ return types.SimpleNamespace(choices=[choice])++ fake_litellm.completion = _completion++ with patch.dict(sys.modules, {"litellm": fake_litellm}):+ result = llm._generate_response("Say hello")++ self.assertEqual(result, "helloworld")++ def test_litellm_provider_requires_model_name(self):+ self._use_litellm_provider(model_name="")++ result = llm._generate_response("test")++ self.assertIn("Error:", result)+ self.assertIn("model_name is not set", result)++ def test_litellm_provider_handles_empty_response(self):+ self._use_litellm_provider()++ fake_litellm = types.SimpleNamespace(+ completion=lambda **kwargs: types.SimpleNamespace(choices=[])+ )++ with patch.dict(sys.modules, {"litellm": fake_litellm}):+ result = llm._generate_response("test")++ self.assertIn("Error:", result)+ self.assertIn("returned empty response", result)++ def test_openai_provider_still_uses_existing_path(self):+ config.app["llm_provider"] = "openai"+ config.app["openai_api_key"] = ""+ config.app["openai_base_url"] = "https://api.openai.com/v1"+ config.app["openai_model_name"] = "gpt-4o-mini"++ result = llm._generate_response("test")++ self.assertIn("Error:", result)+ self.assertIn("api_key is not set", result)+ self.assertNotIn("litellm", result.lower())+++FOUNDRY_KEY = os.environ.get("ANTHROPIC_FOUNDRY_API_KEY", "")+FOUNDRY_BASE = "https://amanrai-test-resource.services.ai.azure.com/anthropic"+FOUNDRY_MODEL = "azure_ai/claude-sonnet-4-6"++[email protected](FOUNDRY_KEY, "ANTHROPIC_FOUNDRY_API_KEY not set")+class TestLiteLLMLiveIntegration(unittest.TestCase):+ def setUp(self):+ self.original_app_config = dict(config.app)+ config.app["llm_provider"] = "litellm"+ config.app["litellm_model_name"] = FOUNDRY_MODEL+ os.environ["AZURE_AI_API_KEY"] = FOUNDRY_KEY+ os.environ["AZURE_AI_API_BASE"] = FOUNDRY_BASE++ def tearDown(self):+ config.app.clear()+ config.app.update(self.original_app_config)++ def test_live_litellm_completion(self):+ result = llm._generate_response("What is 2+2? Reply with just the number.")++ self.assertNotIn("Error:", result)+ self.assertIn("4", result)+++if __name__ == "__main__":+ unittest.main()diff --git a/uv.lock b/uv.lockindex 1b1cab17..46413722 100644--- a/uv.lock+++ b/uv.lock@@ -783,17 +783,18 @@ wheels = [[[package]]name = "httpx"-version = "0.28.1"+version = "0.27.2"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "anyio" },{ name = "certifi" },{ name = "httpcore" },{ name = "idna" },+ { name = "sniffio" },]-sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406 }+sdist = { url = "https://files.pythonhosted.org/packages/78/82/08f8c936781f67d9e6b9eeb8a0c8b4e406136ea4c3d1f89a5db71d42e0e6/httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2", size = 144189 }wheels = [- { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517 },+ { url = "https://files.pythonhosted.org/packages/56/95/9377bcb415797e44274b51d46e3249eba641711cf3348050f76ee7b15ffc/httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0", size = 76395 },][[package]]@@ -852,6 +853,18 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/2c/c6/fa760e12a2483469e2bf5058c5faff664acf66cadb4df2ad6205b016a73d/imageio_ffmpeg-0.6.0-py3-none-win_amd64.whl", hash = "sha256:02fa47c83703c37df6bfe4896aab339013f62bf02c5ebf2dce6da56af04ffc0a", size = 31246824 },]+[[package]]+name = "importlib-metadata"+version = "9.0.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "zipp" },+]+sdist = { url = "https://files.pythonhosted.org/packages/a9/01/15bb152d77b21318514a96f43af312635eb2500c96b55398d020c93d86ea/importlib_metadata-9.0.0.tar.gz", hash = "sha256:a4f57ab599e6a2e3016d7595cfd72eb4661a5106e787a95bcc90c7105b831efc", size = 56405 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/38/3d/2d244233ac4f76e38533cfcb2991c9eb4c7bf688ae0a036d30725b8faafe/importlib_metadata-9.0.0-py3-none-any.whl", hash = "sha256:2d21d1cc5a017bd0559e36150c21c830ab1dc304dedd1b7ea85d20f45ef3edd7", size = 27789 },+]+[[package]]name = "jinja2"version = "3.1.6"@@ -933,6 +946,28 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437 },]+[[package]]+name = "litellm"+version = "1.60.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "aiohttp" },+ { name = "click" },+ { name = "httpx" },+ { name = "importlib-metadata" },+ { name = "jinja2" },+ { name = "jsonschema" },+ { name = "openai" },+ { name = "pydantic" },+ { name = "python-dotenv" },+ { name = "tiktoken" },+ { name = "tokenizers" },+]+sdist = { url = "https://files.pythonhosted.org/packages/88/02/dd7191498805a6a1b5577993b0e01b5edff7b934fa95fbced4b1f7e09be2/litellm-1.60.0.tar.gz", hash = "sha256:45e3d9d7c19c02b7a1adf1c86102395fc667ebf35f72033e490e8f6fae7d0f8e", size = 6437939 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/72/db/382c5e34025acb2a01e02d8ce3e1b675d41a29b2e5c694435272675f6fb2/litellm-1.60.0-py3-none-any.whl", hash = "sha256:e8284f5cc74ae1aed77516cdfbb2db3746d50c4ba055fb21358e6e25aea25a15", size = 6732210 },+]+[[package]]name = "loguru"version = "0.7.3"@@ -1009,6 +1044,7 @@ dependencies = [{ name = "faster-whisper" },{ name = "g4f" },{ name = "google-generativeai" },+ { name = "litellm" },{ name = "loguru" },{ name = "moviepy" },{ name = "openai" },@@ -1031,6 +1067,7 @@ requires-dist = [{ name = "faster-whisper", specifier = "==1.1.0" },{ name = "g4f", specifier = "==0.5.2.2" },{ name = "google-generativeai", specifier = "==0.8.6" },+ { name = "litellm", specifier = "==1.60.0" },{ name = "loguru", specifier = "==0.7.3" },{ name = "moviepy", specifier = "==2.1.2" },{ name = "openai", specifier = "==1.56.1" },@@ -1631,6 +1668,46 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/2c/58/ca301544e1fa93ed4f80d724bf5b194f6e4b945841c5bfd555878eea9fcb/referencing-0.37.0-py3-none-any.whl", hash = "sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231", size = 26766 },]+[[package]]+name = "regex"+version = "2026.4.4"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/cb/0e/3a246dbf05666918bd3664d9d787f84a9108f6f43cc953a077e4a7dfdb7e/regex-2026.4.4.tar.gz", hash = "sha256:e08270659717f6973523ce3afbafa53515c4dc5dcad637dc215b6fd50f689423", size = 416000 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/e0/7a/617356cbecdb452812a5d42f720d6d5096b360d4a4c1073af700ea140ad2/regex-2026.4.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:b4c36a85b00fadb85db9d9e90144af0a980e1a3d2ef9cd0f8a5bef88054657c6", size = 489415 },+ { url = "https://files.pythonhosted.org/packages/20/e6/bf057227144d02e3ba758b66649e87531d744dda5f3254f48660f18ae9d8/regex-2026.4.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dcb5453ecf9cd58b562967badd1edbf092b0588a3af9e32ee3d05c985077ce87", size = 291205 },+ { url = "https://files.pythonhosted.org/packages/eb/3b/637181b787dd1a820ba1c712cee2b4144cd84a32dc776ca067b12b2d70c8/regex-2026.4.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6aa809ed4dc3706cc38594d67e641601bd2f36d5555b2780ff074edfcb136cf8", size = 289225 },+ { url = "https://files.pythonhosted.org/packages/05/21/bac05d806ed02cd4b39d9c8e5b5f9a2998c94c3a351b7792e80671fa5315/regex-2026.4.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:33424f5188a7db12958246a54f59a435b6cb62c5cf9c8d71f7cc49475a5fdada", size = 792434 },+ { url = "https://files.pythonhosted.org/packages/d9/17/c65d1d8ae90b772d5758eb4014e1e011bb2db353fc4455432e6cc9100df7/regex-2026.4.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:7d346fccdde28abba117cc9edc696b9518c3307fbfcb689e549d9b5979018c6d", size = 861730 },+ { url = "https://files.pythonhosted.org/packages/ad/64/933321aa082a2c6ee2785f22776143ba89840189c20d3b6b1d12b6aae16b/regex-2026.4.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:415a994b536440f5011aa77e50a4274d15da3245e876e5c7f19da349caaedd87", size = 906495 },+ { url = "https://files.pythonhosted.org/packages/01/ea/4c8d306e9c36ac22417336b1e02e7b358152c34dc379673f2d331143725f/regex-2026.4.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:21e5eb86179b4c67b5759d452ea7c48eb135cd93308e7a260aa489ed2eb423a4", size = 799810 },+ { url = "https://files.pythonhosted.org/packages/29/ce/7605048f00e1379eba89d610c7d644d8f695dc9b26d3b6ecfa3132b872ff/regex-2026.4.4-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:312ec9dd1ae7d96abd8c5a36a552b2139931914407d26fba723f9e53c8186f86", size = 774242 },+ { url = "https://files.pythonhosted.org/packages/e9/77/283e0d5023fde22cd9e86190d6d9beb21590a452b195ffe00274de470691/regex-2026.4.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:a0d2b28aa1354c7cd7f71b7658c4326f7facac106edd7f40eda984424229fd59", size = 781257 },+ { url = "https://files.pythonhosted.org/packages/8b/fb/7f3b772be101373c8626ed34c5d727dcbb8abd42a7b1219bc25fd9a3cc04/regex-2026.4.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:349d7310eddff40429a099c08d995c6d4a4bfaf3ff40bd3b5e5cb5a5a3c7d453", size = 854490 },+ { url = "https://files.pythonhosted.org/packages/85/30/56547b80f34f4dd2986e1cdd63b1712932f63b6c4ce2f79c50a6cd79d1c2/regex-2026.4.4-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:e7ab63e9fe45a9ec3417509e18116b367e89c9ceb6219222a3396fa30b147f80", size = 763544 },+ { url = "https://files.pythonhosted.org/packages/ac/2f/ce060fdfea8eff34a8997603532e44cdb7d1f35e3bc253612a8707a90538/regex-2026.4.4-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:fe896e07a5a2462308297e515c0054e9ec2dd18dfdc9427b19900b37dfe6f40b", size = 844442 },+ { url = "https://files.pythonhosted.org/packages/e5/44/810cb113096a1dacbe82789fbfab2823f79d19b7f1271acecb7009ba9b88/regex-2026.4.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:eb59c65069498dbae3c0ef07bbe224e1eaa079825a437fb47a479f0af11f774f", size = 789162 },+ { url = "https://files.pythonhosted.org/packages/20/96/9647dd7f2ecf6d9ce1fb04dfdb66910d094e10d8fe53e9c15096d8aa0bd2/regex-2026.4.4-cp311-cp311-win32.whl", hash = "sha256:2a5d273181b560ef8397c8825f2b9d57013de744da9e8257b8467e5da8599351", size = 266227 },+ { url = "https://files.pythonhosted.org/packages/33/80/74e13262460530c3097ff343a17de9a34d040a5dc4de9cf3a8241faab51c/regex-2026.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:9542ccc1e689e752594309444081582f7be2fdb2df75acafea8a075108566735", size = 278399 },+ { url = "https://files.pythonhosted.org/packages/1c/3c/39f19f47f19dcefa3403f09d13562ca1c0fd07ab54db2bc03148f3f6b46a/regex-2026.4.4-cp311-cp311-win_arm64.whl", hash = "sha256:b5f9fb784824a042be3455b53d0b112655686fdb7a91f88f095f3fee1e2a2a54", size = 270473 },+ { url = "https://files.pythonhosted.org/packages/e5/28/b972a4d3df61e1d7bcf1b59fdb3cddef22f88b6be43f161bb41ebc0e4081/regex-2026.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:c07ab8794fa929e58d97a0e1796b8b76f70943fa39df225ac9964615cf1f9d52", size = 490434 },+ { url = "https://files.pythonhosted.org/packages/84/20/30041446cf6dc3e0eab344fc62770e84c23b6b68a3b657821f9f80cb69b4/regex-2026.4.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:2c785939dc023a1ce4ec09599c032cc9933d258a998d16ca6f2b596c010940eb", size = 292061 },+ { url = "https://files.pythonhosted.org/packages/62/c8/3baa06d75c98c46d4cc4262b71fd2edb9062b5665e868bca57859dadf93a/regex-2026.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1b1ce5c81c9114f1ce2f9288a51a8fd3aeea33a0cc440c415bf02da323aa0a76", size = 289628 },+ { url = "https://files.pythonhosted.org/packages/31/87/3accf55634caad8c0acab23f5135ef7d4a21c39f28c55c816ae012931408/regex-2026.4.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:760ef21c17d8e6a4fe8cf406a97cf2806a4df93416ccc82fc98d25b1c20425be", size = 796651 },+ { url = "https://files.pythonhosted.org/packages/f6/0c/aaa2c83f34efedbf06f61cb1942c25f6cf1ee3b200f832c4d05f28306c2e/regex-2026.4.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:7088fcdcb604a4417c208e2169715800d28838fefd7455fbe40416231d1d47c1", size = 865916 },+ { url = "https://files.pythonhosted.org/packages/d9/f6/8c6924c865124643e8f37823eca845dc27ac509b2ee58123685e71cd0279/regex-2026.4.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:07edca1ba687998968f7db5bc355288d0c6505caa7374f013d27356d93976d13", size = 912287 },+ { url = "https://files.pythonhosted.org/packages/11/0e/a9f6f81013e0deaf559b25711623864970fe6a098314e374ccb1540a4152/regex-2026.4.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:993f657a7c1c6ec51b5e0ba97c9817d06b84ea5fa8d82e43b9405de0defdc2b9", size = 801126 },+ { url = "https://files.pythonhosted.org/packages/71/61/3a0cc8af2dc0c8deb48e644dd2521f173f7e6513c6e195aad9aa8dd77ac5/regex-2026.4.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:2b69102a743e7569ebee67e634a69c4cb7e59d6fa2e1aa7d3bdbf3f61435f62d", size = 776788 },+ { url = "https://files.pythonhosted.org/packages/64/0b/8bb9cbf21ef7dee58e49b0fdb066a7aded146c823202e16494a36777594f/regex-2026.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6dac006c8b6dda72d86ea3d1333d45147de79a3a3f26f10c1cf9287ca4ca0ac3", size = 785184 },+ { url = "https://files.pythonhosted.org/packages/99/c2/d3e80e8137b25ee06c92627de4e4d98b94830e02b3e6f81f3d2e3f504cf5/regex-2026.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:50a766ee2010d504554bfb5f578ed2e066898aa26411d57e6296230627cdefa0", size = 859913 },+ { url = "https://files.pythonhosted.org/packages/bc/e6/9d5d876157d969c804622456ef250017ac7a8f83e0e14f903b9e6df5ce95/regex-2026.4.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:9e2f5217648f68e3028c823df58663587c1507a5ba8419f4fdfc8a461be76043", size = 765732 },+ { url = "https://files.pythonhosted.org/packages/82/80/b568935b4421388561c8ed42aff77247285d3ae3bb2a6ca22af63bae805e/regex-2026.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:39d8de85a08e32632974151ba59c6e9140646dcc36c80423962b1c5c0a92e244", size = 852152 },+ { url = "https://files.pythonhosted.org/packages/39/29/f0f81217e21cd998245da047405366385d5c6072048038a3d33b37a79dc0/regex-2026.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:55d9304e0e7178dfb1e106c33edf834097ddf4a890e2f676f6c5118f84390f73", size = 789076 },+ { url = "https://files.pythonhosted.org/packages/49/1d/1d957a61976ab9d4e767dd4f9d04b66cc0c41c5e36cf40e2d43688b5ae6f/regex-2026.4.4-cp312-cp312-win32.whl", hash = "sha256:04bb679bc0bde8a7bfb71e991493d47314e7b98380b083df2447cda4b6edb60f", size = 266700 },+ { url = "https://files.pythonhosted.org/packages/c5/5c/bf575d396aeb58ea13b06ef2adf624f65b70fafef6950a80fc3da9cae3bc/regex-2026.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:db0ac18435a40a2543dbb3d21e161a6c78e33e8159bd2e009343d224bb03bb1b", size = 277768 },+ { url = "https://files.pythonhosted.org/packages/c9/27/049df16ec6a6828ccd72add3c7f54b4df029669bea8e9817df6fff58be90/regex-2026.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:4ce255cc05c1947a12989c6db801c96461947adb7a59990f1360b5983fab4983", size = 270568 },+]+[[package]]name = "requests"version = "2.33.1"@@ -1834,6 +1911,32 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/d7/c1/eb8f9debc45d3b7918a32ab756658a0904732f75e555402972246b0b8e71/tenacity-9.1.4-py3-none-any.whl", hash = "sha256:6095a360c919085f28c6527de529e76a06ad89b23659fa881ae0649b867a9d55", size = 28926 },]+[[package]]+name = "tiktoken"+version = "0.12.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "regex" },+ { name = "requests" },+]+sdist = { url = "https://files.pythonhosted.org/packages/7d/ab/4d017d0f76ec3171d469d80fc03dfbb4e48a4bcaddaa831b31d526f05edc/tiktoken-0.12.0.tar.gz", hash = "sha256:b18ba7ee2b093863978fcb14f74b3707cdc8d4d4d3836853ce7ec60772139931", size = 37806 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/de/46/21ea696b21f1d6d1efec8639c204bdf20fde8bafb351e1355c72c5d7de52/tiktoken-0.12.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:6e227c7f96925003487c33b1b32265fad2fbcec2b7cf4817afb76d416f40f6bb", size = 1051565 },+ { url = "https://files.pythonhosted.org/packages/c9/d9/35c5d2d9e22bb2a5f74ba48266fb56c63d76ae6f66e02feb628671c0283e/tiktoken-0.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c06cf0fcc24c2cb2adb5e185c7082a82cba29c17575e828518c2f11a01f445aa", size = 995284 },+ { url = "https://files.pythonhosted.org/packages/01/84/961106c37b8e49b9fdcf33fe007bb3a8fdcc380c528b20cc7fbba80578b8/tiktoken-0.12.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:f18f249b041851954217e9fd8e5c00b024ab2315ffda5ed77665a05fa91f42dc", size = 1129201 },+ { url = "https://files.pythonhosted.org/packages/6a/d0/3d9275198e067f8b65076a68894bb52fd253875f3644f0a321a720277b8a/tiktoken-0.12.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:47a5bc270b8c3db00bb46ece01ef34ad050e364b51d406b6f9730b64ac28eded", size = 1152444 },+ { url = "https://files.pythonhosted.org/packages/78/db/a58e09687c1698a7c592e1038e01c206569b86a0377828d51635561f8ebf/tiktoken-0.12.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:508fa71810c0efdcd1b898fda574889ee62852989f7c1667414736bcb2b9a4bd", size = 1195080 },+ { url = "https://files.pythonhosted.org/packages/9e/1b/a9e4d2bf91d515c0f74afc526fd773a812232dd6cda33ebea7f531202325/tiktoken-0.12.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a1af81a6c44f008cba48494089dd98cccb8b313f55e961a52f5b222d1e507967", size = 1255240 },+ { url = "https://files.pythonhosted.org/packages/9d/15/963819345f1b1fb0809070a79e9dd96938d4ca41297367d471733e79c76c/tiktoken-0.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:3e68e3e593637b53e56f7237be560f7a394451cb8c11079755e80ae64b9e6def", size = 879422 },+ { url = "https://files.pythonhosted.org/packages/a4/85/be65d39d6b647c79800fd9d29241d081d4eeb06271f383bb87200d74cf76/tiktoken-0.12.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b97f74aca0d78a1ff21b8cd9e9925714c15a9236d6ceacf5c7327c117e6e21e8", size = 1050728 },+ { url = "https://files.pythonhosted.org/packages/4a/42/6573e9129bc55c9bf7300b3a35bef2c6b9117018acca0dc760ac2d93dffe/tiktoken-0.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2b90f5ad190a4bb7c3eb30c5fa32e1e182ca1ca79f05e49b448438c3e225a49b", size = 994049 },+ { url = "https://files.pythonhosted.org/packages/66/c5/ed88504d2f4a5fd6856990b230b56d85a777feab84e6129af0822f5d0f70/tiktoken-0.12.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:65b26c7a780e2139e73acc193e5c63ac754021f160df919add909c1492c0fb37", size = 1129008 },+ { url = "https://files.pythonhosted.org/packages/f4/90/3dae6cc5436137ebd38944d396b5849e167896fc2073da643a49f372dc4f/tiktoken-0.12.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:edde1ec917dfd21c1f2f8046b86348b0f54a2c0547f68149d8600859598769ad", size = 1152665 },+ { url = "https://files.pythonhosted.org/packages/a3/fe/26df24ce53ffde419a42f5f53d755b995c9318908288c17ec3f3448313a3/tiktoken-0.12.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:35a2f8ddd3824608b3d650a000c1ef71f730d0c56486845705a8248da00f9fe5", size = 1194230 },+ { url = "https://files.pythonhosted.org/packages/20/cc/b064cae1a0e9fac84b0d2c46b89f4e57051a5f41324e385d10225a984c24/tiktoken-0.12.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:83d16643edb7fa2c99eff2ab7733508aae1eebb03d5dfc46f5565862810f24e3", size = 1254688 },+ { url = "https://files.pythonhosted.org/packages/81/10/b8523105c590c5b8349f2587e2fdfe51a69544bd5a76295fc20f2374f470/tiktoken-0.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffc5288f34a8bc02e1ea7047b8d041104791d2ddbf42d1e5fa07822cbffe16bd", size = 878694 },+]+[[package]]name = "tokenizers"version = "0.22.2"@@ -2059,3 +2162,12 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/d2/35/aeab955d6c425b227d5b7247eafb24f2653fedc32f95373a001af5dfeb9e/yarl-1.23.0-cp312-cp312-win_arm64.whl", hash = "sha256:6e87a6e8735b44816e7db0b2fbc9686932df473c826b0d9743148432e10bb9b9", size = 81879 },{ url = "https://files.pythonhosted.org/packages/69/68/c8739671f5699c7dc470580a4f821ef37c32c4cb0b047ce223a7f115757f/yarl-1.23.0-py3-none-any.whl", hash = "sha256:a2df6afe50dea8ae15fa34c9f824a3ee958d785fd5d089063d960bae1daa0a3f", size = 48288 },]++[[package]]+name = "zipp"+version = "3.23.1"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/30/21/093488dfc7cc8964ded15ab726fad40f25fd3d788fd741cc1c5a17d78ee8/zipp-3.23.1.tar.gz", hash = "sha256:32120e378d32cd9714ad503c1d024619063ec28aad2248dc6672ad13edfa5110", size = 25965 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/08/8a/0861bec20485572fbddf3dfba2910e38fe249796cb73ecdeb74e07eeb8d3/zipp-3.23.1-py3-none-any.whl", hash = "sha256:0b3596c50a5c700c9cb40ba8d86d9f2cc4807e9bedb06bcdf7fac85633e444dc", size = 10378 },+]diff --git a/webui/Main.py b/webui/Main.pyindex b96e1e44..dfa30daa 100644--- a/webui/Main.py+++ b/webui/Main.py@@ -251,6 +251,7 @@ if not config.app.get("hide_config", False):"Cloudflare","ERNIE","Pollinations",+ "LiteLLM",]saved_llm_provider = config.app.get("llm_provider", "OpenAI").lower()saved_llm_provider_index = 0@@ -419,6 +420,17 @@ if not config.app.get("hide_config", False):- **Model Name**: Use 'openai-fast' or specify a model name"""+ if llm_provider == "litellm":+ if not llm_model_name:+ llm_model_name = "openai/gpt-4o-mini"+ with llm_helper:+ tips = """+ ##### LiteLLM Configuration+ > [LiteLLM](https://github.com/BerriAI/litellm) routes to 100+ LLM providers via a unified interface.+ > Set your provider's API key as an env var: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `AWS_ACCESS_KEY_ID`, etc.+ - **Model Name**: LiteLLM format — `openai/gpt-4o`, `anthropic/claude-sonnet-4-20250514`, `bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0`, `gemini/gemini-2.5-flash`. See [full provider list](https://docs.litellm.ai/docs/providers)+ """+if tips and config.ui["language"] == "zh":st.warning("中国用户建议使用 **DeepSeek** 或 **Moonshot** 作为大模型提供商\n- 国内可直接访问,不需要VPN \n- 注册就送额度,基本够用"