Skip to main content

Module chat

Module chat 

Source
Expand description

Chat formatting for each model family (mirrors their chat templates), including tool calling.

Structs§

Gemma3Chat
Gemma 3: <start_of_turn> turns, no system role (the system prompt opens the first user turn), no thinking and no tool tokens.
GemmaChat
Llama3Chat
Llama 3.x instruct: header-delimited turns; the template always opens with a system turn carrying the knowledge cutoff and today’s date (“25 Oct 2026”, as strftime_now("%d %b %Y")).
Qwen2Chat
Qwen2 / Qwen2.5 ChatML: like Qwen3 without thinking, and the template’s default system prompt when none is given.
QwenChat
Qwen ChatML templates. Qwen3.5 / 3.8: thinking is on by default in the model, so a non-thinking request closes the think block in the generation prompt, and a thinking one opens it; Qwen3.8’s also adds a reasoning-effort instruction to the system turn in thinking mode (and a small model given that instruction anyway can deliberate about it endlessly). Qwen3: the model opens its own think block, and tools are declared and called in JSON.

Constants§

EOT

Statics§

QWEN
Qwen3.5, Qwen3.8 (with the reasoning-effort instruction) and Qwen3 formats.
QWEN3
QWEN_EFFORT

Traits§

ChatFormat
Chat formatting for a model family.

Functions§

conversation_start
Text for the start of a conversation: <bos> plus the optional system turn.
end_of_model_turn
Text to append after the model has finished its reply (before the next user turn).
user_turn
A user turn followed by the generation prompt for the model.
with_turn_end
eos plus the chat format’s end-of-turn token, looked up in the tokenizer.