refactor: rename ListModels* to ModelList*

This commit is contained in:
Ivan Gabriele
2024-03-04 01:56:48 +01:00
parent 809af31dd0
commit 4e702aa48e
3 changed files with 9 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ use crate::v1::{
ChatCompletionMessage, ChatCompletionParams, ChatCompletionRequest, ChatCompletionResponse,
},
constants::API_URL_BASE,
list_models::ListModelsResponse,
model_list::ModelListResponse,
};
pub struct Client {
@@ -145,9 +145,9 @@ impl Client {
}
}
pub fn list_models(&self) -> Result<ListModelsResponse, APIError> {
pub fn list_models(&self) -> Result<ModelListResponse, APIError> {
let response = self.get("/models")?;
let result = response.json::<ListModelsResponse>();
let result = response.json::<ModelListResponse>();
match result {
Ok(response) => Ok(response),
Err(error) => Err(self.new_error(error)),

View File

@@ -3,4 +3,4 @@ pub mod client;
pub mod common;
pub mod constants;
pub mod error;
pub mod list_models;
pub mod model_list;

View File

@@ -1,19 +1,19 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListModelsResponse {
pub struct ModelListResponse {
pub object: String,
pub data: Vec<ListModelsModel>,
pub data: Vec<ModelListData>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListModelsModel {
pub struct ModelListData {
pub id: String,
pub object: String,
/// Unix timestamp (in seconds).
pub created: u32,
pub owned_by: String,
pub permission: Vec<ListModelsModelPermission>,
pub permission: Vec<ModelListDataPermission>,
// TODO Check this prop (seen in API responses but undocumented).
// pub root: ???,
// TODO Check this prop (seen in API responses but undocumented).
@@ -21,7 +21,7 @@ pub struct ListModelsModel {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListModelsModelPermission {
pub struct ModelListDataPermission {
pub id: String,
pub object: String,
/// Unix timestamp (in seconds).