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

Commit

Permalink
Fix the response check error based the new opanai response (#1468)
Browse files Browse the repository at this point in the history
* Fix the response check error based the new opanai response

The new openai response message contain a message without "message", so just continue to fix the whole programe exit.

* better checks

---------

Co-authored-by: Antonio Cheong <[email protected]>
  • Loading branch information
CornerOfSkyline and Antonio Cheong authored Jul 20, 2023
1 parent 8feb200 commit 9217c0c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/revChatGPT/V1.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ def __send_request(
except json.decoder.JSONDecodeError:
continue
if not self.__check_fields(line):
raise ValueError(f"Field missing. Details: {str(line)}")
if line.get("is_completion"):
raise ValueError(f"Field missing. Details: {str(line)}")
if line.get("message").get("author").get("role") != "assistant":
continue

Expand Down Expand Up @@ -1140,8 +1141,10 @@ async def __send_request(
line = json.loads(line)
except json.decoder.JSONDecodeError:
continue

if not self.__check_fields(line):
raise ValueError(f"Field missing. Details: {str(line)}")
if line.get("is_completion"):
raise ValueError(f"Field missing. Details: {str(line)}")
if line.get("message").get("author").get("role") != "assistant":
continue

Expand Down

0 comments on commit 9217c0c

Please sign in to comment.