mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-05 00:01:00 +00:00
add api proxy
This commit is contained in:
parent
6fd2fa971f
commit
325f8558da
@ -105,9 +105,25 @@ class Api:
|
|||||||
|
|
||||||
logger.info(f'model: {model}, stream: {stream}, request: {messages[-1]["content"]}')
|
logger.info(f'model: {model}, stream: {stream}, request: {messages[-1]["content"]}')
|
||||||
|
|
||||||
response = self.engine.ChatCompletion.create(model=model,
|
config = None
|
||||||
stream=stream, messages=messages,
|
proxy = None
|
||||||
ignored=self.list_ignored_providers)
|
|
||||||
|
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_id = ''.join(random.choices(string.ascii_letters + string.digits, k=28))
|
||||||
completion_timestamp = int(time.time())
|
completion_timestamp = int(time.time())
|
||||||
|
Loading…
Reference in New Issue
Block a user