返回提交历史
Modified
g4f/Provider/PollinationsAI.py
+1
-1
Modified
g4f/gui/server/backend_api.py
+1
-1
XFEstudio/gpt4free
fix: Update API key validation logic and enhance chunk handling in Backend_Api
000516c3
代码差异
2 个文件
+2
-2
@@ -381,7 +381,7 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
381
381
return f"{url}&seed={seed}" if seed else url
382
382
383
383
headers = None
384
if api_key and api_key.startswith("g4f_") or api_key.startswith("gfs_"):
384
if api_key and (api_key.startswith("g4f_") or api_key.startswith("gfs_")):
385
385
headers = {"authorization": f"Bearer {api_key}"}
386
386
async with ClientSession(
387
387
headers=DEFAULT_HEADERS,
@@ -331,7 +331,7 @@ class Backend_Api(Api):
331
331
for chunk in response:
332
332
if isinstance(chunk, FinishReason):
333
333
yield f"[{chunk.reason}]" if chunk.reason != "stop" else ""
334
elif not isinstance(chunk, Exception):
334
elif not isinstance(chunk, (Exception, JsonResponse)):
335
335
chunk = str(chunk)
336
336
if chunk:
337
337
yield chunk