Skip to main content

floopy/types/
evaluations.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4/// A dataset evaluation run.
5#[derive(Debug, Clone, Deserialize)]
6pub struct EvaluationRun {
7    /// Run id.
8    pub id: String,
9    /// Dataset under evaluation.
10    pub dataset_id: String,
11    /// Model under evaluation.
12    pub model: String,
13    /// Stored prompt id, if used.
14    pub prompt_id: Option<String>,
15    /// Lifecycle state (`pending`/`running`/`completed`/`failed`/`cancelled`).
16    pub status: String,
17    /// Free-form run configuration.
18    pub config: Option<Value>,
19    /// RFC3339 creation timestamp.
20    pub created_at: String,
21    /// RFC3339 start timestamp, if started.
22    pub started_at: Option<String>,
23    /// RFC3339 finish timestamp, if finished.
24    pub finished_at: Option<String>,
25}
26
27/// One scored row of an evaluation.
28#[derive(Debug, Clone, Deserialize)]
29pub struct EvaluationResultRow {
30    /// Row id.
31    pub id: String,
32    /// Owning run id.
33    pub run_id: String,
34    /// Dataset input id.
35    pub input_id: String,
36    /// Model output.
37    pub output: String,
38    /// Score, if computed.
39    pub score: Option<f64>,
40    /// Free-form per-row metadata.
41    pub metadata: Option<Value>,
42    /// RFC3339 creation timestamp.
43    pub created_at: String,
44}
45
46/// One page of [`crate::resources::Evaluations::results`].
47#[derive(Debug, Clone, Deserialize)]
48pub struct EvaluationResultsPage {
49    /// Result rows in this page.
50    pub items: Vec<EvaluationResultRow>,
51    /// Cursor for the next page, if any.
52    pub next_cursor: Option<String>,
53    /// Whether more pages follow.
54    pub has_more: bool,
55}
56
57/// Arguments for [`crate::resources::Evaluations::create`].
58#[derive(Debug, Clone, Serialize)]
59pub struct EvaluationCreateParams {
60    /// Dataset to evaluate.
61    pub dataset_id: String,
62    /// Model to evaluate.
63    pub model: String,
64    /// Optional stored prompt id.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub prompt_id: Option<String>,
67    /// Optional free-form run configuration.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub config: Option<Value>,
70}