diff options
author | ⲘrṨhส∂ow <71973368+MrShadowDev@users.noreply.github.com> | 2023-10-23 09:46:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 09:46:25 +0200 |
commit | 3982f39424ea037aca1086d45c6f657b4bfc457c (patch) | |
tree | 987290c5dc5822cb0197e789df68488536b1637c /g4f/api/__init__.py | |
parent | ~ | g4f `v-0.1.7.5` (diff) | |
download | gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.gz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.bz2 gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.lz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.xz gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.tar.zst gpt4free-3982f39424ea037aca1086d45c6f657b4bfc457c.zip |
Diffstat (limited to 'g4f/api/__init__.py')
-rw-r--r-- | g4f/api/__init__.py | 12 |
1 files changed, 6 insertions, 6 deletions
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/<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) @@ -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 |