use serde::{Deserialize, Serialize};
use super::{EmbedInput, ModelOptions};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EmbedRequest {
pub model: String,
pub input: EmbedInput,
#[serde(skip_serializing_if = "Option::is_none")]
pub truncate: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub dimensions: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub keep_alive: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub options: Option<ModelOptions>,
}
impl EmbedRequest {
pub fn new(model: impl Into<String>, input: impl Into<EmbedInput>) -> Self {
Self {
model: model.into(),
input: input.into(),
truncate: None,
dimensions: None,
keep_alive: None,
options: None,
}
}
pub fn with_truncate(mut self, truncate: bool) -> Self {
self.truncate = Some(truncate);
self
}
pub fn with_dimensions(mut self, dimensions: i32) -> Self {
self.dimensions = Some(dimensions);
self
}
pub fn with_keep_alive(mut self, keep_alive: impl Into<String>) -> Self {
self.keep_alive = Some(keep_alive.into());
self
}
pub fn with_options(mut self, options: ModelOptions) -> Self {
self.options = Some(options);
self
}
}