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

XFEstudio/gpt4free

Refine API key requirement checks in Api class to simplify demo path handling

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

代码差异

1 个文件 +3 -3
Modified g4f/api/__init__.py +3 -3
@@ -478,7 +478,7 @@ class Api:
478 478 path.startswith("/v1/")
479 479 or (path.startswith("/api/") and path != "/api/logs")
480 480 or (path.startswith("/pa/") and not demo)
481 or (demo and path in ["/backend-api/v2/upload_cookies", "/api/logs"])
481 or (demo and path in ["/backend-api/v2/upload_cookies"])
482 482 )
483 483
484 484 @self.app.middleware("http")
@@ -536,11 +536,11 @@ class Api:
536 536 return ErrorResponse.from_message("G4F API key required", HTTP_401_UNAUTHORIZED)
537 537 if AppConfig.g4f_api_key is None and user is None:
538 538 return ErrorResponse.from_message("Invalid G4F API key", HTTP_403_FORBIDDEN)
539 elif not AppConfig.demo and not path.startswith("/images/") and not path.startswith("/media/"):
539 elif path == "/logs" or (not AppConfig.demo and not path.startswith("/images/") and not path.startswith("/media/")):
540 540 if user_g4f_api_key:
541 541 if user is None:
542 542 return ErrorResponse.from_message("Invalid G4F API key", HTTP_403_FORBIDDEN)
543 elif path.startswith("/backend-api/") or path.startswith("/chat/") or path.startswith("/playground/") or path in ["/logs", "/api/logs"]:
543 elif path.startswith("/backend-api/") or path.startswith("/chat/") or path.startswith("/playground/") or path in ["/logs"]:
544 544 try:
545 545 user = await self.get_username(request)
546 546 except HTTPException as e: