Skip to main content

Module dialect

Module dialect 

Source
Expand description

Tool-call dialect specification.

A DialectSpec describes, as plain data, how a model wraps tool calls inside its text output: the envelope markers, the body encodings to try, and the whitespace layout it uses when emitting a call. It is the single source of truth consumed by every layer that must agree on a dialect:

  • the delimited stream parser (normalize::parsers::delimited) scans for tool_open/tool_close and decodes bodies via body_codecs;
  • the decode-time GBNF grammar (request_pipeline::constrain) is generated from the same markers and EmissionProfile;
  • detection (gglib-gguf) produces specs — either derived from the model’s own chat template or the DialectSpec::qwen_xml builtin.

Because parser, grammar, and detection all read one value, they cannot drift: anything the grammar permits, the parser can parse, provable via DialectSpec::render_call.

Specs are persisted per model (JSON in the dialect_spec column), so the serde shape is forward-compatible: later-added fields must carry #[serde(default)].

Structs§

DialectSpec
A model’s tool-call dialect, described entirely as data.
EmissionProfile
Whitespace layout a dialect uses when emitting a call.

Enums§

BodyCodec
How a tool-call body is encoded between the envelope markers.

Constants§

DERIVED_DIALECT_ID
Spec id for dialects derived from a model’s chat template.
DERIVED_ID_PREFIX
Synthetic tool-call ID prefix used by template-derived specs.
QWEN_ID_PREFIX
Synthetic tool-call ID prefix used by the built-in Qwen dialect.
QWEN_XML_DIALECT_ID
Spec id of the built-in Qwen/Hermes <tool_call> dialect.

Functions§

default_id_prefix 🔒