pub struct EmbeddingRequest {
pub model: String,
pub input: EmbeddingInput,
pub dimensions: Option<usize>,
pub encoding_format: Option<EncodingFormat>,
pub input_type: Option<EmbeddingInputType>,
}Expand description
Request for generating embeddings.
Fields§
§model: StringThe embedding model to use (e.g., “text-embedding-3-small”).
input: EmbeddingInputThe input text(s) to embed.
dimensions: Option<usize>Optional: Number of dimensions for the output embedding. Only supported by some models (e.g., OpenAI text-embedding-3-*).
encoding_format: Option<EncodingFormat>Optional: Output encoding format.
input_type: Option<EmbeddingInputType>Optional: Input type hint for optimized embeddings. Supported by some providers like Voyage AI.
Implementations§
Source§impl EmbeddingRequest
impl EmbeddingRequest
Sourcepub fn new(model: impl Into<String>, text: impl Into<String>) -> Self
pub fn new(model: impl Into<String>, text: impl Into<String>) -> Self
Create a new embedding request for a single text.
Sourcepub fn batch(model: impl Into<String>, texts: Vec<impl Into<String>>) -> Self
pub fn batch(model: impl Into<String>, texts: Vec<impl Into<String>>) -> Self
Create a new embedding request for multiple texts (batch).
Sourcepub fn with_dimensions(self, dimensions: usize) -> Self
pub fn with_dimensions(self, dimensions: usize) -> Self
Set the output dimensions (for models that support dimension reduction).
Sourcepub fn with_encoding_format(self, format: EncodingFormat) -> Self
pub fn with_encoding_format(self, format: EncodingFormat) -> Self
Set the encoding format.
Sourcepub fn with_input_type(self, input_type: EmbeddingInputType) -> Self
pub fn with_input_type(self, input_type: EmbeddingInputType) -> Self
Set the input type hint.
Sourcepub fn text_count(&self) -> usize
pub fn text_count(&self) -> usize
Get the number of texts to embed.
Trait Implementations§
Source§impl Clone for EmbeddingRequest
impl Clone for EmbeddingRequest
Source§fn clone(&self) -> EmbeddingRequest
fn clone(&self) -> EmbeddingRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EmbeddingRequest
impl RefUnwindSafe for EmbeddingRequest
impl Send for EmbeddingRequest
impl Sync for EmbeddingRequest
impl Unpin for EmbeddingRequest
impl UnwindSafe for EmbeddingRequest
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