mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-06-09 07:07:16 -04:00
Fix some old JSON characters not loading (#740)
This commit is contained in:
parent
8b442305ac
commit
8b1f20aa04
1 changed files with 3 additions and 2 deletions
|
@ -349,11 +349,12 @@ def load_character(_character, name1, name2):
|
||||||
if _character != 'None':
|
if _character != 'None':
|
||||||
shared.character = _character
|
shared.character = _character
|
||||||
|
|
||||||
for extension in ["yml", "yaml", "json"]:
|
for extension in ["yml", "yaml", "json"]:
|
||||||
filepath = Path(f'characters/{_character}.{extension}')
|
filepath = Path(f'characters/{_character}.{extension}')
|
||||||
if filepath.exists():
|
if filepath.exists():
|
||||||
break
|
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']
|
name2 = data['name'] if 'name' in data else data['char_name']
|
||||||
for field in ['context', 'greeting', 'example_dialogue', 'char_persona', 'char_greeting', 'world_scenario']:
|
for field in ['context', 'greeting', 'example_dialogue', 'char_persona', 'char_greeting', 'world_scenario']:
|
||||||
|
|
Loading…
Add table
Reference in a new issue