systemprompt_cli/commands/admin/evals/
show.rs1use anyhow::Result;
7use clap::Args;
8use serde::Serialize;
9use systemprompt_identifiers::EvalRunId;
10
11use super::shared::eval_context;
12use crate::context::CommandContext;
13use crate::shared::CommandOutput;
14
15#[derive(Debug, Args)]
16pub struct ShowArgs {
17 #[arg(help = "Run id")]
18 pub run_id: String,
19}
20
21#[derive(Debug, Serialize)]
22struct ResultRow {
23 id: String,
24 ai_request_id: String,
25 model: String,
26 score: String,
27 verdict: &'static str,
28 repaired: bool,
29 replay_of: String,
30 repair_hint: String,
31 rationale: String,
32}
33
34pub async fn execute(args: ShowArgs, ctx: &CommandContext) -> Result<CommandOutput> {
35 let eval = eval_context(ctx).await?;
36 let run_id = EvalRunId::new(args.run_id);
37 let run = eval.evaluation.get_run(&run_id).await?;
38 let results = eval.evaluation.list_results(&run_id).await?;
39
40 let rows: Vec<ResultRow> = results
41 .into_iter()
42 .map(|result| ResultRow {
43 id: result.id.as_str().to_owned(),
44 ai_request_id: result
45 .ai_request_id
46 .map(|id| id.as_str().to_owned())
47 .unwrap_or_default(),
48 model: result.model,
49 score: result
50 .overall_score
51 .map(|s| s.to_string())
52 .unwrap_or_default(),
53 verdict: result.verdict.as_str(),
54 repaired: result.repaired,
55 replay_of: result
56 .replay_of_result_id
57 .map(|id| id.as_str().to_owned())
58 .unwrap_or_default(),
59 repair_hint: result.repair_hint.unwrap_or_default(),
60 rationale: result.rationale.unwrap_or_default(),
61 })
62 .collect();
63
64 Ok(CommandOutput::table_of(
65 vec![
66 "id",
67 "ai_request_id",
68 "model",
69 "score",
70 "verdict",
71 "repaired",
72 "replay_of",
73 "repair_hint",
74 "rationale",
75 ],
76 &rows,
77 )
78 .with_title(format!(
79 "Run {} — {} {} (scored {}, failed {})",
80 run.id,
81 run.kind.as_str(),
82 run.status.as_str(),
83 run.scored_count,
84 run.failed_count
85 )))
86}