Skip to main content

lm_studio_api_extended/embedding/
embed_response.rs

1/// EmbeddingResponse represents the response from the embedding API.
2/// It contains the embedding vector and metadata about the response.
3use crate::prelude::*;
4
5/// The response to an embedding request, 
6/// including the vector and its metadata
7#[derive(Debug, Clone, Deserialize, Serialize)]
8pub struct EmbeddingResponse {
9    /// Type of object returned (e.g., "embedding"). Useful for 
10    /// distinguishing response types.
11    pub object: String,
12
13    /// The embedding vector generated for the input text. This 
14    /// is the main result.
15    pub embedding: Vec<f32>,
16    
17    /// Index of the input in the batch. Useful when multiple 
18    /// inputs are embedded at once.
19    pub index: i32
20}
21
22impl EmbeddingResponse {
23    /// Returns a clone of the embedding vector. This allows 
24    /// further processing without mutating the original response.
25    pub fn actual_embedding(&self) -> Vec<f32> {
26        self.embedding.clone()
27    }
28}