From ae4fdfc2e7803babd03ce4cee6e9a3b75bae3ac6 Mon Sep 17 00:00:00 2001 From: Awni Hannun Date: Mon, 16 Dec 2024 06:53:39 -0800 Subject: [PATCH] fix no template prompt --- llms/mlx_lm/generate.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/llms/mlx_lm/generate.py b/llms/mlx_lm/generate.py index 84dc63ca..a90cfd7b 100644 --- a/llms/mlx_lm/generate.py +++ b/llms/mlx_lm/generate.py @@ -190,7 +190,7 @@ def main(): tokenizer.chat_template = metadata["chat_template"] prompt = codecs.decode(args.prompt, "unicode_escape") - + prompt = sys.stdin.read() if prompt == "-" else prompt if not args.ignore_chat_template and ( hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None @@ -199,12 +199,7 @@ def main(): messages = [{"role": "system", "content": args.system_prompt}] else: messages = [] - messages.append( - { - "role": "user", - "content": sys.stdin.read() if prompt == "-" else prompt, - } - ) + messages.append({"role": "user", "content": prompt}) prompt = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True )