diff options
author | foxfire52 <foxfire52@virgilio.it> | 2024-11-15 07:38:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 07:38:51 +0100 |
commit | f38428ab23a1ec1f6ee22b976189d7e9da9b9167 (patch) | |
tree | d1f0ab8b2f849a8162e2a1430910d0b41d300de5 /g4f/api/__init__.py | |
parent | Merge pull request #2331 from NoelisTired/main (diff) | |
download | gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar.gz gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar.bz2 gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar.lz gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar.xz gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.tar.zst gpt4free-f38428ab23a1ec1f6ee22b976189d7e9da9b9167.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/api/__init__.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 754a48f1..3e29c5f8 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -22,6 +22,8 @@ from g4f.client import Client, ChatCompletion, ChatCompletionChunk, ImagesRespon from g4f.typing import Messages from g4f.cookies import read_cookie_files +logger = logging.getLogger(__name__) + def create_app(g4f_api_key: str = None): app = FastAPI() @@ -200,14 +202,14 @@ class Api: except GeneratorExit: pass except Exception as e: - logging.exception(e) + logger.exception(e) yield f'data: {format_exception(e, config)}\n\n' yield "data: [DONE]\n\n" return StreamingResponse(streaming(), media_type="text/event-stream") except Exception as e: - logging.exception(e) + logger.exception(e) return Response(content=format_exception(e, config), status_code=500, media_type="application/json") @self.app.post("/v1/images/generate") @@ -222,7 +224,7 @@ class Api: response_data = [image.to_dict() for image in response.data] return JSONResponse({"data": response_data}) except Exception as e: - logging.exception(e) + logger.exception(e) return Response(content=format_exception(e, config), status_code=500, media_type="application/json") @self.app.post("/v1/completions") |