Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Make raw actually raw #582

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/EdgeGPT/chathub.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ async def ask_stream(
continue
response = json.loads(obj)
# print(response)
if response.get("type") != 2 and raw:
yield False, response
elif response.get("type") == 1 and response["arguments"][0].get(
if response.get("type") == 1 and response["arguments"][0].get(
"messages",
):
if not draw:
Expand All @@ -166,7 +164,7 @@ async def ask_stream(
if (
response["arguments"][0]["messages"][0]["contentOrigin"]
!= "Apology"
) and not draw:
) and not draw and not raw:
resp_txt = result_text + response["arguments"][0][
"messages"
][0]["adaptiveCards"][0]["body"][0].get("text", "")
Expand All @@ -190,7 +188,8 @@ async def ask_stream(
][0]["body"][0]["inlines"][0].get("text")
+ "\n"
)
yield False, resp_txt
if not raw:
yield False, resp_txt

elif response.get("type") == 2:
if response["item"]["result"].get("error"):
Expand Down Expand Up @@ -221,10 +220,13 @@ async def ask_stream(
await wss.close()
yield True, response
return
elif response.get("type") == 6:
await wss.send(append_identifier({"type": 6}))
elif response.get("type") == 7:
await wss.send(append_identifier({"type": 7}))
if response.get("type") != 2:
if response.get("type") == 6:
await wss.send(append_identifier({"type": 6}))
elif response.get("type") == 7:
await wss.send(append_identifier({"type": 7}))
elif raw:
yield False, response

async def _initial_handshake(self, wss: WebSocketClientProtocol) -> None:
await wss.send(append_identifier({"protocol": "json", "version": 1}))
Expand Down