Skip to content

vllm.renderers.kimi_k3

Classes:

  • KimiK3Renderer –

    Render chat prompts with Kimi K3's Python XTML encoding.

KimiK3Renderer

Bases: BaseHfRenderer[HfTokenizer]

Render chat prompts with Kimi K3's Python XTML encoding.

K3 ships no Jinja chat template; its tokenizer renders messages through encoding_k3 instead. We tokenize eagerly so the structural markers keep their special-token ids while user- and tool-supplied text stays ordinary.

_k3_text_parts(content)

Text parts as parsing reads them, or None if content has others.

_keep_k3_content_parts(messages, conversation)

Pass message content to K3's encoder as part lists.

The encoder renders and tokenizes each part in order with no separator. Parsing joins the text parts of a tool message with newlines, so those are taken from the request instead.

_normalize_k3_tool_messages(conversation)

Reorder tool-result messages to match assistant tool_call order.

Supports matching by tool_call_id or by the synthetic "{tool}:{zero_based_index}" alias. When any tool message in a block cannot be resolved, the whole block is left in its original order (graceful fallback).

Returns a new list; caller-owned message dicts are not mutated.