openai-interface 0.13.0

A low-level Rust interface for the OpenAI API
Documentation
//! Retrieve a vector store via `GET /vector_stores/{vector_store_id}`.
//!
//! > ![warn] This module is untested!
//! > If you encounter any issues, please report them on the repository.

use url::Url;

use crate::{
    errors::OapiError,
    rest::get::{Get, GetNoStream},
    vector_stores::VectorStore,
};

/// Retrieves a vector store by its ID.
#[derive(Debug, Clone)]
pub struct RetrieveVectorStoreRequest<'a> {
    /// The ID of the vector store to retrieve, e.g. `vs_...`.
    pub vector_store_id: &'a str,
}

impl Get for RetrieveVectorStoreRequest<'_> {
    /// Builds the URL for the request.
    ///
    /// `base_url` should be like <https://api.openai.com/v1>
    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);
        Ok(url.to_string())
    }
}

impl GetNoStream for RetrieveVectorStoreRequest<'_> {
    type Response = VectorStore;
}