Skip to main content

systemprompt_cli/commands/admin/evals/
list.rs

1//! `admin evals list` — list evaluation runs.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use anyhow::Result;
7use clap::Args;
8use serde::Serialize;
9
10use super::shared::eval_context;
11use crate::context::CommandContext;
12use crate::shared::CommandOutput;
13
14#[derive(Debug, Clone, Copy, Args)]
15pub struct ListArgs {
16    #[arg(long, default_value_t = 20, help = "Maximum runs to show")]
17    pub limit: i64,
18}
19
20#[derive(Debug, Serialize)]
21struct RunRow {
22    id: String,
23    kind: &'static str,
24    status: &'static str,
25    judge: String,
26    scored: i32,
27    failed: i32,
28    cost_microdollars: i64,
29    created_at: String,
30}
31
32pub async fn execute(args: ListArgs, ctx: &CommandContext) -> Result<CommandOutput> {
33    let eval = eval_context(ctx).await?;
34    let runs = eval.evaluation.list_runs(args.limit).await?;
35
36    let rows: Vec<RunRow> = runs
37        .into_iter()
38        .map(|run| RunRow {
39            id: run.id.as_str().to_owned(),
40            kind: run.kind.as_str(),
41            status: run.status.as_str(),
42            judge: format!("{}/{}", run.judge_provider, run.judge_model),
43            scored: run.scored_count,
44            failed: run.failed_count,
45            cost_microdollars: run.cost_microdollars,
46            created_at: run.created_at.to_rfc3339(),
47        })
48        .collect();
49
50    Ok(CommandOutput::table_of(
51        vec![
52            "id",
53            "kind",
54            "status",
55            "judge",
56            "scored",
57            "failed",
58            "cost_microdollars",
59            "created_at",
60        ],
61        &rows,
62    ))
63}