Skip to contents

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.

Usage

smart_chat_template(model, messages, template = NULL, add_assistant = TRUE)

Arguments

model

A model object created with model_load

messages

A list of message objects

template

Custom template (passed to apply_chat_template if not Gemma)

add_assistant

Whether to add assistant turn prefix

Value

Formatted chat template string