fix chatgpt 使用代理开关

This commit is contained in:
thsrite
2023-08-11 14:44:50 +08:00
parent 987552558a
commit 8a7b2c0289
2 changed files with 25 additions and 2 deletions

View File

@ -12,11 +12,13 @@ class OpenAi:
_api_key: str = None
_api_url: str = None
def __init__(self, api_key: str = None, api_url: str = None):
def __init__(self, api_key: str = None, api_url: str = None, proxy: dict = None):
self._api_key = api_key
self._api_url = api_url
openai.api_base = self._api_url + "/v1"
openai.api_key = self._api_key
if proxy and proxy.get("https"):
openai.proxy = proxy.get("https")
def get_state(self) -> bool:
return True if self._api_key else False