mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-29 18:26:37 +08:00
fix no template prompt
This commit is contained in:
parent
9f2ea5892e
commit
ae4fdfc2e7
@ -190,7 +190,7 @@ def main():
|
|||||||
tokenizer.chat_template = metadata["chat_template"]
|
tokenizer.chat_template = metadata["chat_template"]
|
||||||
|
|
||||||
prompt = codecs.decode(args.prompt, "unicode_escape")
|
prompt = codecs.decode(args.prompt, "unicode_escape")
|
||||||
|
prompt = sys.stdin.read() if prompt == "-" else prompt
|
||||||
if not args.ignore_chat_template and (
|
if not args.ignore_chat_template and (
|
||||||
hasattr(tokenizer, "apply_chat_template")
|
hasattr(tokenizer, "apply_chat_template")
|
||||||
and tokenizer.chat_template is not None
|
and tokenizer.chat_template is not None
|
||||||
@ -199,12 +199,7 @@ def main():
|
|||||||
messages = [{"role": "system", "content": args.system_prompt}]
|
messages = [{"role": "system", "content": args.system_prompt}]
|
||||||
else:
|
else:
|
||||||
messages = []
|
messages = []
|
||||||
messages.append(
|
messages.append({"role": "user", "content": prompt})
|
||||||
{
|
|
||||||
"role": "user",
|
|
||||||
"content": sys.stdin.read() if prompt == "-" else prompt,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
prompt = tokenizer.apply_chat_template(
|
prompt = tokenizer.apply_chat_template(
|
||||||
messages, tokenize=False, add_generation_prompt=True
|
messages, tokenize=False, add_generation_prompt=True
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user