Skip to main content

VectorHook

Trait VectorHook 

Source
pub trait VectorHook: Send + Sync {
    // Required methods
    fn vectorize_fields(
        &self,
        record: Value,
        mappings: &[FieldMapping],
    ) -> Result<Value, String>;
    fn vectorize_text(
        &self,
        text: &str,
        model: &str,
    ) -> Result<Vec<f32>, String>;
    fn vectorize_image(
        &self,
        bytes: &[u8],
        model: &str,
    ) -> Result<Vec<f32>, String>;

    // Provided methods
    fn validate_model(&self, _model: &str) -> Result<(), String> { ... }
    fn warmup_model(
        &self,
        _model: &str,
        _field_type: &str,
    ) -> Result<(), String> { ... }
    fn vectorize_fields_batch(
        &self,
        records: Vec<Value>,
        mappings: &[FieldMapping],
    ) -> Result<Vec<Value>, String> { ... }
}
Expand description

Hook for automatic vector embedding generation.

Implementations must be sync for safety across the WIT boundary.

Required Methods§

Source

fn vectorize_fields( &self, record: Value, mappings: &[FieldMapping], ) -> Result<Value, String>

Embed text/image fields in a record based on mappings.

Source

fn vectorize_text(&self, text: &str, model: &str) -> Result<Vec<f32>, String>

Convert a text query to a vector for search.

Source

fn vectorize_image(&self, bytes: &[u8], model: &str) -> Result<Vec<f32>, String>

Convert raw image bytes to a vector.

Provided Methods§

Source

fn validate_model(&self, _model: &str) -> Result<(), String>

Check if a model is available for use.

Source

fn warmup_model(&self, _model: &str, _field_type: &str) -> Result<(), String>

Eagerly load a model into memory during startup.

Source

fn vectorize_fields_batch( &self, records: Vec<Value>, mappings: &[FieldMapping], ) -> Result<Vec<Value>, String>

Batch-embed multiple records.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§