add api proxy

This commit is contained in:
catmeowjiao 2023-10-27 17:33:47 +08:00
parent 6fd2fa971f
commit 325f8558da

View File

@ -105,6 +105,22 @@ class Api:
logger.info(f'model: {model}, stream: {stream}, request: {messages[-1]["content"]}')
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)