zagens_runtime/cli/handlers/
models.rs1use anyhow::Result;
2
3use crate::cli::args::ModelsArgs;
4use crate::cli::context::CliContext;
5use crate::client::DeepSeekClient;
6
7pub async fn run(ctx: &CliContext, args: ModelsArgs) -> Result<()> {
8 let client = DeepSeekClient::new(&ctx.config)?;
9 let mut models = client.list_models().await?;
10 models.sort_by(|a, b| a.id.cmp(&b.id));
11
12 if args.json {
13 println!("{}", serde_json::to_string_pretty(&models)?);
14 return Ok(());
15 }
16
17 if models.is_empty() {
18 println!("No models returned by the API.");
19 return Ok(());
20 }
21
22 let default_model = ctx.config.default_model();
23 println!("Available models (default: {default_model})");
24 for model in models {
25 let marker = if model.id == default_model { "*" } else { " " };
26 if let Some(owner) = model.owned_by {
27 println!("{marker} {} ({owner})", model.id);
28 } else {
29 println!("{marker} {}", model.id);
30 }
31 }
32
33 Ok(())
34}