langfuse_client_base/models/
observations_view.rs

1/*
2 * langfuse
3 *
4 * ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings:  - username: Langfuse Public Key - password: Langfuse Secret Key  ## Exports  - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ObservationsView {
16    /// The name of the prompt associated with the observation
17    #[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    /// The version of the prompt associated with the observation
25    #[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    /// The unique identifier of the model
33    #[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    /// The price of the input in USD
41    #[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    /// The price of the output in USD.
49    #[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    /// The total price in USD.
57    #[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    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD
65    #[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    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD
73    #[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    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD
81    #[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    /// The latency in seconds.
89    #[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    /// The time to the first token in seconds
97    #[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    /// The unique identifier of the observation
105    #[serde(rename = "id")]
106    pub id: String,
107    /// The trace ID associated with the observation
108    #[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    /// The type of the observation
116    #[serde(rename = "type")]
117    pub r#type: String,
118    /// The name of the observation
119    #[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    /// The start time of the observation
127    #[serde(rename = "startTime")]
128    pub start_time: String,
129    /// The end time of the observation.
130    #[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    /// The completion start time of the observation
138    #[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    /// The model used for the observation
146    #[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    /// The parameters of the model used for the observation
154    #[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    /// The input data of the observation
162    #[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    /// The version of the observation
170    #[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    /// Additional metadata of the observation
178    #[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    /// The output data of the observation
186    #[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    /// The status message of the observation
198    #[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    /// The parent observation ID
206    #[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    /// The prompt ID associated with the observation
214    #[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    /// The usage details of the observation. Key is the name of the usage metric, value is the number of units consumed. The total key is the sum of all (non-total) usage metrics or the total value ingested.
222    #[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    /// The cost details of the observation. Key is the name of the cost metric, value is the cost in USD. The total key is the sum of all (non-total) cost metrics or the total value ingested.
230    #[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    /// The environment from which this observation originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
238    #[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}