XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Update providers

d49ad2d8
hlohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

14 个文件 +59 -56
Renamed g4f/Provider/Pollinations.py +2 -2
@@ -29,7 +29,7 @@ from ..config import AppConfig
29 29 from .template.OpenaiTemplate import read_response
30 30 from .. import debug
31 31
32 class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
32 class Pollinations(AsyncGeneratorProvider, ProviderModelMixin):
33 33 label = "Pollinations 🌸"
34 34 url = "https://pollinations.ai"
35 35 login_url = "https://enter.pollinations.ai"
@@ -238,7 +238,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
238 238 frequency_penalty: float = None,
239 239 response_format: Optional[dict] = None,
240 240 extra_parameters: list[str] = ["tools", "parallel_tool_calls", "tool_choice", "reasoning_effort",
241 "logit_bias", "voice", "modalities", "audio"],
241 "logit_bias", "voice", "modalities", "audio", "prompt_cache_key"],
242 242 **kwargs
243 243 ) -> AsyncResult:
244 244 if cache is None:
Modified g4f/Provider/PollinationsImage.py +5 -5
@@ -4,11 +4,11 @@ from typing import Optional
4 4
5 5 from .helper import format_media_prompt
6 6 from ..typing import AsyncResult, Messages, MediaListType
7 from .PollinationsAI import PollinationsAI
7 from .Pollinations import Pollinations
8 8
9 class PollinationsImage(PollinationsAI):
9 class PollinationsImage(Pollinations):
10 10 label = "PollinationsImage"
11 parent = PollinationsAI.__name__
11 parent = Pollinations.__name__
12 12 active_by_default = False
13 13 default_model = "auto"
14 14 default_vision_model = None
@@ -17,8 +17,8 @@ class PollinationsImage(PollinationsAI):
17 17
18 18 @classmethod
19 19 def get_models(cls, **kwargs):
20 PollinationsAI.get_models()
21 cls.image_models = {"Auto-Select": "auto", **PollinationsAI.image_models}
20 Pollinations.get_models()
21 cls.image_models = {"Auto-Select": "auto", **Pollinations.image_models}
22 22 cls.models = cls.image_models
23 23 return cls.models
24 24
Modified g4f/Provider/__init__.py +13 -17
@@ -8,14 +8,14 @@ from ..providers.create_images import CreateImagesProvider
8 8 def _resolve_provider(name: str) -> ProviderType:
9 9 if name == "AnyProvider":
10 10 from g4f.providers.any_provider import AnyProvider; return AnyProvider
11 if name == "AIBadgr":
11 elif name == "AIBadgr":
12 12 from g4f.Provider.needs_auth.AIBadgr import AIBadgr; return AIBadgr
13 13 elif name == "Anthropic":
14 14 from g4f.Provider.needs_auth.Anthropic import Anthropic; return Anthropic
15 15 elif name == "Antigravity":
16 16 from g4f.Provider.needs_auth.Antigravity import Antigravity; return Antigravity
17 elif name == "ApiAirforce":
18 from g4f.Provider.needs_auth.ApiAirforce import ApiAirforce; return ApiAirforce
17 elif name == "Airforce" or name == "ApiAirforce":
18 from g4f.Provider.needs_auth.Airforce import Airforce; return Airforce
19 19 elif name == "BingCreateImages":
20 20 from g4f.Provider.needs_auth.BingCreateImages import BingCreateImages; return BingCreateImages
21 21 elif name == "BlackForestLabs_Flux1Dev":
@@ -48,9 +48,7 @@ def _resolve_provider(name: str) -> ProviderType:
48 48 from g4f.Provider.needs_auth.Custom import Custom; return Custom
49 49 elif name == "DeepInfra":
50 50 from g4f.Provider.deepinfra import DeepInfra; return DeepInfra
51 elif name == "DeepSeek":
52 from g4f.Provider.needs_auth.DeepSeek import DeepSeek; return DeepSeek
53 elif name == "DeepSeekAPI":
51 elif name == "DeepSeek" or name == "DeepSeekAPI":
54 52 from g4f.Provider.needs_auth.DeepSeek import DeepSeek; return DeepSeek
55 53 elif name == "EasyChat":
56 54 from g4f.Provider.EasyChat import EasyChat; return EasyChat
@@ -144,14 +142,14 @@ def _resolve_provider(name: str) -> ProviderType:
144 142 from g4f.Provider.PhindAi import PhindAi; return PhindAi
145 143 elif name == "Pi":
146 144 from g4f.Provider.needs_auth.Pi import Pi; return Pi
147 elif name == "PollinationsAI":
148 from g4f.Provider.PollinationsAI import PollinationsAI; return PollinationsAI
145 elif name == "Pollinations" or name == "PollinationsAI":
146 from g4f.Provider.Pollinations import Pollinations; return Pollinations
149 147 elif name == "PollinationsAudio":
150 148 from g4f.Provider.audio.PollinationsAudio import PollinationsAudio; return PollinationsAudio
151 149 elif name == "PollinationsImage":
152 150 from g4f.Provider.PollinationsImage import PollinationsImage; return PollinationsImage
153 elif name == "PuterJS":
154 from g4f.Provider.needs_auth.PuterJS import PuterJS; return PuterJS
151 elif name == "Puter" or name == "PuterJS":
152 from g4f.Provider.needs_auth.Puter import Puter; return Puter
155 153 elif name == "Qwen":
156 154 from g4f.Provider.Qwen import Qwen; return Qwen
157 155 elif name == "QwenCode":
@@ -299,10 +297,6 @@ _loaded_providers = {}
299 297 def __getattr__(name: str):
300 298 if name in _loaded_providers:
301 299 return _loaded_providers[name]
302 try:
303 return _resolve_provider(name)
304 except ImportError:
305 pass
306 300 if name == "__providers__":
307 301 # Load all providers if specifically requested
308 302 providers_list = []
@@ -312,8 +306,10 @@ def __getattr__(name: str):
312 306 except AttributeError:
313 307 pass
314 308 return providers_list
315
316 raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
309 try:
310 return _resolve_provider(name)
311 except ImportError as e:
312 raise AttributeError(f"module '{__name__}' has no attribute '{name}'") from e
317 313
318 314 def __dir__():
319 315 return __all__
@@ -345,7 +341,7 @@ class ProviderUtils:
345 341 def get_by_label(cls, label: str) -> ProviderType:
346 342 if not label:
347 343 raise ValueError("Label must be provided")
348
344
349 345 # Check explicit map
350 346 try:
351 347 return __getattr__(label)
Modified g4f/Provider/audio/PollinationsAudio.py +2 -2
@@ -16,12 +16,12 @@ from ...tools.run_tools import AuthManager
16 16 from ...image import to_bytes
17 17 from ...tools.media import merge_media
18 18 from ..helper import filter_none, format_media_prompt
19 from ..PollinationsAI import PollinationsAI
19 from ..Pollinations import Pollinations
20 20 from ... import debug
21 21
22 22 class PollinationsAudio(AsyncGeneratorProvider, ProviderModelMixin):
23 23 label = "PollinationsAudio"
24 parent = PollinationsAI.__name__
24 parent = Pollinations.__name__
25 25 active_by_default = False
26 26 working = True
27 27 supports_stream = False
Modified g4f/Provider/hf_space/__init__.py +3 -2
@@ -42,10 +42,11 @@ class HuggingSpace(AsyncGeneratorProvider, ProviderModelMixin):
42 42 cls.model_aliases = {}
43 43 for provider in cls.providers:
44 44 models.extend(provider.get_models(**kwargs))
45 models.extend(provider.model_aliases.keys())
45 models.extend([] if provider.model_aliases is None else provider.model_aliases.keys())
46 46 image_models.extend(provider.image_models)
47 47 vision_models.extend(provider.vision_models)
48 cls.model_aliases.update(provider.model_aliases)
48 if provider.model_aliases is not None:
49 cls.model_aliases.update(provider.model_aliases)
49 50 models = list(set(models))
50 51 models.sort()
51 52 cls.models = models
Renamed g4f/Provider/needs_auth/Airforce.py +1 -1
@@ -4,7 +4,7 @@ from ...typing import Messages, AsyncResult
4 4 from ..template import OpenaiTemplate
5 5 from ...errors import RateLimitError
6 6
7 class ApiAirforce(OpenaiTemplate):
7 class Airforce(OpenaiTemplate):
8 8 label = "Api.Airforce"
9 9 url = "https://api.airforce"
10 10 login_url = "https://panel.api.airforce/dashboard"
Modified g4f/Provider/needs_auth/Antigravity.py +1 -0
@@ -1349,6 +1349,7 @@ class Antigravity(AsyncGeneratorProvider, ProviderModelMixin):
1349 1349 working = True
1350 1350 supports_message_history = True
1351 1351 supports_system_message = True
1352 supports_native_tools = True
1352 1353 needs_auth = True
1353 1354 active_by_default = True
1354 1355
Modified g4f/Provider/needs_auth/GeminiCLI.py +1 -0
@@ -930,6 +930,7 @@ class GeminiCLI(AsyncGeneratorProvider, ProviderModelMixin):
930 930 supports_message_history = True
931 931 supports_system_message = True
932 932 needs_auth = True
933 supports_native_tools = True
933 934 active_by_default = True
934 935
935 936 auth_manager: Optional[AuthManager] = None
Renamed g4f/Provider/needs_auth/Puter.py +2 -3
@@ -1,6 +1,5 @@
1 1 from __future__ import annotations
2 2
3 import random
4 3 import json
5 4 import requests
6 5 from aiohttp import ClientSession
@@ -14,7 +13,7 @@ from ...errors import ResponseError, ModelNotFoundError, MissingAuthError
14 13 from ..helper import format_media_prompt
15 14 from ... import debug
16 15
17 class PuterJS(AsyncGeneratorProvider, ProviderModelMixin):
16 class Puter(AsyncGeneratorProvider, ProviderModelMixin):
18 17 label = "Puter.js"
19 18 url = "https://docs.puter.com/playground"
20 19 login_url = "https://github.com/HeyPuter/puter-cli"
@@ -233,7 +232,7 @@ class PuterJS(AsyncGeneratorProvider, ProviderModelMixin):
233 232 stream: bool = True,
234 233 api_key: str = None,
235 234 media: MediaListType = None,
236 extra_parameters: list[str] = ["temperature", "presence_penalty", "top_p", "frequency_penalty", "response_format", "tools", "parallel_tool_calls", "tool_choice", "reasoning_effort", "logit_bias", "voice", "modalities", "audio"],
235 extra_parameters: list[str] = ["temperature", "presence_penalty", "top_p", "frequency_penalty", "response_format", "tools", "parallel_tool_calls", "tool_choice", "reasoning_effort", "logit_bias", "voice", "modalities", "audio", "prompt_cache_key"],
237 236 **kwargs
238 237 ) -> AsyncResult:
239 238 if not api_key:
Modified g4f/Provider/needs_auth/__init__.py +2 -3
@@ -1,5 +1,5 @@
1 1 from .AIBadgr import AIBadgr
2 from .ApiAirforce import ApiAirforce
2 from .Airforce import Airforce
3 3 from .Anthropic import Anthropic
4 4 from .Antigravity import Antigravity
5 5 from .Azure import Azure
@@ -12,7 +12,6 @@ from .Cohere import Cohere
12 12 from .CopilotAccount import CopilotAccount
13 13 from .Custom import Custom
14 14 from .Custom import Feature
15 from .DeepSeek import DeepSeekAPI
16 15 from .FenayAI import FenayAI
17 16 from .Gemini import Gemini
18 17 from .GeminiPro import GeminiPro
@@ -35,7 +34,7 @@ from .OpenRouter import OpenRouter
35 34 from .OpenRouter import OpenRouterFree
36 35 from .PerplexityApi import PerplexityApi
37 36 from .Pi import Pi
38 from .PuterJS import PuterJS
37 from .Puter import Puter
39 38 from .Reka import Reka
40 39 from .Replicate import Replicate
41 40 from .ThebApi import ThebApi
Modified g4f/Provider/template/OpenaiTemplate.py +1 -1
@@ -147,7 +147,7 @@ class OpenaiTemplate(AsyncGeneratorProvider, ProviderModelMixin, RaiseErrorMixin
147 147 headers: dict = None,
148 148 impersonate: str = None,
149 149 download_media: bool = True,
150 extra_parameters: list[str] = ["tools", "parallel_tool_calls", "tool_choice", "reasoning_effort", "logit_bias", "modalities", "audio", "stream_options", "include_reasoning", "response_format", "max_completion_tokens", "reasoning_effort", "search_settings"],
150 extra_parameters: list[str] = ["tools", "parallel_tool_calls", "tool_choice", "reasoning_effort", "logit_bias", "modalities", "audio", "stream_options", "include_reasoning", "response_format", "max_completion_tokens", "reasoning_effort", "search_settings", "prompt_cache_key"],
151 151 extra_body: dict = None,
152 152 yield_request: bool = True,
153 153 **kwargs
Modified g4f/api/stubs.py +1 -0
@@ -50,6 +50,7 @@ class RequestConfig(BaseModel):
50 50 download_media: bool = False
51 51 raw: bool = False
52 52 extra_body: Optional[dict] = None
53 prompt_cache_key: Optional[str] = None
53 54 # When set (or when env G4F_TOOL_EMULATION=1), the server will attempt to
54 55 # emulate OpenAI tool_calls for providers that don't support tools natively.
55 56 tool_emulation: Optional[bool] = None
Modified g4f/gui/server/api.py +24 -19
Modified g4f/tools/run_tools.py +1 -1