返回 Pixelle-Video
llm_presets.py
根目录 / pixelle_video / llm_presets.py
1 # Copyright (C) 2025 AIDC-AI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 """
14 LLM Presets - Predefined configurations for popular LLM providers
15
16 All providers support OpenAI SDK protocol.
17 """
18
19 from typing import Dict, Any, List
20
21
22 LLM_PRESETS: List[Dict[str, Any]] = [
23 {
24 "name": "Qwen",
25 "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
26 "model": "qwen-max",
27 "api_key_url": "https://bailian.console.aliyun.com/?tab=model#/api-key",
28 },
29 {
30 "name": "OpenAI",
31 "base_url": "https://api.openai.com/v1",
32 "model": "gpt-4o",
33 "api_key_url": "https://platform.openai.com/api-keys",
34 },
35 {
36 "name": "Claude",
37 "base_url": "https://api.anthropic.com/v1/",
38 "model": "claude-sonnet-4-5",
39 "api_key_url": "https://console.anthropic.com/settings/keys",
40 },
41 {
42 "name": "DeepSeek",
43 "base_url": "https://api.deepseek.com",
44 "model": "deepseek-chat",
45 "api_key_url": "https://platform.deepseek.com/api_keys",
46 },
47 {
48 "name": "Ollama",
49 "base_url": "http://localhost:11434/v1",
50 "model": "llama3.2",
51 "api_key_url": "https://ollama.com/download",
52 "default_api_key": "ollama", # Required by OpenAI SDK but ignored by Ollama
53 },
54 {
55 "name": "Moonshot",
56 "base_url": "https://api.moonshot.cn/v1",
57 "model": "moonshot-v1-8k",
58 "api_key_url": "https://platform.moonshot.cn/console/api-keys",
59 },
60 ]
61
62
63 def get_preset_names() -> List[str]:
64 """Get list of preset names"""
65 return [preset["name"] for preset in LLM_PRESETS]
66
67
68 def get_preset(name: str) -> Dict[str, Any]:
69 """Get preset configuration by name"""
70 for preset in LLM_PRESETS:
71 if preset["name"] == name:
72 return preset
73 return {}
74
75
76 def find_preset_by_base_url_and_model(base_url: str, model: str) -> str | None:
77 """
78 Find preset name by base_url and model
79
80 Returns:
81 Preset name if found, None otherwise
82 """
83 for preset in LLM_PRESETS:
84 if preset["base_url"] == base_url and preset["model"] == model:
85 return preset["name"]
86 return None
87
88
88 lines PYTHON