Skip to main content

sanitize_embedding_inputs

Function sanitize_embedding_inputs 

Source
pub fn sanitize_embedding_inputs<'a>(texts: &[&'a str]) -> Vec<Cow<'a, str>>
Expand description

Replace empty/whitespace-only strings with "." to prevent API errors.

Returns a Vec<Cow<str>> of the same length as texts. Non-empty strings are returned as Cow::Borrowed (zero-copy); empty/whitespace-only strings are replaced with Cow::Owned(".").

After receiving the API response, pair this with handle_embedding_response to zero out vectors for slots that were originally invalid.