From 147170214bccecd5856bdeeb039f0eb460b28d1c Mon Sep 17 00:00:00 2001 From: ZHU QIHAO <18811325956@163.com> Date: Wed, 28 Feb 2024 12:27:00 +0800 Subject: [PATCH] Update app.py --- demo/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/app.py b/demo/app.py index 5bf817a..1580e83 100644 --- a/demo/app.py +++ b/demo/app.py @@ -48,7 +48,7 @@ def generate( conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}]) conversation.append({"role": "user", "content": message}) - input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt") + input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True) if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH: input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:] gr.Warning(f"Trimmed input from conversation as it was longer than {MAX_INPUT_TOKEN_LENGTH} tokens.")