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§
Sourcefn vectorize_fields(
&self,
record: Value,
mappings: &[FieldMapping],
) -> Result<Value, String>
fn vectorize_fields( &self, record: Value, mappings: &[FieldMapping], ) -> Result<Value, String>
Embed text/image fields in a record based on mappings.
Provided Methods§
Sourcefn validate_model(&self, _model: &str) -> Result<(), String>
fn validate_model(&self, _model: &str) -> Result<(), String>
Check if a model is available for use.
Sourcefn warmup_model(&self, _model: &str, _field_type: &str) -> Result<(), String>
fn warmup_model(&self, _model: &str, _field_type: &str) -> Result<(), String>
Eagerly load a model into memory during startup.
Sourcefn vectorize_fields_batch(
&self,
records: Vec<Value>,
mappings: &[FieldMapping],
) -> Result<Vec<Value>, String>
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".