Antonio Cheong
commited on
Commit
·
d2ff37d
1
Parent(s):
b084de8
ensure it always is connected
Browse files- src/EdgeGPT.py +9 -8
src/EdgeGPT.py
CHANGED
@@ -7,7 +7,6 @@ import asyncio
|
|
7 |
import json
|
8 |
import os
|
9 |
import random
|
10 |
-
import sys
|
11 |
import uuid
|
12 |
from enum import Enum
|
13 |
from typing import Generator
|
@@ -243,14 +242,16 @@ class ChatHub:
|
|
243 |
"""
|
244 |
Ask a question to the bot
|
245 |
"""
|
|
|
|
|
|
|
246 |
# Check if websocket is closed
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
await self.__initial_handshake()
|
254 |
# Construct a ChatHub request
|
255 |
self.request.update(prompt=prompt, conversation_style=conversation_style)
|
256 |
# Send request
|
|
|
7 |
import json
|
8 |
import os
|
9 |
import random
|
|
|
10 |
import uuid
|
11 |
from enum import Enum
|
12 |
from typing import Generator
|
|
|
242 |
"""
|
243 |
Ask a question to the bot
|
244 |
"""
|
245 |
+
if self.wss:
|
246 |
+
if not self.wss.closed:
|
247 |
+
await self.wss.close()
|
248 |
# Check if websocket is closed
|
249 |
+
self.wss = await websockets.connect(
|
250 |
+
"wss://sydney.bing.com/sydney/ChatHub",
|
251 |
+
extra_headers=HEADERS,
|
252 |
+
max_size=None,
|
253 |
+
)
|
254 |
+
await self.__initial_handshake()
|
|
|
255 |
# Construct a ChatHub request
|
256 |
self.request.update(prompt=prompt, conversation_style=conversation_style)
|
257 |
# Send request
|