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

XFEstudio/gpt4free

fix: Update active_by_default to False for Claude and Cohere providers; refactor Gemini login methods and enhance OpenRouterFree class

1d8186a9
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

5 个文件 +20 -8
Modified g4f/Provider/needs_auth/Claude.py +1 -1
@@ -11,7 +11,7 @@ class Claude(OpenaiTemplate):
11 11 url = "https://claude.ai"
12 12 base_url = "https://g4f.space/api/claude"
13 13 working = True
14 active_by_default = True
14 active_by_default = False
15 15 login_url = "https://discord.gg/qXA4Wf4Fsm"
16 16 organization_id = None
17 17
Modified g4f/Provider/needs_auth/Cohere.py +1 -1
@@ -17,7 +17,7 @@ class Cohere(AsyncGeneratorProvider, ProviderModelMixin):
17 17 login_url = "https://dashboard.cohere.com/api-keys"
18 18 api_endpoint = "https://api.cohere.ai/v2/chat"
19 19 working = True
20 active_by_default = True
20 active_by_default = False
21 21 needs_auth = True
22 22 models_needs_auth = True
23 23 supports_stream = True
Modified g4f/Provider/needs_auth/Gemini.py +8 -2
@@ -105,7 +105,7 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
105 105 rotate_tasks = {}
106 106
107 107 @classmethod
108 async def login(cls, proxy: str = None) -> AsyncIterator[str]:
108 async def login_generator(cls, proxy: str = None) -> AsyncIterator[str]:
109 109 if not has_nodriver:
110 110 debug.log("Skip nodriver login in Gemini provider")
111 111 return
@@ -122,6 +122,12 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
122 122 finally:
123 123 await stop_browser()
124 124
125 @classmethod
126 async def login(cls, proxy: str = None) -> AsyncIterator[str]:
127 async for _ in cls.login_generator(proxy):
128 pass
129 return {"success": True, "message": "Login successful"}
130
125 131 @classmethod
126 132 async def start_auto_refresh(cls, proxy: str = None) -> None:
127 133 """
@@ -200,7 +206,7 @@ class Gemini(AsyncGeneratorProvider, ProviderModelMixin):
200 206 await cls.fetch_snlm0e(session, cls._cookies) if cls._cookies else None
201 207 if not cls._snlm0e:
202 208 try:
203 async for chunk in cls.login(proxy):
209 async for chunk in cls.login_generator(proxy):
204 210 yield chunk
205 211 except Exception as e:
206 212 raise MissingAuthError('Missing or invalid "__Secure-1PSID" cookie', e)
Modified g4f/Provider/needs_auth/OpenRouter.py +7 -3
@@ -11,10 +11,14 @@ class OpenRouter(OpenaiTemplate):
11 11 needs_auth = True
12 12 default_model = "openrouter/auto"
13 13
14 class OpenRouterFree(OpenRouter):
14 class OpenRouterFree(OpenaiTemplate):
15 15 label = "OpenRouter (free)"
16 base_url = "https://g4f.space/api/openrouter"
17 max_tokens = 4096
16 url = "https://openrouter.ai"
17 login_url = "https://openrouter.ai/settings/keys"
18 base_url = "https://openrouter.ai/api/v1"
19 backup_url = "https://g4f.space/api/openrouter"
20 max_tokens = 8192
21 working = True
18 22 active_by_default = True
19 23 default_model = "openrouter/free"
20 24
Modified g4f/Provider/template/OpenaiTemplate.py +3 -1
@@ -39,8 +39,10 @@ class OpenaiTemplate(AsyncGeneratorProvider, ProviderModelMixin, RaiseErrorMixin
39 39 """Get the quota information for the API key."""
40 40 if not api_key:
41 41 api_key = AuthManager.load_api_key(cls)
42 if cls.models_needs_auth and cls.quota_url is None:
42 if api_key and cls.models_needs_auth and cls.quota_url is None:
43 43 cls.quota_url = f"{cls.base_url}/models"
44 if cls.quota_url is None and cls.backup_url is not None:
45 cls.quota_url = f"{cls.backup_url}/chat/completions"
44 46 if cls.quota_url is not None:
45 47 return await super().get_quota(api_key=api_key, **kwargs)
46 48 if not api_key and cls.needs_auth: