pub struct LlmEmbeddingProvider { /* private fields */ }Expand description
LLM-backed embedding provider that calls the clawft-llm provider layer.
Uses the model’s embedding endpoint to produce real semantic vectors.
When no API is configured (or the API is unavailable), falls back to
MockEmbeddingProvider for deterministic hash-based embeddings.
Implementations§
Source§impl LlmEmbeddingProvider
impl LlmEmbeddingProvider
Sourcepub fn new(config: LlmEmbeddingConfig) -> Self
pub fn new(config: LlmEmbeddingConfig) -> Self
Create a new LLM embedding provider with the given configuration.
Sourcepub fn from_config(table: &HashMap<String, String>) -> Self
pub fn from_config(table: &HashMap<String, String>) -> Self
Create from a weave.toml-style configuration table.
Expected keys: model (string), dimensions (int), batch_size (int).
If the table is missing or incomplete, returns a provider with defaults
that falls back to mock embeddings.
Sourcepub fn is_api_available(&self) -> bool
pub fn is_api_available(&self) -> bool
Whether the LLM API is available (non-fallback mode).
Sourcepub fn config(&self) -> &LlmEmbeddingConfig
pub fn config(&self) -> &LlmEmbeddingConfig
Get the underlying configuration.
Trait Implementations§
Source§impl EmbeddingProvider for LlmEmbeddingProvider
impl EmbeddingProvider for LlmEmbeddingProvider
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Embed a single text chunk into a vector.
Source§fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Embed a batch of text chunks. Read more
Source§fn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Dimensionality of the output vectors.
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Name of the embedding model (for metadata tracking).
Auto Trait Implementations§
impl Freeze for LlmEmbeddingProvider
impl RefUnwindSafe for LlmEmbeddingProvider
impl Send for LlmEmbeddingProvider
impl Sync for LlmEmbeddingProvider
impl Unpin for LlmEmbeddingProvider
impl UnsafeUnpin for LlmEmbeddingProvider
impl UnwindSafe for LlmEmbeddingProvider
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> 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