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".
Implementations on Foreign Types§
Source§impl Embed for &str
impl Embed for &str
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for String
impl Embed for String
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for Value
impl Embed for Value
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for bool
impl Embed for bool
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for char
impl Embed for char
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for f32
impl Embed for f32
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for f64
impl Embed for f64
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for i8
impl Embed for i8
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for i16
impl Embed for i16
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for i32
impl Embed for i32
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for i64
impl Embed for i64
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl Embed for i128
impl Embed for i128
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl<T: Embed> Embed for &T
impl<T: Embed> Embed for &T
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Source§impl<T: Embed> Embed for Vec<T>
impl<T: Embed> Embed for Vec<T>
fn embed(&self, embedder: &mut TextEmbedder) -> Result<(), EmbedError>
Implementors§
impl Embed for MockMultiTextDocument
Available on crate feature
test-utils only.impl Embed for MockTextDocument
Available on crate feature
test-utils only.