diff --git a/request_llm/bridge_newbing.py b/request_llm/bridge_newbing.py index e65f6d0..c373c7d 100644 --- a/request_llm/bridge_newbing.py +++ b/request_llm/bridge_newbing.py @@ -49,7 +49,7 @@ class NewBingHandle(Process): def check_dependency(self): try: self.success = False - import rich + import certifi, httpx, rich self.info = "依赖检测通过,等待NewBing响应。注意目前不能多人同时调用NewBing接口(有线程锁),否则将导致每个人的NewBing问询历史互相渗透。调用NewBing时,会自动使用已配置的代理。" self.success = True except: diff --git a/request_llm/edge_gpt.py b/request_llm/edge_gpt.py index b896b94..bbf8400 100644 --- a/request_llm/edge_gpt.py +++ b/request_llm/edge_gpt.py @@ -19,8 +19,6 @@ from typing import Generator from typing import Literal from typing import Optional from typing import Union -import certifi -import httpx import websockets.client as websockets DELIMITER = "\x1e" @@ -78,8 +76,12 @@ HEADERS_INIT_CONVER = { "x-forwarded-for": FORWARDED_IP, } -ssl_context = ssl.create_default_context() -ssl_context.load_verify_locations(certifi.where()) +def get_ssl_context(): + import certifi + ssl_context = ssl.create_default_context() + ssl_context.load_verify_locations(certifi.where()) + return ssl_context + class NotAllowedToAccess(Exception): @@ -210,6 +212,7 @@ class _Conversation: "conversationSignature": None, "result": {"value": "Success", "message": None}, } + import httpx self.proxy = proxy proxy = ( proxy @@ -288,7 +291,7 @@ class _ChatHub: wss_link, extra_headers=HEADERS, max_size=None, - ssl=ssl_context, + ssl=get_ssl_context() ) await self._initial_handshake() # Construct a ChatHub request