fix chatgpt 使用代理开关
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user