From 8b1f20aa045d4ed9c76e157910cd538eb75c90ca Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" <4000772+mcmonkey4eva@users.noreply.github.com> Date: Mon, 3 Apr 2023 06:49:28 -0700 Subject: [PATCH] Fix some old JSON characters not loading (#740) --- modules/chat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index f5adbcf..0b010b4 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -349,11 +349,12 @@ def load_character(_character, name1, name2): if _character != 'None': shared.character = _character - for extension in ["yml", "yaml", "json"]: + for extension in ["yml", "yaml", "json"]: filepath = Path(f'characters/{_character}.{extension}') if filepath.exists(): break - data = yaml.safe_load(open(filepath, 'r', encoding='utf-8').read()) + file_contents = open(filepath, 'r', encoding='utf-8').read() + data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents) name2 = data['name'] if 'name' in data else data['char_name'] for field in ['context', 'greeting', 'example_dialogue', 'char_persona', 'char_greeting', 'world_scenario']: