pub enum Dialect {
Glm,
Hermes,
Kimi,
Xml,
Anthropic,
Deepseek,
Harmony,
Qwen3,
Gemini,
Gemma,
Minimax,
}Expand description
An owned tool-calling dialect.
Mirrors omp’s Dialect union (@oh-my-pi/pi-catalog/identity). The variant
selects the text grammar used to render and parse in-band tool calls.
Variants§
Glm
GLM (ChatGLM) XML dialect.
Hermes
Hermes / Qwen JSON-fence dialect.
Kimi
Kimi (Moonshot) section dialect.
Xml
Generic XML dialect — the fallback (<invoke>/<parameter>).
Anthropic
Anthropic <function_calls> / <antml:invoke> dialect.
Deepseek
DeepSeek DSML dialect.
Harmony
OpenAI / GPT-OSS Harmony control-token dialect.
Qwen3
Qwen3 dialect.
Gemini
Google Gemini <start_of_turn> dialect.
Gemma
Google Gemma <|turn> dialect.
Minimax
MiniMax <minimax:tool_call> dialect.
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Parse a dialect from its kebab/short name (e.g. "xml", "qwen3").
Returns None for unknown names. Accepts the canonical lower-case
identifier omp uses on the wire and in PI_DIALECT.
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The canonical wire identifier (matches omp’s Dialect string values).
Sourcepub fn preferred_for_model(model_id: &str) -> Self
pub fn preferred_for_model(model_id: &str) -> Self
Resolve the dialect a model id prefers, by family token.
Mirrors omp’s preferredDialect(modelId). The match is a substring
scan over the lower-cased model id; unknown families fall back to
FALLBACK_DIALECT.
Sourcepub fn prompt(self) -> String
pub fn prompt(self) -> String
The dialect’s format-guide prompt fragment (injected after the catalog).
Sourcepub fn render_tool_calls(self, calls: &[ToolCall], tools: &[Tool]) -> String
pub fn render_tool_calls(self, calls: &[ToolCall], tools: &[Tool]) -> String
Render a batch of (parallel) tool calls as one text block.
Sourcepub fn render_tool_results(self, results: &[RenderedToolResult]) -> String
pub fn render_tool_results(self, results: &[RenderedToolResult]) -> String
Render a run of tool results as one text block.
Sourcepub fn render_thinking(self, text: &str) -> String
pub fn render_thinking(self, text: &str) -> String
Render a thinking/reasoning block in the dialect’s envelope.
Sourcepub fn parse(self, text: &str, tools: &[Tool]) -> Vec<ScanSegment>
pub fn parse(self, text: &str, tools: &[Tool]) -> Vec<ScanSegment>
Parse completed model text into segments (text / thinking / tool calls).
This is the batch entry point. Streaming (incremental) parsing lands in a follow-up; the agent loop will call this on the accumulated assistant text once the turn completes.
Sourcepub fn parse_assistant_message(
self,
message: &AssistantMessage,
tools: &[Tool],
) -> AssistantMessage
pub fn parse_assistant_message( self, message: &AssistantMessage, tools: &[Tool], ) -> AssistantMessage
Re-materialize in-band tool-call text on an assistant message as native
ToolCall content blocks, leaving any prose as text blocks.
Returns the rewritten message. When the text contains no tool calls the message is returned unchanged.
Trait Implementations§
impl Copy for Dialect
impl Eq for Dialect
impl StructuralPartialEq for Dialect
Auto Trait Implementations§
impl Freeze for Dialect
impl RefUnwindSafe for Dialect
impl Send for Dialect
impl Sync for Dialect
impl Unpin for Dialect
impl UnsafeUnpin for Dialect
impl UnwindSafe for Dialect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.