use serde::Serialize;
use url::Url;
use crate::{
errors::OapiError,
rest::post::{Post, PostNoStream},
vector_stores::file_batches::VectorStoreFileBatch,
};
#[derive(Debug, Clone, Serialize)]
pub struct CreateVectorStoreFileBatchRequest<'a> {
#[serde(skip)]
pub vector_store_id: &'a str,
pub file_ids: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub chunking_strategy: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<serde_json::Value>,
#[serde(flatten, skip_serializing_if = "Option::is_none")]
pub extra_body: Option<serde_json::Map<String, serde_json::Value>>,
}
impl Post for CreateVectorStoreFileBatchRequest<'_> {
fn is_streaming(&self) -> bool {
false
}
fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
let mut url =
Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
url.path_segments_mut()
.map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
.push("vector_stores")
.push(self.vector_store_id)
.push("file_batches");
Ok(url.to_string())
}
}
impl PostNoStream for CreateVectorStoreFileBatchRequest<'_> {
type Response = VectorStoreFileBatch;
}