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