Automatically detects the model type and applies the appropriate chat template. For Gemma models, uses the Gemma-specific format. For other models, falls back to the standard apply_chat_template function.
smart_chat_template(model, messages, template = NULL, add_assistant = TRUE)Formatted chat template string
A model object created with model_load
A list of message objects
Custom template (passed to apply_chat_template if not Gemma)
Whether to add assistant turn prefix