pub struct EmbeddingsBuilder { /* private fields */ }Expand description
Builder for creating embedding requests.
§Examples
use openai_ergonomic::{Builder, EmbeddingsBuilder};
let request = EmbeddingsBuilder::new("text-embedding-3-small")
.input_text("hello world")
.dimensions(256)
.build()
.unwrap();
assert_eq!(request.model, "text-embedding-3-small");
assert_eq!(request.dimensions, Some(256));Implementations§
Source§impl EmbeddingsBuilder
impl EmbeddingsBuilder
Sourcepub fn new(model: impl Into<String>) -> Self
pub fn new(model: impl Into<String>) -> Self
Create a new embeddings builder for the specified model.
Sourcepub fn input(self, input: EmbeddingInput) -> Self
pub fn input(self, input: EmbeddingInput) -> Self
Provide the request input explicitly.
Sourcepub fn input_text(self, text: impl Into<String>) -> Self
pub fn input_text(self, text: impl Into<String>) -> Self
Embed a single string input.
Sourcepub fn input_texts<I, S>(self, texts: I) -> Self
pub fn input_texts<I, S>(self, texts: I) -> Self
Embed multiple string inputs in one request.
Sourcepub fn input_tokens<I>(self, tokens: I) -> Selfwhere
I: IntoIterator<Item = i32>,
pub fn input_tokens<I>(self, tokens: I) -> Selfwhere
I: IntoIterator<Item = i32>,
Embed a single tokenized input.
Sourcepub fn input_token_batches<I, J>(self, batches: I) -> Self
pub fn input_token_batches<I, J>(self, batches: I) -> Self
Embed multiple tokenized inputs.
Sourcepub fn encoding_format(self, format: EncodingFormat) -> Self
pub fn encoding_format(self, format: EncodingFormat) -> Self
Set the encoding format for the embeddings response.
Sourcepub fn dimensions(self, dimensions: i32) -> Self
pub fn dimensions(self, dimensions: i32) -> Self
Set the output dimensions for supported models.
Sourcepub fn user(self, user: impl Into<String>) -> Self
pub fn user(self, user: impl Into<String>) -> Self
Associate a user identifier with the request.
Sourcepub fn input_ref(&self) -> Option<&EmbeddingInput>
pub fn input_ref(&self) -> Option<&EmbeddingInput>
Access the configured input, if set.
Sourcepub fn encoding_format_ref(&self) -> Option<EncodingFormat>
pub fn encoding_format_ref(&self) -> Option<EncodingFormat>
Access the configured encoding format, if set.
Sourcepub fn dimensions_ref(&self) -> Option<i32>
pub fn dimensions_ref(&self) -> Option<i32>
Access the configured dimensions, if set.
Trait Implementations§
Source§impl Builder<CreateEmbeddingRequest> for EmbeddingsBuilder
impl Builder<CreateEmbeddingRequest> for EmbeddingsBuilder
Source§fn build(self) -> Result<CreateEmbeddingRequest>
fn build(self) -> Result<CreateEmbeddingRequest>
Build the final request type.
Source§impl Clone for EmbeddingsBuilder
impl Clone for EmbeddingsBuilder
Source§fn clone(&self) -> EmbeddingsBuilder
fn clone(&self) -> EmbeddingsBuilder
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 EmbeddingsBuilder
impl RefUnwindSafe for EmbeddingsBuilder
impl Send for EmbeddingsBuilder
impl Sync for EmbeddingsBuilder
impl Unpin for EmbeddingsBuilder
impl UnwindSafe for EmbeddingsBuilder
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