Skip to contents

Creates a properly formatted chat template for Gemma models, which use <start_of_turn> and <end_of_turn> markers instead of ChatML format. This function addresses compatibility issues with apply_chat_template() when used with Gemma models.

Usage

apply_gemma_chat_template(messages, add_assistant = TRUE)

Arguments

messages

A list of message objects, each with 'role' and 'content' fields

add_assistant

Whether to add the assistant turn prefix (default: TRUE)

Value

A character string with properly formatted Gemma chat template

Examples

if (FALSE) { # \dontrun{
messages <- list(
  list(role = "system", content = "You are a helpful assistant."),
  list(role = "user", content = "Hello!")
)
formatted <- apply_gemma_chat_template(messages)
} # }