From 626da6c731ace6d1ec50cbcaffd6439be16578c9 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 28 Feb 2023 00:59:05 -0300 Subject: [PATCH] Handle {{user}} and {{char}} in example dialogue --- modules/chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/chat.py b/modules/chat.py index 1392038d..78aeee06 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -331,6 +331,7 @@ def load_character(_character, name1, name2): context += f"Scenario: {data['world_scenario']}\n" context = f"{context.strip()}\n\n" if 'example_dialogue' in data and data['example_dialogue'] != '': + data['example_dialogue'] = data['example_dialogue'].replace('{{user}}', name1).replace('{{char}}', name2) context += f"{data['example_dialogue'].strip()}\n" if 'char_greeting' in data and len(data['char_greeting'].strip()) > 0: shared.history['internal'] += [['<|BEGIN-VISIBLE-CHAT|>', data['char_greeting']]] @@ -375,7 +376,6 @@ def upload_tavern_character(img, name1, name2): decoded_string = base64.b64decode(_img.info['chara']) _json = json.loads(decoded_string) _json = {"char_name": _json['name'], "char_persona": _json['description'], "char_greeting": _json["first_mes"], "example_dialogue": _json['mes_example'], "world_scenario": _json['scenario']} - _json['example_dialogue'] = _json['example_dialogue'].replace('{{user}}', name1).replace('{{char}}', _json['char_name']) return upload_character(json.dumps(_json), img, tavern=True) def upload_your_profile_picture(img):