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

XFEstudio/gpt4free

fix: Update API key validation logic and enhance chunk handling in Backend_Api

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

代码差异

2 个文件 +2 -2
Modified g4f/Provider/PollinationsAI.py +1 -1
@@ -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,
Modified g4f/gui/server/backend_api.py +1 -1
@@ -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