返回提交历史
Added
g4f/Provider/FreeRouter.py
+9
-0
Modified
g4f/Provider/__init__.py
+1
-0
Modified
g4f/Provider/needs_auth/CablyAI.py
+1
-1
Modified
g4f/Provider/needs_auth/Gemini.py
+4
-0
Added
g4f/Provider/needs_auth/OpenRouter.py
+11
-0
Modified
g4f/Provider/needs_auth/__init__.py
+1
-0
XFEstudio/gpt4free
feat: add FreeRouter and OpenRouter providers with Gemini model updates
- Add new FreeRouter provider (based on OpenaiTemplate) - Add new OpenRouter provider (needs auth) to access OpenRouter.ai service - Update CablyAI provider imports to use Messages and AsyncResult - Add support for new Gemini models including gemini-2.5-pro-exp, gemini-2.0-flash-thinking-exp, and gemini-deep-research - Add processing for <think> tags in Gemini provider output by replacing <ctrl94>thought and <ctrl95> markers - Update provider imports in __init__.py files to include the new providers - Mark FreeRouter as not working initially
93f055d9
代码差异
6 个文件
+27
-1
@@ -0,0 +1,9 @@
1
from __future__ import annotations
2
3
from .template import OpenaiTemplate
4
5
class FreeRouter(OpenaiTemplate):
6
label = "CablyAI FreeRouter"
7
url = "https://freerouter.cablyai.com"
8
api_base = "https://freerouter.cablyai.com/v1"
9
working = False
@@ -48,6 +48,7 @@ except ImportError as e:
48
48
try:
49
49
from .Free2GPT import Free2GPT
50
50
from .FreeGpt import FreeGpt
51
from .FreeRouter import FreeRouter
51
52
from .GizAI import GizAI
52
53
from .Glider import Glider
53
54
from .Goabror import Goabror
@@ -1,6 +1,6 @@
1
1
from __future__ import annotations
2
2
3
from ...errors import ModelNotSupportedError
3
from ...typing import Messages, AsyncResult
4
4
from ..template import OpenaiTemplate
5
5
6
6
class CablyAI(OpenaiTemplate):
@@ -61,6 +61,9 @@ ROTATE_COOKIES_URL = "https://accounts.google.com/RotateCookies"
61
61
GGOGLE_SID_COOKIE = "__Secure-1PSID"
62
62
63
63
models = {
64
"gemini-2.5-pro-exp": {"x-goog-ext-525001261-jspb": '[1,null,null,null,"2525e3954d185b3c"]'},
65
"gemini-2.0-flash-thinking-exp": {"x-goog-ext-525001261-jspb": '[1,null,null,null,"7ca48d02d802f20a"]'},
66
"gemini-deep-research": {"x-goog-ext-525001261-jspb": '[1,null,null,null,"cd472a54d2abba7e"]'},
64
67
"gemini-2.0-flash": {"x-goog-ext-525001261-jspb": '[null,null,null,null,"f299729663a2343f"]'},
65
68
"gemini-2.0-flash-exp": {"x-goog-ext-525001261-jspb": '[null,null,null,null,"f299729663a2343f"]'},
66
69
"gemini-2.0-flash-thinking": {"x-goog-ext-525001261-jspb": '[null,null,null,null,"9c17b1863f581b8a"]'},
@@ -267,6 +270,7 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
267
270
pattern = r"http://googleusercontent.com/(?:image_generation|youtube|map)_content/\d+"
268
271
content = re.sub(pattern, "", content)
269
272
content = content.replace("<!-- end list -->", "")
273
content = content.replace("<ctrl94>thought", "<think>").replace("<ctrl95>", "</think>")
270
274
def replace_link(match):
271
275
return f"(https://{quote_plus(unquote_plus(match.group(1)), '/?&=#')})"
272
276
content = re.sub(r"\(https://www.google.com/(?:search\?q=|url\?sa=E&source=gmail&q=)https?://(.+?)\)", replace_link, content)
@@ -0,0 +1,11 @@
1
from __future__ import annotations
2
3
from ..template import OpenaiTemplate
4
5
class OpenRouter(OpenaiTemplate):
6
label = "OpenRouter"
7
url = "https://openrouter.ai"
8
login_url = "https://openrouter.ai/settings/keys"
9
api_base = "https://openrouter.ai/api/v1"
10
working = True
11
needs_auth = True
@@ -21,6 +21,7 @@ from .MicrosoftDesigner import MicrosoftDesigner
21
21
from .OpenaiAccount import OpenaiAccount
22
22
from .OpenaiAPI import OpenaiAPI
23
23
from .OpenaiChat import OpenaiChat
24
from .OpenRouter import OpenRouter
24
25
from .PerplexityApi import PerplexityApi
25
26
from .Reka import Reka
26
27
from .Replicate import Replicate