diff options
Diffstat (limited to 'g4f/api/__init__.py')
-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") |