BaseSchema

Trait BaseSchema 

Source
pub trait BaseSchema: Send + Sync {
    // Required methods
    fn from_examples(
        examples_data: &[ExampleData],
        attribute_suffix: &str,
    ) -> LangExtractResult<Box<dyn BaseSchema>>
       where Self: Sized;
    fn to_provider_config(&self) -> HashMap<String, Value>;
    fn supports_strict_mode(&self) -> bool;
    fn clone_box(&self) -> Box<dyn BaseSchema>;

    // Provided method
    fn sync_with_provider_kwargs(&mut self, kwargs: &HashMap<String, Value>) { ... }
}
Expand description

Abstract base trait for generating structured constraints from examples

Required Methods§

Source

fn from_examples( examples_data: &[ExampleData], attribute_suffix: &str, ) -> LangExtractResult<Box<dyn BaseSchema>>
where Self: Sized,

Factory method to build a schema instance from example data

Source

fn to_provider_config(&self) -> HashMap<String, Value>

Convert schema to provider-specific configuration

Returns a dictionary of provider kwargs (e.g., response_schema for Gemini). Should be a pure data mapping with no side effects.

Source

fn supports_strict_mode(&self) -> bool

Whether the provider emits valid output without needing Markdown fences

Returns true when the provider will emit syntactically valid JSON (or other machine-parseable format) without needing Markdown fences. This says nothing about attribute-level schema enforcement.

Source

fn clone_box(&self) -> Box<dyn BaseSchema>

Clone this schema instance

Provided Methods§

Source

fn sync_with_provider_kwargs(&mut self, kwargs: &HashMap<String, Value>)

Hook to update schema state based on provider kwargs

This allows schemas to adjust their behavior based on caller overrides. For example, FormatModeSchema uses this to sync its format when the caller overrides it, ensuring supports_strict_mode stays accurate.

Implementors§