Format a Conversation With a Chat Template
Implement two functions using the provided tokenizer and its chat template:
format_chat(messages): turn[{"role": ..., "content": ...}]into the exact prompt string the model expects, ready for the assistant to continue.format_for_training(messages): the same conversation including the final assistant turn, for fine-tuning.
If the tokenizer has no template, fall back to role: content lines.
The catch: the two differ by one flag. Get it wrong and the model writes the user's next message instead of answering.