Antonio Cheong commited on
Commit
0795fe7
·
1 Parent(s): 759f47c
Files changed (3) hide show
  1. example.env +1 -1
  2. example.py +3 -1
  3. src/EdgeGPT.py +10 -6
example.env CHANGED
@@ -1 +1 @@
1
- export BING_U="<COOKIE_VALUE>"
 
1
+ export BING_U="<COOKIE_VALUE>"
example.py CHANGED
@@ -1,4 +1,5 @@
1
  import json
 
2
  from EdgeGPT import Chatbot
3
 
4
 
@@ -7,7 +8,8 @@ async def main():
7
  await bot.start()
8
 
9
  result = json.dumps(
10
- await bot.ask("Check GitHub for a repository names 'EdgeGPT'"), indent=4
 
11
  )
12
  print(result)
13
 
 
1
  import json
2
+
3
  from EdgeGPT import Chatbot
4
 
5
 
 
8
  await bot.start()
9
 
10
  result = json.dumps(
11
+ await bot.ask("Check GitHub for a repository names 'EdgeGPT'"),
12
+ indent=4,
13
  )
14
  print(result)
15
 
src/EdgeGPT.py CHANGED
@@ -4,8 +4,8 @@ Main.py
4
  import asyncio
5
  import json
6
  import os
7
- import uuid
8
  import sys
 
9
 
10
  import requests
11
  import websockets.client as websockets
@@ -129,7 +129,9 @@ class Conversation:
129
  try:
130
  self.struct = response.json()
131
  except json.decoder.JSONDecodeError:
132
- raise Exception("Authentication failed. You have not been accepted into the beta.") from json.decoder.JSONDecodeError
 
 
133
 
134
 
135
  class ChatHub:
@@ -155,7 +157,9 @@ class ChatHub:
155
  # Check if websocket is closed
156
  if self.wss:
157
  if self.wss.closed:
158
- self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
 
 
159
  await self.__initial_handshake()
160
  else:
161
  self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
@@ -252,7 +256,7 @@ async def main():
252
  !help - Show this help message
253
  !exit - Exit the program
254
  !reset - Reset the conversation
255
- """
256
  )
257
  continue
258
  elif prompt == "!reset":
@@ -262,7 +266,7 @@ async def main():
262
  print(
263
  (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
264
  "body"
265
- ][0]["text"]
266
  )
267
  await bot.close()
268
 
@@ -278,6 +282,6 @@ if __name__ == "__main__":
278
 
279
  Type !exit to exit
280
  Enter twice to send message
281
- """
282
  )
283
  asyncio.run(main())
 
4
  import asyncio
5
  import json
6
  import os
 
7
  import sys
8
+ import uuid
9
 
10
  import requests
11
  import websockets.client as websockets
 
129
  try:
130
  self.struct = response.json()
131
  except json.decoder.JSONDecodeError:
132
+ raise Exception(
133
+ "Authentication failed. You have not been accepted into the beta."
134
+ ) from json.decoder.JSONDecodeError
135
 
136
 
137
  class ChatHub:
 
157
  # Check if websocket is closed
158
  if self.wss:
159
  if self.wss.closed:
160
+ self.wss = await websockets.connect(
161
+ "wss://sydney.bing.com/sydney/ChatHub"
162
+ )
163
  await self.__initial_handshake()
164
  else:
165
  self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
 
256
  !help - Show this help message
257
  !exit - Exit the program
258
  !reset - Reset the conversation
259
+ """,
260
  )
261
  continue
262
  elif prompt == "!reset":
 
266
  print(
267
  (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
268
  "body"
269
+ ][0]["text"],
270
  )
271
  await bot.close()
272
 
 
282
 
283
  Type !exit to exit
284
  Enter twice to send message
285
+ """,
286
  )
287
  asyncio.run(main())