From 3982f39424ea037aca1086d45c6f657b4bfc457c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=B2=98r=E1=B9=A8h=E0=B8=AA=E2=88=82ow?= <71973368+MrShadowDev@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:46:25 +0200 Subject: 'Refactored by Sourcery' (#1125) Co-authored-by: Sourcery AI <> --- g4f/api/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'g4f/api') diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index a682f094..eb7f4bf0 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -41,7 +41,7 @@ class Api: def run(self, bind_str, threads=8): host, port = self.__parse_bind(bind_str) - + CORS(self.app, resources={r'/v1/*': {'supports_credentials': True, 'expose_headers': [ 'Content-Type', 'Authorization', @@ -51,18 +51,18 @@ class Api: 'Access-Control-Request-Method', 'Access-Control-Request-Headers', 'Content-Disposition'], 'max_age': 600}}) - + self.app.route('/v1/models', methods=['GET'])(self.models) self.app.route('/v1/models/', methods=['GET'])(self.model_info) - + self.app.route('/v1/chat/completions', methods=['POST'])(self.chat_completions) self.app.route('/v1/completions', methods=['POST'])(self.completions) for ex in default_exceptions: self.app.register_error_handler(ex, self.__handle_error) - + if not self.debug: - self.logger.warning('Serving on http://{}:{}'.format(host, port)) + self.logger.warning(f'Serving on http://{host}:{port}') WSGIRequestHandler.protocol_version = 'HTTP/1.1' serve(self.app, host=host, port=port, ident=None, threads=threads) @@ -76,7 +76,7 @@ class Api: @staticmethod def __after_request(resp): - resp.headers['X-Server'] = 'g4f/%s' % g4f.version + resp.headers['X-Server'] = f'g4f/{g4f.version}' return resp -- cgit v1.2.3 From 9eee45023e1c6253e56d6df620a39fc4b6732276 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 23 Oct 2023 13:54:37 +0200 Subject: Debug config in api --- g4f/api/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'g4f/api') diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index eb7f4bf0..4bb4d52e 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -1,4 +1,4 @@ -import g4f; g4f.logging = True +import g4f; g4f.debug.logging = True import time import json import random -- cgit v1.2.3