pub struct StructuredOutputValidator { /* private fields */ }Expand description
Middleware that validates structured output from a tool against a JSON Schema.
When attached to a “result” tool, this validates the model’s JSON input
against the expected schema. On validation failure, returns
ToolError::ModelRetry with a description of what went wrong so the
model can self-correct.
This implements the tool-based structured output pattern used by instructor, Pydantic AI, and Rig: inject a tool with the output schema, force the model to call it, and validate.
Implementations§
Trait Implementations§
Source§impl ToolMiddleware for StructuredOutputValidator
impl ToolMiddleware for StructuredOutputValidator
Source§fn process<'a>(
&'a self,
call: &'a ToolCall,
ctx: &'a ToolContext,
next: Next<'a>,
) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>
fn process<'a>( &'a self, call: &'a ToolCall, ctx: &'a ToolContext, next: Next<'a>, ) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>
Process a tool call, optionally delegating to the next middleware/tool.
Auto Trait Implementations§
impl Freeze for StructuredOutputValidator
impl RefUnwindSafe for StructuredOutputValidator
impl Send for StructuredOutputValidator
impl Sync for StructuredOutputValidator
impl Unpin for StructuredOutputValidator
impl UnsafeUnpin for StructuredOutputValidator
impl UnwindSafe for StructuredOutputValidator
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
Mutably borrows from an owned value. Read more