langfuse_client_base/models/
observations_view.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct ObservationsView {
16 #[serde(rename = "id")]
18 pub id: String,
19 #[serde(
21 rename = "traceId",
22 default,
23 with = "::serde_with::rust::double_option",
24 skip_serializing_if = "Option::is_none"
25 )]
26 pub trace_id: Option<Option<String>>,
27 #[serde(rename = "type")]
29 pub r#type: String,
30 #[serde(
32 rename = "name",
33 default,
34 with = "::serde_with::rust::double_option",
35 skip_serializing_if = "Option::is_none"
36 )]
37 pub name: Option<Option<String>>,
38 #[serde(rename = "startTime")]
40 pub start_time: String,
41 #[serde(
43 rename = "endTime",
44 default,
45 with = "::serde_with::rust::double_option",
46 skip_serializing_if = "Option::is_none"
47 )]
48 pub end_time: Option<Option<String>>,
49 #[serde(
51 rename = "completionStartTime",
52 default,
53 with = "::serde_with::rust::double_option",
54 skip_serializing_if = "Option::is_none"
55 )]
56 pub completion_start_time: Option<Option<String>>,
57 #[serde(
59 rename = "model",
60 default,
61 with = "::serde_with::rust::double_option",
62 skip_serializing_if = "Option::is_none"
63 )]
64 pub model: Option<Option<String>>,
65 #[serde(
67 rename = "modelParameters",
68 default,
69 with = "::serde_with::rust::double_option",
70 skip_serializing_if = "Option::is_none"
71 )]
72 pub model_parameters: Option<Option<std::collections::HashMap<String, models::MapValue>>>,
73 #[serde(
75 rename = "input",
76 default,
77 with = "::serde_with::rust::double_option",
78 skip_serializing_if = "Option::is_none"
79 )]
80 pub input: Option<Option<serde_json::Value>>,
81 #[serde(
83 rename = "version",
84 default,
85 with = "::serde_with::rust::double_option",
86 skip_serializing_if = "Option::is_none"
87 )]
88 pub version: Option<Option<String>>,
89 #[serde(
91 rename = "metadata",
92 default,
93 with = "::serde_with::rust::double_option",
94 skip_serializing_if = "Option::is_none"
95 )]
96 pub metadata: Option<Option<serde_json::Value>>,
97 #[serde(
99 rename = "output",
100 default,
101 with = "::serde_with::rust::double_option",
102 skip_serializing_if = "Option::is_none"
103 )]
104 pub output: Option<Option<serde_json::Value>>,
105 #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
106 pub usage: Option<Box<models::Usage>>,
107 #[serde(rename = "level")]
108 pub level: models::ObservationLevel,
109 #[serde(
111 rename = "statusMessage",
112 default,
113 with = "::serde_with::rust::double_option",
114 skip_serializing_if = "Option::is_none"
115 )]
116 pub status_message: Option<Option<String>>,
117 #[serde(
119 rename = "parentObservationId",
120 default,
121 with = "::serde_with::rust::double_option",
122 skip_serializing_if = "Option::is_none"
123 )]
124 pub parent_observation_id: Option<Option<String>>,
125 #[serde(
127 rename = "promptId",
128 default,
129 with = "::serde_with::rust::double_option",
130 skip_serializing_if = "Option::is_none"
131 )]
132 pub prompt_id: Option<Option<String>>,
133 #[serde(
135 rename = "usageDetails",
136 default,
137 with = "::serde_with::rust::double_option",
138 skip_serializing_if = "Option::is_none"
139 )]
140 pub usage_details: Option<Option<std::collections::HashMap<String, i32>>>,
141 #[serde(
143 rename = "costDetails",
144 default,
145 with = "::serde_with::rust::double_option",
146 skip_serializing_if = "Option::is_none"
147 )]
148 pub cost_details: Option<Option<std::collections::HashMap<String, f64>>>,
149 #[serde(
151 rename = "environment",
152 default,
153 with = "::serde_with::rust::double_option",
154 skip_serializing_if = "Option::is_none"
155 )]
156 pub environment: Option<Option<String>>,
157 #[serde(
159 rename = "promptName",
160 default,
161 with = "::serde_with::rust::double_option",
162 skip_serializing_if = "Option::is_none"
163 )]
164 pub prompt_name: Option<Option<String>>,
165 #[serde(
167 rename = "promptVersion",
168 default,
169 with = "::serde_with::rust::double_option",
170 skip_serializing_if = "Option::is_none"
171 )]
172 pub prompt_version: Option<Option<i32>>,
173 #[serde(
175 rename = "modelId",
176 default,
177 with = "::serde_with::rust::double_option",
178 skip_serializing_if = "Option::is_none"
179 )]
180 pub model_id: Option<Option<String>>,
181 #[serde(
183 rename = "inputPrice",
184 default,
185 with = "::serde_with::rust::double_option",
186 skip_serializing_if = "Option::is_none"
187 )]
188 pub input_price: Option<Option<f64>>,
189 #[serde(
191 rename = "outputPrice",
192 default,
193 with = "::serde_with::rust::double_option",
194 skip_serializing_if = "Option::is_none"
195 )]
196 pub output_price: Option<Option<f64>>,
197 #[serde(
199 rename = "totalPrice",
200 default,
201 with = "::serde_with::rust::double_option",
202 skip_serializing_if = "Option::is_none"
203 )]
204 pub total_price: Option<Option<f64>>,
205 #[serde(
207 rename = "calculatedInputCost",
208 default,
209 with = "::serde_with::rust::double_option",
210 skip_serializing_if = "Option::is_none"
211 )]
212 pub calculated_input_cost: Option<Option<f64>>,
213 #[serde(
215 rename = "calculatedOutputCost",
216 default,
217 with = "::serde_with::rust::double_option",
218 skip_serializing_if = "Option::is_none"
219 )]
220 pub calculated_output_cost: Option<Option<f64>>,
221 #[serde(
223 rename = "calculatedTotalCost",
224 default,
225 with = "::serde_with::rust::double_option",
226 skip_serializing_if = "Option::is_none"
227 )]
228 pub calculated_total_cost: Option<Option<f64>>,
229 #[serde(
231 rename = "latency",
232 default,
233 with = "::serde_with::rust::double_option",
234 skip_serializing_if = "Option::is_none"
235 )]
236 pub latency: Option<Option<f64>>,
237 #[serde(
239 rename = "timeToFirstToken",
240 default,
241 with = "::serde_with::rust::double_option",
242 skip_serializing_if = "Option::is_none"
243 )]
244 pub time_to_first_token: Option<Option<f64>>,
245}
246
247impl ObservationsView {
248 pub fn new(
249 id: String,
250 r#type: String,
251 start_time: String,
252 level: models::ObservationLevel,
253 ) -> ObservationsView {
254 ObservationsView {
255 id,
256 trace_id: None,
257 r#type,
258 name: None,
259 start_time,
260 end_time: None,
261 completion_start_time: None,
262 model: None,
263 model_parameters: None,
264 input: None,
265 version: None,
266 metadata: None,
267 output: None,
268 usage: None,
269 level,
270 status_message: None,
271 parent_observation_id: None,
272 prompt_id: None,
273 usage_details: None,
274 cost_details: None,
275 environment: None,
276 prompt_name: None,
277 prompt_version: None,
278 model_id: None,
279 input_price: None,
280 output_price: None,
281 total_price: None,
282 calculated_input_cost: None,
283 calculated_output_cost: None,
284 calculated_total_cost: None,
285 latency: None,
286 time_to_first_token: None,
287 }
288 }
289}