async_openai/types/graders/
grader.rs1use serde::{Deserialize, Serialize};
2
3use crate::types::evals::EvalItem;
4use crate::types::graders::ReasoningEffort;
5
6#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq)]
8#[serde(rename_all = "lowercase")]
9pub enum GraderStringCheckOperation {
10 Eq,
12 Ne,
14 Like,
16 Ilike,
18}
19
20#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
22pub struct GraderStringCheck {
23 pub name: String,
25 pub input: String,
27 pub reference: String,
29 pub operation: GraderStringCheckOperation,
31}
32
33#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
35pub struct GraderTextSimilarity {
36 pub name: String,
38 pub input: String,
40 pub reference: String,
42 pub evaluation_metric: GraderTextSimilarityEvaluationMetric,
44}
45
46#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq)]
48#[serde(rename_all = "snake_case")]
49pub enum GraderTextSimilarityEvaluationMetric {
50 Cosine,
51 FuzzyMatch,
52 Bleu,
53 Gleu,
54 Meteor,
55 Rouge1,
56 Rouge2,
57 Rouge3,
58 Rouge4,
59 Rouge5,
60 RougeL,
61}
62
63#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
65pub struct GraderPython {
66 pub name: String,
68 pub source: String,
70 pub image_tag: Option<String>,
72}
73
74#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
76pub struct GraderScoreModel {
77 pub name: String,
79 pub model: String,
81 pub input: Vec<EvalItem>,
83
84 #[serde(skip_serializing_if = "Option::is_none")]
86 pub sampling_params: Option<GraderScoreModelSamplingParams>,
87 #[serde(skip_serializing_if = "Option::is_none")]
89 pub range: Option<Vec<f64>>,
90}
91
92#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
93pub struct GraderScoreModelSamplingParams {
94 #[serde(skip_serializing_if = "Option::is_none")]
96 pub seed: Option<i32>,
97 #[serde(skip_serializing_if = "Option::is_none")]
99 pub top_p: Option<f64>,
100 #[serde(skip_serializing_if = "Option::is_none")]
102 pub temperature: Option<f64>,
103 #[serde(skip_serializing_if = "Option::is_none")]
105 pub max_completion_tokens: Option<i32>,
106 #[serde(skip_serializing_if = "Option::is_none")]
108 pub reasoning_effort: Option<ReasoningEffort>,
109}
110
111#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
112pub struct GraderLabelModel {
113 pub name: String,
115 pub model: String,
117 pub input: Vec<EvalItem>,
119 pub labels: Vec<String>,
121 pub passing_labels: Vec<String>,
123}
124
125#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
126#[serde(tag = "type", rename_all = "snake_case")]
127pub enum Graders {
128 StringCheck(GraderStringCheck),
129 TextSimilarity(GraderTextSimilarity),
130 Python(GraderPython),
131 ScoreModel(GraderScoreModel),
132 LabelModel(GraderLabelModel),
133}
134
135#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
136pub struct GraderMulti {
137 pub name: String,
139 pub graders: Graders,
140 pub calculate_output: String,
142}