pub struct CohereEmbeddingProvider { /* private fields */ }Expand description
Embedding provider backed by the Cohere embed API (v2).
Stores the API key, model, and dimension configuration. Calling [embed()]
performs a real HTTP request when the http-embeddings feature is enabled.
Without the feature, it returns an error. For local/offline embeddings, use
LocalEmbedding.
Implementations§
Source§impl CohereEmbeddingProvider
impl CohereEmbeddingProvider
Sourcepub fn new(api_key: impl Into<String>, model: Option<String>) -> Self
pub fn new(api_key: impl Into<String>, model: Option<String>) -> Self
Create a new Cohere embedding provider.
model defaults to "embed-english-v3.0".
Sourcepub fn with_input_type(self, input_type: impl Into<String>) -> Self
pub fn with_input_type(self, input_type: impl Into<String>) -> Self
Set the input type ("search_document" for indexing, "search_query" for querying).
Sourcepub fn with_dimensions(self, dimensions: usize) -> Self
pub fn with_dimensions(self, dimensions: usize) -> Self
Override the output dimension count.
Sourcepub fn input_type(&self) -> &str
pub fn input_type(&self) -> &str
Returns the current input type.
Trait Implementations§
Source§impl EmbeddingProvider for CohereEmbeddingProvider
impl EmbeddingProvider for CohereEmbeddingProvider
Source§fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
_text: &'life1 str,
) -> Pin<Box<dyn Future<Output = ArgentorResult<Vec<f32>>> + 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 = ArgentorResult<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Compute embedding vector for a single text.
Source§fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = ArgentorResult<Vec<Vec<f32>>>> + 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 = ArgentorResult<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Compute embeddings for a batch of texts.
Auto Trait Implementations§
impl Freeze for CohereEmbeddingProvider
impl RefUnwindSafe for CohereEmbeddingProvider
impl Send for CohereEmbeddingProvider
impl Sync for CohereEmbeddingProvider
impl Unpin for CohereEmbeddingProvider
impl UnsafeUnpin for CohereEmbeddingProvider
impl UnwindSafe for CohereEmbeddingProvider
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