Skip to main content

Module normalizer

Module normalizer 

Source
Expand description

Tool-call normalizer: converts raw model text output (in-band markers) into structured normalizer::ToolInvocations for kernel dispatch. ToolCallNormalizer — converts raw LLM text output into structured ToolInvocations.

Models served via OpenAI-compatible APIs (e.g. mlx_lm.server) sometimes emit tool-intent as in-band text markers rather than the structured tool_calls JSON field. Normalizers detect and decode those markers so the kernel can dispatch them identically to first-class tool calls.

§Built-in implementations

TypeFormat
LfmNormalizerLiquidAI LFM <|tool_call_start|>[fn(k=v)]<|tool_call_end|>
StructuredToolCallNormalizerOpenAI Responses function_call output and Chat Completions tool_calls

§Example

use rig_compose::normalizer::{LfmNormalizer, ToolCallNormalizer};

let raw = "<|tool_call_start|>[get_weather(city='Berlin')]<|tool_call_end|>";
let normalizer = LfmNormalizer;
let calls = normalizer.normalize(raw).expect("parse ok");
assert_eq!(calls[0].name, "get_weather");

Structs§

LfmNormalizer
Normalizer for LiquidAI LFM models (e.g. LFM2.5-1.2B-Thinking) served through mlx_lm.server or similar OpenAI-compatible shims that emit tool intent as in-band text rather than the structured tool_calls field.
StructuredToolCallNormalizer
Normalizer for structured tool-call JSON returned by common provider APIs.
ToolInvocation
A structured tool invocation extracted from raw model output.
ToolInvocationResult
Result of dispatching one normalized ToolInvocation.

Enums§

ToolDispatchAction
Decision returned by a ToolDispatchHook before a tool invocation runs.
ToolInvocationOutcome
Outcome recorded for one normalized ToolInvocation.

Traits§

ToolCallNormalizer
Normalizes raw LLM text output into structured ToolInvocations.
ToolDispatchHook
Hook for policy, accounting, and tracing around normalized tool dispatch.

Functions§

dispatch_tool_invocations
Dispatch normalized tool invocations sequentially through a ToolRegistry.
dispatch_tool_invocations_with_hooks
Dispatch normalized tool invocations with policy/accounting hooks.
dispatch_tool_invocations_with_trace
Dispatch normalized tool invocations and record a DispatchTrace.