diff --git a/crates/localllm-cli/src/main.rs b/crates/localllm-cli/src/main.rs index 53caa52..599262f 100644 --- a/crates/localllm-cli/src/main.rs +++ b/crates/localllm-cli/src/main.rs @@ -747,23 +747,41 @@ fn backend_request(cli: &Cli) -> BackendRequest { } } -fn backend_response_preview(cli: &Cli, _status_code: u16, _body: &str) -> BackendResponsePreview { +fn backend_response_preview(cli: &Cli, _status_code: u16, body: &str) -> BackendResponsePreview { match &cli.command { - Commands::Status => BackendResponsePreview::SummaryOnly { - command: "response-unimplemented".to_owned(), - }, - Commands::Models(models) => match &models.command { - ModelsSubcommand::List => BackendResponsePreview::SummaryOnly { + Commands::Status => serde_json::from_str::(body) + .map(|health| BackendResponsePreview::Health { + status: health.status, + model_loaded: health.model_loaded, + model_id: health.model_id, + uptime_secs: health.uptime_secs, + }) + .unwrap_or_else(|_| BackendResponsePreview::SummaryOnly { command: "response-unimplemented".to_owned(), - }, + }), + Commands::Models(models) => match &models.command { + ModelsSubcommand::List => serde_json::from_str::(body) + .map(|models| BackendResponsePreview::Models { + count: models.data.len(), + ids: models.data.into_iter().map(|model| model.id).collect(), + }) + .unwrap_or_else(|_| BackendResponsePreview::SummaryOnly { + command: "response-unimplemented".to_owned(), + }), _ => BackendResponsePreview::SummaryOnly { command: command_summary(&cli.command), }, }, Commands::Bench(bench) => match &bench.command { - BenchSubcommand::Throughput(_) => BackendResponsePreview::SummaryOnly { - command: "response-unimplemented".to_owned(), - }, + BenchSubcommand::Throughput(args) => serde_json::from_str::(body) + .map(|response| BackendResponsePreview::Throughput { + model: args.model.clone(), + total_tokens: response.usage.total_tokens, + tokens_per_second: response.usage.tokens_per_second, + }) + .unwrap_or_else(|_| BackendResponsePreview::SummaryOnly { + command: "response-unimplemented".to_owned(), + }), _ => BackendResponsePreview::SummaryOnly { command: command_summary(&cli.command), },