use bunsen::errors::BunsenResult;
use bunsen_app::{
cache::WeightsCacheArgs,
logging::{
LevelFilter,
LogArgs,
LogPolicy,
},
};
use crate::{
chat::ChatModelFamily,
support::{
print_model_row,
print_providers,
},
};
#[derive(clap::Args, Debug)]
pub struct ChatListCommand {
#[clap(flatten)]
logging: LogArgs,
#[clap(flatten)]
cache: WeightsCacheArgs,
#[arg(long)]
urls: bool,
}
impl ChatListCommand {
pub fn run(
&self,
families: &[ChatModelFamily],
) -> BunsenResult<()> {
self.logging
.init(LogPolicy::new(LevelFilter::Info, LevelFilter::Info))?;
let cache = self.cache.init()?;
println!("cache: {}", cache.cache_dir().display());
for &family in families {
let default = family.default_model();
println!();
println!("# {} checkpoints (the default: {default})", family.name());
print_providers(&family.providers()?);
for (id, row) in family.rows()? {
print_model_row(&cache, &id, &row, default, self.urls);
}
if let Some(note) = family.hf_note() {
println!();
println!("{note}");
}
}
Ok(())
}
}