Skip to content

vllm.renderers.inkling_encoding

Inkling chat-encoding core.

Pure implementation of Inkling chat rendering, kept deliberately free of vLLM imports: it depends only on the InklingTextTokenizer protocol and speaks OpenAI-style message dicts. If a standalone Inkling input-processing library becomes available, this module is the unit to swap out — the swap point is marked in vllm/renderers/inkling.py.

Multimodal parts follow the contract of vLLM's Inkling multimodal processor (InklingMultiModalProcessor anchors prompt updates on the bare content-kind marker and inserts the per-patch placeholder run itself):

  • image parts emit only <|content_image|> — no seed placeholder id;
  • audio parts emit <|content_audio_input|><|audio_end|> — no seed placeholder id between them.

reasoning_effort (a float in [0, 0.99], sourced from chat_template_kwargs only) renders the Thinking effort level: system control block after the tool declarations and initial system messages.

Classes:

Functions:

InklingTextTokenizer

Bases: Protocol

Structural tokenizer contract required by the renderer.

_collect_tools(messages, tools)

Request-level plus per-developer-message tools (Rust renderer semantics), declared in a single leading system block.

_flatten_text_content(content)

Flatten a tool-response content (string or text parts) to text.

_iter_render_parts(content)

Yield (kind, text) per content part: kind in {text, image, audio}.

_tml_json_dumps(value, *, legacy_floats=True, sort_keys=True)

Compact JSON with the Inkling2 reference float spelling.

_tml_json_loads(text)

Parse JSON as the Inkling2 reference does (64-bit ints, finite floats).

continuation_prefix(message)

Return the text an Inkling2 continue_final_message request extends.

Only a plain-string assistant message with no tool calls or reasoning is continued; None means the message renders as a closed turn.

render_inkling2_messages(messages, tokenizer, *, tools=None, tool_choice=None, parallel_tool_calls=True, reasoning_effort=DEFAULT_REASONING_EFFORT, continue_final_message=False)

Render chat messages to Inkling2 input ids.

With continue_final_message, a final assistant message holding only a text string is left open so generation continues its text.

render_inkling_messages(messages, tokenizer, *, add_generation_prompt=True, tools=None, reasoning_effort=None)

Render chat messages to Inkling input ids.

PURE renderer: emits Inkling framing plus bare media markers; media encoding and placeholder expansion happen later in the MM processor. add_generation_prompt appends the assistant turn opener so the model continues into the response.