use anyhow::Result;
use clap::Args;
use serde::Serialize;
use systemprompt_identifiers::EvalRunId;
use super::shared::eval_context;
use crate::context::CommandContext;
use crate::shared::CommandOutput;
#[derive(Debug, Args)]
pub struct ShowArgs {
#[arg(help = "Run id")]
pub run_id: String,
}
#[derive(Debug, Serialize)]
struct ResultRow {
id: String,
ai_request_id: String,
model: String,
score: String,
verdict: &'static str,
repaired: bool,
replay_of: String,
repair_hint: String,
rationale: String,
}
pub async fn execute(args: ShowArgs, ctx: &CommandContext) -> Result<CommandOutput> {
let eval = eval_context(ctx).await?;
let run_id = EvalRunId::new(args.run_id);
let run = eval.evaluation.get_run(&run_id).await?;
let results = eval.evaluation.list_results(&run_id).await?;
let rows: Vec<ResultRow> = results
.into_iter()
.map(|result| ResultRow {
id: result.id.as_str().to_owned(),
ai_request_id: result
.ai_request_id
.map(|id| id.as_str().to_owned())
.unwrap_or_default(),
model: result.model,
score: result
.overall_score
.map(|s| s.to_string())
.unwrap_or_default(),
verdict: result.verdict.as_str(),
repaired: result.repaired,
replay_of: result
.replay_of_result_id
.map(|id| id.as_str().to_owned())
.unwrap_or_default(),
repair_hint: result.repair_hint.unwrap_or_default(),
rationale: result.rationale.unwrap_or_default(),
})
.collect();
Ok(CommandOutput::table_of(
vec![
"id",
"ai_request_id",
"model",
"score",
"verdict",
"repaired",
"replay_of",
"repair_hint",
"rationale",
],
&rows,
)
.with_title(format!(
"Run {} — {} {} (scored {}, failed {})",
run.id,
run.kind.as_str(),
run.status.as_str(),
run.scored_count,
run.failed_count
)))
}