diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-10-23 14:53:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 14:53:48 +0200 |
commit | aa95d30732211877166535096b6eb6310d21283e (patch) | |
tree | 9beddcdd73e6ddc0ae999e07f14c03d7b4fe5c5c /g4f/api/__init__.py | |
parent | Merge pull request #1126 from Luneye/patch-3 (diff) | |
parent | Merge branch 'main' into api-ignore-providers (diff) | |
download | gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.gz gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.bz2 gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.lz gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.xz gpt4free-aa95d30732211877166535096b6eb6310d21283e.tar.zst gpt4free-aa95d30732211877166535096b6eb6310d21283e.zip |
Diffstat (limited to 'g4f/api/__init__.py')
-rw-r--r-- | g4f/api/__init__.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index 4bb4d52e..b78768bd 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -1,3 +1,5 @@ +import typing +from .. import BaseProvider import g4f; g4f.debug.logging = True import time import json @@ -26,10 +28,12 @@ class Api: __default_ip = '127.0.0.1' __default_port = 1337 - def __init__(self, engine: g4f, debug: bool = True, sentry: bool = False) -> None: + def __init__(self, engine: g4f, debug: bool = True, sentry: bool = False, + list_ignored_providers:typing.List[typing.Union[str, BaseProvider]]=None) -> None: self.engine = engine self.debug = debug self.sentry = sentry + self.list_ignored_providers = list_ignored_providers self.log_level = logging.DEBUG if debug else logging.WARN hook_logging(level=self.log_level, format='[%(asctime)s] %(levelname)s in %(module)s: %(message)s') @@ -102,7 +106,8 @@ class Api: logger.info(f'model: {model}, stream: {stream}, request: {messages[-1]["content"]}') response = self.engine.ChatCompletion.create(model=model, - stream=stream, messages=messages) + stream=stream, messages=messages, + ignored=self.list_ignored_providers) completion_id = ''.join(random.choices(string.ascii_letters + string.digits, k=28)) completion_timestamp = int(time.time()) |