langfuse_client_base/models/
numeric_score_1.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct NumericScore1 {
16 #[serde(rename = "id")]
17 pub id: String,
18 #[serde(
20 rename = "traceId",
21 default,
22 with = "::serde_with::rust::double_option",
23 skip_serializing_if = "Option::is_none"
24 )]
25 pub trace_id: Option<Option<String>>,
26 #[serde(
28 rename = "sessionId",
29 default,
30 with = "::serde_with::rust::double_option",
31 skip_serializing_if = "Option::is_none"
32 )]
33 pub session_id: Option<Option<String>>,
34 #[serde(
36 rename = "observationId",
37 default,
38 with = "::serde_with::rust::double_option",
39 skip_serializing_if = "Option::is_none"
40 )]
41 pub observation_id: Option<Option<String>>,
42 #[serde(
44 rename = "datasetRunId",
45 default,
46 with = "::serde_with::rust::double_option",
47 skip_serializing_if = "Option::is_none"
48 )]
49 pub dataset_run_id: Option<Option<String>>,
50 #[serde(rename = "name")]
51 pub name: String,
52 #[serde(rename = "source")]
53 pub source: models::ScoreSource,
54 #[serde(rename = "timestamp")]
55 pub timestamp: chrono::DateTime<chrono::FixedOffset>,
56 #[serde(rename = "createdAt")]
57 pub created_at: chrono::DateTime<chrono::FixedOffset>,
58 #[serde(rename = "updatedAt")]
59 pub updated_at: chrono::DateTime<chrono::FixedOffset>,
60 #[serde(rename = "authorUserId", deserialize_with = "Option::deserialize")]
62 pub author_user_id: Option<String>,
63 #[serde(rename = "comment", deserialize_with = "Option::deserialize")]
65 pub comment: Option<String>,
66 #[serde(
68 rename = "metadata",
69 default,
70 with = "::serde_with::rust::double_option",
71 skip_serializing_if = "Option::is_none"
72 )]
73 pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
74 #[serde(rename = "configId", deserialize_with = "Option::deserialize")]
76 pub config_id: Option<String>,
77 #[serde(rename = "queueId", deserialize_with = "Option::deserialize")]
79 pub queue_id: Option<String>,
80 #[serde(rename = "environment")]
82 pub environment: String,
83 #[serde(rename = "value")]
85 pub value: f64,
86 #[serde(rename = "dataType")]
87 pub data_type: DataType,
88}
89
90impl NumericScore1 {
91 pub fn new(
92 id: String,
93 name: String,
94 source: models::ScoreSource,
95 timestamp: chrono::DateTime<chrono::FixedOffset>,
96 created_at: chrono::DateTime<chrono::FixedOffset>,
97 updated_at: chrono::DateTime<chrono::FixedOffset>,
98 author_user_id: Option<String>,
99 comment: Option<String>,
100 config_id: Option<String>,
101 queue_id: Option<String>,
102 environment: String,
103 value: f64,
104 data_type: DataType,
105 ) -> NumericScore1 {
106 NumericScore1 {
107 id,
108 trace_id: None,
109 session_id: None,
110 observation_id: None,
111 dataset_run_id: None,
112 name,
113 source,
114 timestamp,
115 created_at,
116 updated_at,
117 author_user_id,
118 comment,
119 metadata: None,
120 config_id,
121 queue_id,
122 environment,
123 value,
124 data_type,
125 }
126 }
127}
128#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
130pub enum DataType {
131 #[serde(rename = "NUMERIC")]
132 Numeric,
133}
134
135impl Default for DataType {
136 fn default() -> DataType {
137 Self::Numeric
138 }
139}