summaryrefslogtreecommitdiffstats
path: root/g4f/api/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g4f/api/__init__.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py
index 4c945fbe..b78768bd 100644
--- a/g4f/api/__init__.py
+++ b/g4f/api/__init__.py
@@ -1,9 +1,6 @@
import typing
-
-import g4f;
from .. import BaseProvider
-
-g4f.logging = True
+import g4f; g4f.debug.logging = True
import time
import json
import random
@@ -48,7 +45,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',
@@ -58,18 +55,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/<model_id>', 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)
@@ -83,7 +80,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