summaryrefslogtreecommitdiffstats
path: root/g4f/api
diff options
context:
space:
mode:
authorAndPim4912 <52836885+AndPim4912@users.noreply.github.com>2023-10-23 14:10:28 +0200
committerGitHub <noreply@github.com>2023-10-23 14:10:28 +0200
commit8d7ad98fcb314453c01f6dcd4bfe59016efd78ce (patch)
tree4d39804e1aa1724560e1688f0b6d4c124b9771c7 /g4f/api
parentRefactor API initialization to accept a list of ignored providers. (diff)
parentDebug config in api (diff)
downloadgpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.gz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.bz2
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.lz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.xz
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.tar.zst
gpt4free-8d7ad98fcb314453c01f6dcd4bfe59016efd78ce.zip
Diffstat (limited to 'g4f/api')
-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