use crate::{
config::Config,
error::OpenAIError,
types::{DeleteModelResponse, ListModelResponse, Model},
Client,
};
pub struct Models<'c, C: Config> {
client: &'c Client<C>,
}
impl<'c, C: Config> Models<'c, C> {
pub fn new(client: &'c Client<C>) -> Self {
Self { client }
}
#[crate::byot(R = serde::de::DeserializeOwned)]
pub async fn list(&self) -> Result<ListModelResponse, OpenAIError> {
self.client.get("/models").await
}
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
pub async fn retrieve(&self, id: &str) -> Result<Model, OpenAIError> {
self.client.get(format!("/models/{id}").as_str()).await
}
#[crate::byot(T0 = std::fmt::Display, R = serde::de::DeserializeOwned)]
pub async fn delete(&self, model: &str) -> Result<DeleteModelResponse, OpenAIError> {
self.client
.delete(format!("/models/{model}").as_str())
.await
}
}