Antonio Cheong
commited on
Commit
·
3334976
1
Parent(s):
0d7237c
Recv ping
Browse files- src/EdgeGPT.py +13 -5
src/EdgeGPT.py
CHANGED
@@ -175,7 +175,9 @@ class ChatHub:
|
|
175 |
|
176 |
async def __initial_handshake(self):
|
177 |
await self.wss.send(append_identifier({"protocol": "json", "version": 1}))
|
|
|
178 |
await self.wss.send(append_identifier({"type": 6}))
|
|
|
179 |
|
180 |
async def __ping(self):
|
181 |
while self.loop:
|
@@ -184,6 +186,7 @@ class ChatHub:
|
|
184 |
except asyncio.CancelledError:
|
185 |
break
|
186 |
await self.wss.send(append_identifier({"type": 6}))
|
|
|
187 |
|
188 |
async def close(self):
|
189 |
"""
|
@@ -222,14 +225,13 @@ class Chatbot:
|
|
222 |
Close the connection
|
223 |
"""
|
224 |
await self.chat_hub.close()
|
225 |
-
|
226 |
async def reset(self):
|
227 |
"""
|
228 |
Reset the conversation
|
229 |
"""
|
230 |
await self.close()
|
231 |
await self.start()
|
232 |
-
|
233 |
|
234 |
|
235 |
def get_input(prompt):
|
@@ -268,17 +270,23 @@ async def main():
|
|
268 |
if prompt == "!exit":
|
269 |
break
|
270 |
elif prompt == "!help":
|
271 |
-
print(
|
|
|
272 |
!help - Show this help message
|
273 |
!exit - Exit the program
|
274 |
!reset - Reset the conversation
|
275 |
-
"""
|
|
|
276 |
continue
|
277 |
elif prompt == "!reset":
|
278 |
await bot.reset()
|
279 |
continue
|
280 |
print("Bot:")
|
281 |
-
print(
|
|
|
|
|
|
|
|
|
282 |
await bot.close()
|
283 |
|
284 |
|
|
|
175 |
|
176 |
async def __initial_handshake(self):
|
177 |
await self.wss.send(append_identifier({"protocol": "json", "version": 1}))
|
178 |
+
await self.wss.recv()
|
179 |
await self.wss.send(append_identifier({"type": 6}))
|
180 |
+
await self.wss.recv()
|
181 |
|
182 |
async def __ping(self):
|
183 |
while self.loop:
|
|
|
186 |
except asyncio.CancelledError:
|
187 |
break
|
188 |
await self.wss.send(append_identifier({"type": 6}))
|
189 |
+
await self.wss.recv()
|
190 |
|
191 |
async def close(self):
|
192 |
"""
|
|
|
225 |
Close the connection
|
226 |
"""
|
227 |
await self.chat_hub.close()
|
228 |
+
|
229 |
async def reset(self):
|
230 |
"""
|
231 |
Reset the conversation
|
232 |
"""
|
233 |
await self.close()
|
234 |
await self.start()
|
|
|
235 |
|
236 |
|
237 |
def get_input(prompt):
|
|
|
270 |
if prompt == "!exit":
|
271 |
break
|
272 |
elif prompt == "!help":
|
273 |
+
print(
|
274 |
+
"""
|
275 |
!help - Show this help message
|
276 |
!exit - Exit the program
|
277 |
!reset - Reset the conversation
|
278 |
+
"""
|
279 |
+
)
|
280 |
continue
|
281 |
elif prompt == "!reset":
|
282 |
await bot.reset()
|
283 |
continue
|
284 |
print("Bot:")
|
285 |
+
print(
|
286 |
+
(await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
|
287 |
+
"body"
|
288 |
+
][0]["text"]
|
289 |
+
)
|
290 |
await bot.close()
|
291 |
|
292 |
|