Spaces:
Paused
Paused
:boom: [Fix] Several typos
Browse files- README.md +2 -2
- conversation_creater.py +6 -6
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
## Bing-Chat-API
|
2 |
|
3 |
-
A successor
|
4 |
|
5 |
-
**Note: This
|
6 |
|
7 |
After completing some key features, I would focus on the quick deployment of this project.
|
8 |
|
|
|
1 |
## Bing-Chat-API
|
2 |
|
3 |
+
A successor to [EdgeGPT](https://github.com/acheong08/EdgeGPT) by [acheong08](https://github.com/acheong08).
|
4 |
|
5 |
+
**Note: This project is in rapid progress, and currently is not ready to be used in production.**
|
6 |
|
7 |
After completing some key features, I would focus on the quick deployment of this project.
|
8 |
|
conversation_creater.py
CHANGED
@@ -35,7 +35,7 @@ class ConversationCreator:
|
|
35 |
# pprint.pprint(self.response_headers)
|
36 |
|
37 |
|
38 |
-
def
|
39 |
return json.dumps(msg, ensure_ascii=False) + "\x1e"
|
40 |
|
41 |
|
@@ -60,10 +60,10 @@ class ConversationChatter:
|
|
60 |
|
61 |
async def _init_handshake(self, wss):
|
62 |
await wss.send_str(
|
63 |
-
|
64 |
)
|
65 |
await wss.receive_str()
|
66 |
-
await wss.send_str(
|
67 |
|
68 |
async def stream_chat(self, prompt=""):
|
69 |
self.aio_session = aiohttp.ClientSession(cookies=self.cookies)
|
@@ -87,17 +87,17 @@ class ConversationChatter:
|
|
87 |
)
|
88 |
|
89 |
await self._init_handshake(wss)
|
90 |
-
|
91 |
prompt=prompt,
|
92 |
conversation_style="precise",
|
93 |
client_id=self.client_id,
|
94 |
conversation_id=self.conversation_id,
|
95 |
invocation_id=self.invocation_id,
|
96 |
)
|
97 |
-
|
98 |
|
99 |
await wss.send_str(
|
100 |
-
|
101 |
)
|
102 |
|
103 |
delta_content_pointer = 0
|
|
|
35 |
# pprint.pprint(self.response_headers)
|
36 |
|
37 |
|
38 |
+
def serialize_websocket_message(msg: dict) -> str:
|
39 |
return json.dumps(msg, ensure_ascii=False) + "\x1e"
|
40 |
|
41 |
|
|
|
60 |
|
61 |
async def _init_handshake(self, wss):
|
62 |
await wss.send_str(
|
63 |
+
serialize_websocket_message({"protocol": "json", "version": 1})
|
64 |
)
|
65 |
await wss.receive_str()
|
66 |
+
await wss.send_str(serialize_websocket_message({"type": 6}))
|
67 |
|
68 |
async def stream_chat(self, prompt=""):
|
69 |
self.aio_session = aiohttp.ClientSession(cookies=self.cookies)
|
|
|
87 |
)
|
88 |
|
89 |
await self._init_handshake(wss)
|
90 |
+
chathub_request_constructor = ChathubRequestConstructor(
|
91 |
prompt=prompt,
|
92 |
conversation_style="precise",
|
93 |
client_id=self.client_id,
|
94 |
conversation_id=self.conversation_id,
|
95 |
invocation_id=self.invocation_id,
|
96 |
)
|
97 |
+
chathub_request_constructor.construct()
|
98 |
|
99 |
await wss.send_str(
|
100 |
+
serialize_websocket_message(chathub_request_constructor.request_message)
|
101 |
)
|
102 |
|
103 |
delta_content_pointer = 0
|