Merge pull request #147 from yousefissa/yi-fix-print-assistant-thoughts

fix assistant thoughts failure on string type
pull/50/head
Toran Bruce Richards 2023-04-04 20:43:58 +12:00 committed by GitHub
commit f294ba8605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -52,6 +52,14 @@ def print_assistant_thoughts(assistant_reply):
# Parse and print Assistant response
assistant_reply_json = fix_and_parse_json(assistant_reply)
# Check if assistant_reply_json is a string and attempt to parse it into a JSON object
if isinstance(assistant_reply_json, str):
try:
assistant_reply_json = json.loads(assistant_reply_json)
except json.JSONDecodeError as e:
print_to_console("Error: Invalid JSON\n", Fore.RED, assistant_reply)
assistant_reply_json = {}
assistant_thoughts_reasoning = None
assistant_thoughts_plan = None
assistant_thoughts_speak = None