Clearer syntax for instruction-following characters

This commit is contained in:
oobabooga 2023-05-03 22:50:39 -03:00
parent 9c77ab4fc2
commit 0e6d17304a
10 changed files with 38 additions and 28 deletions

View file

@ -455,9 +455,18 @@ def load_character(character, name1, name2, mode):
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']
if 'your_name' in data and data['your_name'] != '':
name1 = data['your_name']
# Finding the bot's name
for k in ['name', 'bot', '<|bot|>', 'char_name']:
if k in data and data[k] != '':
name2 = data[k]
break
# Find the user name (if any)
for k in ['your_name', 'user', '<|user|>']:
if k in data and data[k] != '':
name1 = data[k]
break
else:
name1 = shared.settings['name1']