Skip to main content

openai_interface/vector_stores/
delete.rs

1//! Delete a vector store via `DELETE /vector_stores/{vector_store_id}`.
2//!
3//! > ![warn] This module is untested!
4//! > If you encounter any issues, please report them on the repository.
5
6use url::Url;
7
8use crate::{
9    errors::OapiError,
10    rest::delete::{Delete, DeleteNoStream},
11};
12
13/// Deletes a vector store by its ID.
14#[derive(Debug, Clone)]
15pub struct DeleteVectorStoreRequest<'a> {
16    /// The ID of the vector store to delete, e.g. `vs_...`.
17    pub vector_store_id: &'a str,
18}
19
20impl Delete for DeleteVectorStoreRequest<'_> {
21    /// Builds the URL for the request.
22    ///
23    /// `base_url` should be like <https://api.openai.com/v1>
24    fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
25        let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
26        url.path_segments_mut()
27            .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
28            .push("vector_stores")
29            .push(self.vector_store_id);
30        Ok(url.to_string())
31    }
32}
33
34impl DeleteNoStream for DeleteVectorStoreRequest<'_> {
35    type Response = DeleteVectorStoreResponse;
36}
37
38/// The response of a vector store deletion.
39#[derive(Debug, Clone, serde::Deserialize)]
40pub struct DeleteVectorStoreResponse {
41    /// The ID of the vector store that was deleted.
42    pub id: String,
43    /// Whether the vector store was deleted successfully.
44    pub deleted: bool,
45    /// The object type (`vector_store.deleted`), if the provider sends
46    /// it.
47    #[serde(default)]
48    pub object: Option<String>,
49}
50
51crate::impl_from_str!(DeleteVectorStoreResponse);