Skip to content

Commit

Permalink
Add files via upload (acheong08#582)
Browse files Browse the repository at this point in the history
fix acheong08#579

Co-authored-by: renqabs <130155002+renqabs@users.noreply.github.com>
  • Loading branch information
Antonio Cheong and renqabs committed Jun 29, 2023
1 parent cea9405 commit 5cbb6e3
Showing 1 changed file with 11 additions and 9 deletions.
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

0 comments on commit 5cbb6e3

Please sign in to comment.