Skip to content

v2.43.2

Choose a tag to compare

@j-mendez j-mendez released this 02 Feb 00:55
· 147 commits to main since this release

New Feature: Extraction Schema Support

Add JSON Schema support for structured extraction in RemoteMultimodalEngine.

ExtractionSchema Struct

pub struct ExtractionSchema {
    pub name: String,           // Schema name (e.g., "products")
    pub description: Option<String>,  // What to extract
    pub schema: String,         // JSON Schema definition
    pub strict: bool,           // Enforce strict adherence
}

Example Usage

use spider::features::automation::{RemoteMultimodalConfigs, ExtractionSchema};

let schema = ExtractionSchema::new_with_description(
    "products",
    "Extract product information",
    r#"{
        "type": "object",
        "properties": {
            "products": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string" },
                        "price": { "type": "number" }
                    },
                    "required": ["name", "price"]
                }
            }
        }
    }"#,
).with_strict(true);

let mm = RemoteMultimodalConfigs::new("http://localhost:11434/v1/chat/completions", "model")
    .with_extra_ai_data(true)
    .with_extraction_schema(Some(schema));

Full Changelog: v2.43.1...v2.43.2