返回提交历史
Modified
g4f/Provider/PollinationsAI.py
+25
-10
XFEstudio/gpt4free
feat: Update model aliases and add model retrieval method
- Changed the model alias for "gpt-4.1-nano" to be a list containing "openai-fast" and "openai-small". - Updated the model alias for "gpt-4.1" to be a list containing "openai", "openai-large", and "openai-xlarge". - Modified the model alias for "gpt-4.1-mini" to be a list containing "openai", "openai-roblox", and "roblox-rp". - Changed the model alias for "deepseek-r1" to be a list containing "deepseek-reasoning-large" and "deepseek-reasoning". - Added a new class method `get_model` to retrieve the internal model name based on user-provided model names, including handling for aliases that are lists. - Implemented error handling in `get_model` to raise a `ModelNotFoundError` if the model is not found.
13eaf147
代码差异
1 个文件
+25
-10
@@ -57,17 +57,12 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
57
57
model_aliases = {
58
58
### Text Models ###
59
59
"gpt-4o-mini": "openai",
60
"gpt-4.1": "openai",
61
"gpt-4.1-mini": "openai",
62
"gpt-4.1-nano": "openai-fast",
63
"gpt-4.1-nano": "openai-small",
60
"gpt-4.1-nano": ["openai-fast", "openai-small"],
64
61
"gpt-4": "openai-large",
65
62
"gpt-4o": "openai-large",
66
"gpt-4.1": "openai-large",
67
"gpt-4.1": "openai-xlarge",
63
"gpt-4.1": ["openai", "openai-large", "openai-xlarge"],
68
64
"o4-mini": "openai-reasoning",
69
"gpt-4.1-mini": "openai-roblox",
70
"gpt-4.1-mini": "roblox-rp",
65
"gpt-4.1-mini": ["openai", "openai-roblox", "roblox-rp"],
71
66
"command-r-plus-08-2024": "command-r",
72
67
"gemini-2.5-flash": "gemini",
73
68
"gemini-2.0-flash-thinking": "gemini-thinking",
@@ -76,7 +71,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
76
71
"llama-4-scout": "llamascout",
77
72
"llama-4-scout-17b": "llamascout",
78
73
"mistral-small-3.1-24b": "mistral",
79
"deepseek-r1": "deepseek-reasoning-large",
74
"deepseek-r1": ["deepseek-reasoning-large", "deepseek-reasoning"],
80
75
"deepseek-r1-distill-llama-70b": "deepseek-reasoning-large",
81
76
"deepseek-r1-distill-llama-70b": "deepseek-r1-llama",
82
77
#"mistral-small-3.1-24b": "unity", # Personas
@@ -85,7 +80,6 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
85
80
#"rtist": "rtist", # Personas
86
81
#"searchgpt": "searchgpt",
87
82
#"evil": "evil", # Personas
88
"deepseek-r1": "deepseek-reasoning",
89
83
"deepseek-r1-distill-qwen-32b": "deepseek-reasoning",
90
84
"phi-4": "phi",
91
85
#"pixtral-12b": "pixtral",
@@ -105,6 +99,27 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
105
99
"sdxl-turbo": "turbo",
106
100
}
107
101
102
@classmethod
103
def get_model(cls, model: str) -> str:
104
"""Get the internal model name from the user-provided model name."""
105
if not model:
106
return cls.default_model
107
108
# Check if the model exists directly in our model lists
109
if model in cls.text_models or model in cls.image_models or model in cls.audio_models:
110
return model
111
112
# Check if there's an alias for this model
113
if model in cls.model_aliases:
114
alias = cls.model_aliases[model]
115
# If the alias is a list, randomly select one of the options
116
if isinstance(alias, list):
117
return random.choice(alias)
118
return alias
119
120
# If no match is found, raise an error
121
raise ModelNotFoundError(f"Model {model} not found")
122
108
123
@classmethod
109
124
def get_models(cls, **kwargs):
110
125
if not cls._models_loaded: