pub struct MistralEmbeddingClient { /* private fields */ }Expand description
A Mistral embeddings client (POST {base_url}/embeddings).
let client = MistralEmbeddingClient::from_env(None)?; // mistral-embed
let batch = client.get_embeddings(vec!["hello".into()], None).await?;
println!("{} dims", batch[0].dimensions());Implementations§
Source§impl MistralEmbeddingClient
impl MistralEmbeddingClient
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 client for the given API key and embedding model
(None → DEFAULT_EMBEDDING_MODEL).
Sourcepub fn from_env(model: Option<String>) -> Result<Self>
pub fn from_env(model: Option<String>) -> Result<Self>
Build a client from the MISTRAL_API_KEY (and optional
MISTRAL_BASE_URL) environment variables.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the base URL.
Trait Implementations§
Source§impl Clone for MistralEmbeddingClient
impl Clone for MistralEmbeddingClient
Source§fn clone(&self) -> MistralEmbeddingClient
fn clone(&self) -> MistralEmbeddingClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MistralEmbeddingClient
impl Debug for MistralEmbeddingClient
Source§impl EmbeddingClient for MistralEmbeddingClient
impl EmbeddingClient for MistralEmbeddingClient
Source§fn get_embeddings<'life0, 'async_trait>(
&'life0 self,
values: Vec<String>,
options: Option<EmbeddingGenerationOptions>,
) -> Pin<Box<dyn Future<Output = Result<GeneratedEmbeddings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_embeddings<'life0, 'async_trait>(
&'life0 self,
values: Vec<String>,
options: Option<EmbeddingGenerationOptions>,
) -> Pin<Box<dyn Future<Output = Result<GeneratedEmbeddings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generate embeddings for the given values (one per value, in order).
Auto Trait Implementations§
impl !RefUnwindSafe for MistralEmbeddingClient
impl !UnwindSafe for MistralEmbeddingClient
impl Freeze for MistralEmbeddingClient
impl Send for MistralEmbeddingClient
impl Sync for MistralEmbeddingClient
impl Unpin for MistralEmbeddingClient
impl UnsafeUnpin for MistralEmbeddingClient
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