pub struct ModelList {
pub data: Vec<Model>,
}Expand description
Represents a complete list of models from a provider.
This struct contains all available models from a provider. Providers that support pagination internally handle fetching all pages before returning results.
§Fields
data: The complete list of available models
§Example
use rig::model::{Model, ModelList};
let list = ModelList::new(vec![
Model::from_id("gpt-4"),
Model::from_id("gpt-3.5-turbo"),
]);
println!("Found {} models", list.len());
for model in list.iter() {
println!("- {}", model.display_name());
}Fields§
§data: Vec<Model>The complete list of available models
Implementations§
Source§impl ModelList
impl ModelList
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the list is empty.
§Example
use rig::model::ModelList;
let empty = ModelList::new(vec![]);
assert!(empty.is_empty());
let non_empty = ModelList::new(vec![rig::model::Model::from_id("gpt-4")]);
assert!(!non_empty.is_empty());Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of models in this page.
§Example
use rig::model::{Model, ModelList};
let list = ModelList::new(vec![
Model::from_id("gpt-4"),
Model::from_id("gpt-3.5-turbo"),
]);
assert_eq!(list.len(), 2);Sourcepub fn iter(&self) -> Iter<'_, Model>
pub fn iter(&self) -> Iter<'_, Model>
Returns an iterator over the models in this list.
§Example
use rig::model::{Model, ModelList};
let list = ModelList::new(vec![
Model::from_id("gpt-4"),
Model::from_id("gpt-3.5-turbo"),
]);
for model in list.iter() {
println!("Model: {}", model.display_name());
}Trait Implementations§
Source§impl<'de> Deserialize<'de> for ModelList
impl<'de> Deserialize<'de> for ModelList
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> IntoIterator for &'a ModelList
impl<'a> IntoIterator for &'a ModelList
Source§impl IntoIterator for ModelList
impl IntoIterator for ModelList
Auto Trait Implementations§
impl Freeze for ModelList
impl RefUnwindSafe for ModelList
impl Send for ModelList
impl Sync for ModelList
impl Unpin for ModelList
impl UnsafeUnpin for ModelList
impl UnwindSafe for ModelList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more