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