pub trait Embed {
// Required method
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>;
}Expand description
Extracts text fragments for vector embedding in append order.
Implementations report extraction failures through EmbedError.
use rig_core::{Embed, embeddings::{EmbedError, TextEmbedder, to_texts}};
struct Definitions(String);
impl Embed for Definitions {
fn embed(&self, out: &mut TextEmbedder) -> Result<(), EmbedError> {
for definition in self.0.split(',') {
out.embed(definition.trim().to_owned());
}
Ok(())
}
}
assert_eq!(to_texts(Definitions("fruit, company".into()))?, vec!["fruit", "company"]);Required Methods§
Sourcefn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Append all text fragments that should be embedded for this value.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".