Skip to main content

systemprompt_evaluation/models/
case.rs

1//! Evaluation case model captured from sampled traffic.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8use serde_json::Value;
9use systemprompt_identifiers::{AiRequestId, EvalCaseId, UserId};
10
11/// Provider-neutral reconstruction of an AI request.
12///
13/// Built from `ai_request_messages` plus the request row's model/provider
14/// columns — never from the provider-specific wire body — so it can be
15/// replayed through any configured provider.
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct CanonicalPrompt {
18    pub messages: Vec<CanonicalMessage>,
19    pub system_prompt: Option<String>,
20    pub offered_tools: Option<Value>,
21    pub provider: String,
22    pub model: String,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct CanonicalMessage {
27    pub role: String,
28    pub content: String,
29}
30
31#[derive(Debug, Clone)]
32pub struct EvalCase {
33    pub id: EvalCaseId,
34    pub name: String,
35    pub prompt_body: Value,
36    pub source_ai_request_id: Option<AiRequestId>,
37    pub expectation: Option<String>,
38    pub tags: Vec<String>,
39    pub enabled: bool,
40    pub created_by: UserId,
41    pub created_at: DateTime<Utc>,
42    pub repair_hint: Option<String>,
43    pub canonical_messages: Option<Value>,
44    pub system_prompt: Option<String>,
45    pub offered_tools: Option<Value>,
46    pub provider: Option<String>,
47    pub model: Option<String>,
48    pub prepared_body_sha256: Option<String>,
49}
50
51#[derive(Debug, Clone)]
52pub struct NewCaseParams {
53    pub name: String,
54    pub prompt: CanonicalPrompt,
55    pub source_ai_request_id: Option<AiRequestId>,
56    pub expectation: Option<String>,
57    pub tags: Vec<String>,
58    pub created_by: UserId,
59    pub prepared_body_sha256: Option<String>,
60}