systemprompt_evaluation/models/
run.rs1use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8use systemprompt_identifiers::{EvalRubricId, EvalRunId, UserId};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "lowercase")]
12pub enum EvalRunKind {
13 Judge,
14 Replay,
15 Pairwise,
16}
17
18impl EvalRunKind {
19 #[must_use]
20 pub const fn as_str(self) -> &'static str {
21 match self {
22 Self::Judge => "judge",
23 Self::Replay => "replay",
24 Self::Pairwise => "pairwise",
25 }
26 }
27}
28
29impl std::str::FromStr for EvalRunKind {
30 type Err = String;
31
32 fn from_str(s: &str) -> Result<Self, Self::Err> {
33 match s {
34 "judge" => Ok(Self::Judge),
35 "replay" => Ok(Self::Replay),
36 "pairwise" => Ok(Self::Pairwise),
37 other => Err(format!("unknown eval run kind: {other}")),
38 }
39 }
40}
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
43#[serde(rename_all = "lowercase")]
44pub enum EvalRunStatus {
45 Running,
46 Completed,
47 Failed,
48}
49
50impl EvalRunStatus {
51 #[must_use]
52 pub const fn as_str(self) -> &'static str {
53 match self {
54 Self::Running => "running",
55 Self::Completed => "completed",
56 Self::Failed => "failed",
57 }
58 }
59}
60
61#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
62#[serde(rename_all = "lowercase")]
63pub enum TriggerSource {
64 Scheduled,
65 Cli,
66 Manual,
67}
68
69impl TriggerSource {
70 #[must_use]
71 pub const fn as_str(self) -> &'static str {
72 match self {
73 Self::Scheduled => "scheduled",
74 Self::Cli => "cli",
75 Self::Manual => "manual",
76 }
77 }
78}
79
80#[derive(Debug, Clone)]
81pub struct EvalRun {
82 pub id: EvalRunId,
83 pub kind: EvalRunKind,
84 pub status: EvalRunStatus,
85 pub judge_provider: String,
86 pub judge_model: String,
87 pub sample_size: i32,
88 pub scored_count: i32,
89 pub failed_count: i32,
90 pub cost_microdollars: i64,
91 pub created_by: UserId,
92 pub created_at: DateTime<Utc>,
93 pub completed_at: Option<DateTime<Utc>>,
94 pub error_message: Option<String>,
95 pub rubric_id: Option<EvalRubricId>,
96 pub trigger_source: TriggerSource,
97}
98
99#[derive(Debug, Clone)]
100pub struct NewRunParams {
101 pub kind: EvalRunKind,
102 pub judge_provider: String,
103 pub judge_model: String,
104 pub sample_size: i32,
105 pub created_by: UserId,
106 pub rubric_id: Option<EvalRubricId>,
107 pub trigger_source: TriggerSource,
108}