From baab89475989a4f7166b233339e90cb0b9a3cfee Mon Sep 17 00:00:00 2001 From: Jordan Tucker Date: Sat, 18 Nov 2023 17:20:13 -0600 Subject: [PATCH] fix: use system message in chat-instruct mode (#4648) --- modules/chat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/chat.py b/modules/chat.py index 4c518d33..dda16749 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -91,7 +91,12 @@ def generate_chat_prompt(user_input, state, **kwargs): if state['mode'] == 'chat-instruct': wrapper = '' command = state['chat-instruct_command'].replace('<|character|>', state['name2'] if not impersonate else state['name1']) - wrapper += state['context_instruct'] + context_instruct = state['context_instruct'] + if state['custom_system_message'].strip() != '': + context_instruct = context_instruct.replace('<|system-message|>', state['custom_system_message']) + else: + context_instruct = context_instruct.replace('<|system-message|>', state['system_message']) + wrapper += context_instruct wrapper += all_substrings['instruct']['user_turn'].replace('<|user-message|>', command) wrapper += all_substrings['instruct']['bot_turn_stripped'] if impersonate: