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

XFEstudio/gpt4free

fix: update provider status to inactive and enhance error handling for Antigravity API

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

代码差异

6 个文件 +14 -9
Modified g4f/Provider/GradientNetwork.py +1 -1
@@ -17,7 +17,7 @@ class GradientNetwork(AsyncGeneratorProvider, ProviderModelMixin):
17 17 url = "https://chat.gradient.network"
18 18 api_endpoint = "https://chat.gradient.network/api/generate"
19 19
20 working = True
20 working = False
21 21 needs_auth = False
22 22 supports_stream = True
23 23 supports_system_message = True
Modified g4f/Provider/needs_auth/Antigravity.py +8 -3
@@ -30,7 +30,7 @@ import aiohttp
30 30 from aiohttp import ClientSession, ClientTimeout
31 31
32 32 from ...typing import AsyncResult, Messages, MediaListType
33 from ...errors import MissingAuthError
33 from ...errors import MissingAuthError, RateLimitError
34 34 from ...image.copy_images import save_response_media
35 35 from ...image import to_bytes, is_data_an_media
36 36 from ...providers.response import Usage, ImageResponse, ToolCalls, Reasoning
@@ -1234,8 +1234,13 @@ class AntigravityProvider:
1234 1234 if not resp.ok:
1235 1235 if resp.status == 401:
1236 1236 raise MissingAuthError("Unauthorized (401) from Antigravity API")
1237 error_body = await resp.text()
1238 raise RuntimeError(f"Antigravity API error {resp.status}: {error_body}")
1237 elif resp.status == 429:
1238 try:
1239 message = (await resp.json()).get("error", {}).get("message", "")
1240 except Exception:
1241 message = await resp.text()
1242 raise RateLimitError(f"Error 429: {message}")
1243 raise RuntimeError(f"Antigravity API error {resp.status}: {await resp.text()}")
1239 1244
1240 1245 usage_metadata = {}
1241 1246 async for json_data in parse_sse_stream(resp.content):
Modified g4f/Provider/needs_auth/Azure.py +1 -1
@@ -15,7 +15,7 @@ class Azure(OpenaiTemplate):
15 15 label = "Azure ☁️"
16 16 url = "https://ai.azure.com"
17 17 base_url = "https://g4f.space/api/azure"
18 working = True
18 working = False
19 19 active_by_default = False
20 20 quota_url = "https://g4f.space/api/azure/chat/completions"
21 21 routes: dict[str, str] = {}
Modified g4f/Provider/qwen/QwenCode.py +1 -1
@@ -18,7 +18,7 @@ class QwenCode(OpenaiTemplate):
18 18 label = "Qwen Code 🤖"
19 19 url = "https://qwen.ai"
20 20 login_url = "https://github.com/QwenLM/qwen-code"
21 working = True
21 working = False
22 22 needs_auth = True
23 23 active_by_default = True
24 24 default_model = "qwen3-coder-plus"
Modified g4f/api/__init__.py +2 -2
@@ -866,7 +866,7 @@ class Api:
866 866 # request_origin in the source directives.
867 867 csp = (
868 868 "sandbox allow-scripts allow-forms allow-downloads allow-popups; "
869 f"default-src {request_origin}; "
869 f"default-src {request_origin} https://g4f.space; "
870 870 f"script-src {request_origin} 'unsafe-inline'; "
871 871 f"style-src {request_origin} 'unsafe-inline'; "
872 872 f"img-src {request_origin} data:; "
@@ -880,7 +880,7 @@ class Api:
880 880 # sandboxing — they are leaf assets without their own browsing
881 881 # context. Use the request origin for source directives.
882 882 csp = (
883 f"default-src {request_origin}; "
883 f"default-src {request_origin} https://g4f.space; "
884 884 f"script-src {request_origin} 'unsafe-inline'; "
885 885 f"style-src {request_origin} 'unsafe-inline'; "
886 886 f"img-src {request_origin} data:; "
Modified g4f/mcp/server.py +1 -1
@@ -455,7 +455,7 @@ class MCPServer:
455 455 req_origin = f"{request.scheme}://{request.host}"
456 456 headers["content-security-policy"] = (
457 457 f"sandbox allow-scripts allow-forms allow-popups; "
458 f"default-src {req_origin}; "
458 f"default-src {req_origin} https://g4f.space; "
459 459 f"img-src {req_origin} data: blob:; "
460 460 f"font-src {req_origin}; "
461 461 f"style-src {req_origin} 'unsafe-inline'; "