Skip to main content

handle_embedding_response

Function handle_embedding_response 

Source
pub fn handle_embedding_response(
    original_texts: &[&str],
    embeddings: Vec<Vec<f32>>,
    dimensions: usize,
) -> Vec<Vec<f32>>
Expand description

Replace embeddings for originally-invalid inputs with zero vectors.

Iterates original_texts in parallel with embeddings. For each slot where original_texts[i] is empty or whitespace-only (as determined by is_embeddable), the corresponding embedding is replaced with a zero vector of length dimensions.

This must be called with the original (unsanitized) texts, not the sanitized ones returned by sanitize_embedding_inputs.