Fix prompt incorrectly set to empty when suffix is empty string (#5757)

This commit is contained in:
Yiximail 2024-03-27 03:33:09 +08:00 committed by GitHub
parent 2a92a842ce
commit 8c9aca239a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -161,12 +161,14 @@ def generate_chat_prompt(user_input, state, **kwargs):
prompt = instruction_template.render(messages=outer_messages)
suffix = get_generation_prompt(instruct_renderer, impersonate=False)[1]
prompt = prompt[:-len(suffix)]
if len(suffix) > 0:
prompt = prompt[:-len(suffix)]
else:
if _continue:
suffix = get_generation_prompt(renderer, impersonate=impersonate)[1]
prompt = prompt[:-len(suffix)]
if len(suffix) > 0:
prompt = prompt[:-len(suffix)]
else:
prefix = get_generation_prompt(renderer, impersonate=impersonate)[0]
if state['mode'] == 'chat' and not impersonate: