1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::{
error::OpenAIError,
types::{DeleteModelResponse, ListModelResponse, Model},
Client,
};
pub struct Models<'c> {
client: &'c Client,
}
impl<'c> Models<'c> {
pub fn new(client: &'c Client) -> Self {
Self { client }
}
pub async fn list(&self) -> Result<ListModelResponse, OpenAIError> {
self.client.get("/models").await
}
pub async fn retrieve(&self, id: &str) -> Result<Model, OpenAIError> {
self.client.get(format!("/models/{id}").as_str()).await
}
pub async fn delete(&self, model: &str) -> Result<DeleteModelResponse, OpenAIError> {
self.client
.delete(format!("/models/{model}").as_str())
.await
}
}