修改依赖的引用方式

This commit is contained in:
Your Name 2023-04-23 23:39:54 +08:00
parent 3814c3a915
commit 59bed52faf
2 changed files with 9 additions and 6 deletions

View File

@ -49,7 +49,7 @@ class NewBingHandle(Process):
def check_dependency(self): def check_dependency(self):
try: try:
self.success = False self.success = False
import rich import certifi, httpx, rich
self.info = "依赖检测通过等待NewBing响应。注意目前不能多人同时调用NewBing接口有线程锁否则将导致每个人的NewBing问询历史互相渗透。调用NewBing时会自动使用已配置的代理。" self.info = "依赖检测通过等待NewBing响应。注意目前不能多人同时调用NewBing接口有线程锁否则将导致每个人的NewBing问询历史互相渗透。调用NewBing时会自动使用已配置的代理。"
self.success = True self.success = True
except: except:

View File

@ -19,8 +19,6 @@ from typing import Generator
from typing import Literal from typing import Literal
from typing import Optional from typing import Optional
from typing import Union from typing import Union
import certifi
import httpx
import websockets.client as websockets import websockets.client as websockets
DELIMITER = "\x1e" DELIMITER = "\x1e"
@ -78,8 +76,12 @@ HEADERS_INIT_CONVER = {
"x-forwarded-for": FORWARDED_IP, "x-forwarded-for": FORWARDED_IP,
} }
ssl_context = ssl.create_default_context() def get_ssl_context():
ssl_context.load_verify_locations(certifi.where()) import certifi
ssl_context = ssl.create_default_context()
ssl_context.load_verify_locations(certifi.where())
return ssl_context
class NotAllowedToAccess(Exception): class NotAllowedToAccess(Exception):
@ -210,6 +212,7 @@ class _Conversation:
"conversationSignature": None, "conversationSignature": None,
"result": {"value": "Success", "message": None}, "result": {"value": "Success", "message": None},
} }
import httpx
self.proxy = proxy self.proxy = proxy
proxy = ( proxy = (
proxy proxy
@ -288,7 +291,7 @@ class _ChatHub:
wss_link, wss_link,
extra_headers=HEADERS, extra_headers=HEADERS,
max_size=None, max_size=None,
ssl=ssl_context, ssl=get_ssl_context()
) )
await self._initial_handshake() await self._initial_handshake()
# Construct a ChatHub request # Construct a ChatHub request