pub struct EmbeddingModelBridge { /* private fields */ }Expand description
Bridge between the Context Engine and the EmbeddingsManager.
This struct provides zero overhead when embeddings are disabled and seamless integration when they are enabled.
§Usage Examples
ⓘ
// Create a disabled bridge (zero overhead)
let bridge = EmbeddingModelBridge::disabled();
// Create from embeddings config
let embeddings_config = Some(EmbeddingsConfig::default());
let bridge = EmbeddingModelBridge::from_embeddings_config(embeddings_config);
// Use the bridge (returns NotImplemented when disabled)
match bridge.embed("some text").await {
Ok(vector) => println!("Embedded: {} dimensions", vector.len()),
Err(EmbeddingError::NotImplemented) => println!("Embeddings disabled"),
Err(e) => println!("Error: {}", e),
}Implementations§
Source§impl EmbeddingModelBridge
impl EmbeddingModelBridge
Sourcepub const fn new(manager: Option<EmbeddingsManager>) -> Self
pub const fn new(manager: Option<EmbeddingsManager>) -> Self
Create a new bridge from the embeddings manager
Sourcepub fn from_embeddings_config(config: Option<EmbeddingsConfig>) -> Self
pub fn from_embeddings_config(config: Option<EmbeddingsConfig>) -> Self
Create a bridge from embeddings configuration
This is the preferred way to create the bridge, as it handles the case where embeddings are disabled.
Sourcepub const fn from_config(_config: &Config) -> Self
pub const fn from_config(_config: &Config) -> Self
Create a bridge from the main Config (future extension point)
For now, this creates a disabled bridge since the main Config doesn’t yet have an embeddings field. When embeddings are added to the main Config, this method will extract the embeddings config.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if embeddings are enabled
Trait Implementations§
Source§impl EmbeddingModel for EmbeddingModelBridge
impl EmbeddingModel for EmbeddingModelBridge
fn dimensions(&self) -> usize
async fn embed(&self, text: &str) -> Result<EmbeddingVector, EmbeddingError>
async fn embed_batch( &self, texts: &[String], ) -> Result<Vec<EmbeddingVector>, EmbeddingError>
Auto Trait Implementations§
impl !RefUnwindSafe for EmbeddingModelBridge
impl !UnwindSafe for EmbeddingModelBridge
impl Freeze for EmbeddingModelBridge
impl Send for EmbeddingModelBridge
impl Sync for EmbeddingModelBridge
impl Unpin for EmbeddingModelBridge
impl UnsafeUnpin for EmbeddingModelBridge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more