diff options
author | catmeowjiao <meowjiao321@163.com> | 2023-10-27 11:33:47 +0200 |
---|---|---|
committer | catmeowjiao <meowjiao321@163.com> | 2023-10-27 11:33:47 +0200 |
commit | 325f8558da81fd7e6dacc0ed8e50859e285f116c (patch) | |
tree | b8e030a40f7d4afa9cd5c472d57b23ed2ed54b87 /g4f | |
parent | add proxy support (diff) | |
download | gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar.gz gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar.bz2 gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar.lz gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar.xz gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.tar.zst gpt4free-325f8558da81fd7e6dacc0ed8e50859e285f116c.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/api/__init__.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py index b78768bd..fec5606f 100644 --- a/g4f/api/__init__.py +++ b/g4f/api/__init__.py @@ -105,9 +105,25 @@ class Api: logger.info(f'model: {model}, stream: {stream}, request: {messages[-1]["content"]}') - response = self.engine.ChatCompletion.create(model=model, - stream=stream, messages=messages, - ignored=self.list_ignored_providers) + config = None + proxy = None + + try: + config = json.load(open("config.json","r",encoding="utf-8")) + proxy = config["proxy"] + + except Exception: + pass + + if proxy != None: + response = self.engine.ChatCompletion.create(model=model, + stream=stream, messages=messages, + ignored=self.list_ignored_providers, + proxy=proxy) + else: + response = self.engine.ChatCompletion.create(model=model, + 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()) |