pub struct DialectSpec {
pub id: String,
pub tool_open: String,
pub tool_close: String,
pub body_codecs: Vec<BodyCodec>,
pub emission: EmissionProfile,
pub id_prefix: String,
}Expand description
A model’s tool-call dialect, described entirely as data.
See the module docs for the consumer contract. tool_open == tool_close
is a valid spec (fenced dialects); an empty marker is not.
Fields§
§id: StringStable identifier — QWEN_XML_DIALECT_ID for the builtin,
DERIVED_DIALECT_ID for template-derived specs.
tool_open: StringMarker that opens a tool-call envelope, e.g. <tool_call>.
tool_close: StringMarker that closes a tool-call envelope, e.g. </tool_call>.
body_codecs: Vec<BodyCodec>Body encodings to try, in order, against the envelope contents.
emission: EmissionProfileWhitespace layout for emitted calls (grammar + Self::render_call).
id_prefix: StringPrefix for synthesized tool-call IDs, e.g. call_qwen_.
Implementations§
Source§impl DialectSpec
impl DialectSpec
Sourcepub fn qwen_xml() -> Self
pub fn qwen_xml() -> Self
The built-in Qwen 2 / 2.5 / 3 (and Hermes-family) dialect:
<tool_call> envelope with a JSON body, falling back to the
<function=...> inner-XML body Qwen 3 emits under --jinja.
Sourcepub fn supports_json_body(&self) -> bool
pub fn supports_json_body(&self) -> bool
Whether the JSON body codec applies — the precondition for GBNF grammar enforcement, which can only originate JSON-shaped bodies.
Sourcepub fn render_call(&self, name: &str, arguments: &Value) -> String
pub fn render_call(&self, name: &str, arguments: &Value) -> String
Render one canonical tool call exactly as the grammar would enforce
it: envelope markers, EmissionProfile newlines, and a JSON body
with name before arguments.
This is the bridge that proves grammar and parser share one source:
tests feed render_call output through the parser and require the
call to round-trip.
Trait Implementations§
Source§impl Clone for DialectSpec
impl Clone for DialectSpec
Source§fn clone(&self) -> DialectSpec
fn clone(&self) -> DialectSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DialectSpec
impl Debug for DialectSpec
Source§impl<'de> Deserialize<'de> for DialectSpec
impl<'de> Deserialize<'de> for DialectSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for DialectSpec
impl PartialEq for DialectSpec
Source§fn eq(&self, other: &DialectSpec) -> bool
fn eq(&self, other: &DialectSpec) -> bool
self and other values to be equal, and is used by ==.