Skip to main content

abu_base/embed/
mod.rs

1use serde::{Deserialize, Serialize};
2use super::common::Usage;
3
4#[derive(Debug, Clone, Serialize)]
5pub struct EmbedRequest {
6    pub input: Vec<String>,
7    pub model: String,
8}
9
10impl EmbedRequest {
11    pub fn new(input: impl Into<Vec<String>>, model: impl Into<String>) -> Self {
12        Self { input: input.into(), model: model.into() }
13    }
14
15    pub fn single(input: impl Into<String>, model: impl Into<String>) -> Self {
16        Self {
17            input: vec![input.into()],
18            model: model.into(),
19        }
20    }
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct EmbedResponse {
25    pub embeddings: Vec<Vec<f32>>,
26    pub usage: Usage,
27}