langfuse_client/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)]
15#[cfg_attr(feature="bon", derive(bon::Builder))]
16pub struct ObservationsView {
17    /// The name of the prompt associated with the observation
18    #[serde(rename = "promptName", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
19    pub prompt_name: Option<Option<String>>,
20    /// The version of the prompt associated with the observation
21    #[serde(rename = "promptVersion", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
22    pub prompt_version: Option<Option<i32>>,
23    /// The unique identifier of the model
24    #[serde(rename = "modelId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
25    pub model_id: Option<Option<String>>,
26    /// The price of the input in USD
27    #[serde(rename = "inputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
28    pub input_price: Option<Option<f64>>,
29    /// The price of the output in USD.
30    #[serde(rename = "outputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
31    pub output_price: Option<Option<f64>>,
32    /// The total price in USD.
33    #[serde(rename = "totalPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
34    pub total_price: Option<Option<f64>>,
35    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD
36    #[serde(rename = "calculatedInputCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
37    pub calculated_input_cost: Option<Option<f64>>,
38    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD
39    #[serde(rename = "calculatedOutputCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
40    pub calculated_output_cost: Option<Option<f64>>,
41    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD
42    #[serde(rename = "calculatedTotalCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43    pub calculated_total_cost: Option<Option<f64>>,
44    /// The latency in seconds.
45    #[serde(rename = "latency", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
46    pub latency: Option<Option<f64>>,
47    /// The time to the first token in seconds
48    #[serde(rename = "timeToFirstToken", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
49    pub time_to_first_token: Option<Option<f64>>,
50    /// The unique identifier of the observation
51    #[serde(rename = "id")]
52    pub id: String,
53    /// The trace ID associated with the observation
54    #[serde(rename = "traceId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
55    pub trace_id: Option<Option<String>>,
56    /// The type of the observation
57    #[serde(rename = "type")]
58    pub r#type: String,
59    /// The name of the observation
60    #[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
61    pub name: Option<Option<String>>,
62    /// The start time of the observation
63    #[serde(rename = "startTime")]
64    pub start_time: String,
65    /// The end time of the observation.
66    #[serde(rename = "endTime", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
67    pub end_time: Option<Option<String>>,
68    /// The completion start time of the observation
69    #[serde(rename = "completionStartTime", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
70    pub completion_start_time: Option<Option<String>>,
71    /// The model used for the observation
72    #[serde(rename = "model", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
73    pub model: Option<Option<String>>,
74    /// The parameters of the model used for the observation
75    #[serde(rename = "modelParameters", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
76    pub model_parameters: Option<Option<std::collections::HashMap<String, models::MapValue>>>,
77    /// The input data of the observation
78    #[serde(rename = "input", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
79    pub input: Option<Option<serde_json::Value>>,
80    /// The version of the observation
81    #[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
82    pub version: Option<Option<String>>,
83    /// Additional metadata of the observation
84    #[serde(rename = "metadata", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
85    pub metadata: Option<Option<serde_json::Value>>,
86    /// The output data of the observation
87    #[serde(rename = "output", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
88    pub output: Option<Option<serde_json::Value>>,
89    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
90    pub usage: Option<models::Usage>,
91    #[serde(rename = "level")]
92    pub level: models::ObservationLevel,
93    /// The status message of the observation
94    #[serde(rename = "statusMessage", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
95    pub status_message: Option<Option<String>>,
96    /// The parent observation ID
97    #[serde(rename = "parentObservationId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
98    pub parent_observation_id: Option<Option<String>>,
99    /// The prompt ID associated with the observation
100    #[serde(rename = "promptId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
101    pub prompt_id: Option<Option<String>>,
102    /// 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.
103    #[serde(rename = "usageDetails", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
104    pub usage_details: Option<Option<std::collections::HashMap<String, i32>>>,
105    /// 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.
106    #[serde(rename = "costDetails", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
107    pub cost_details: Option<Option<std::collections::HashMap<String, f64>>>,
108    /// The environment from which this observation originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
109    #[serde(rename = "environment", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
110    pub environment: Option<Option<String>>,
111}
112
113impl ObservationsView {
114    pub fn new(id: String, r#type: String, start_time: String, level: models::ObservationLevel) -> ObservationsView {
115        ObservationsView {
116            prompt_name: None,
117            prompt_version: None,
118            model_id: None,
119            input_price: None,
120            output_price: None,
121            total_price: None,
122            calculated_input_cost: None,
123            calculated_output_cost: None,
124            calculated_total_cost: None,
125            latency: None,
126            time_to_first_token: None,
127            id,
128            trace_id: None,
129            r#type,
130            name: None,
131            start_time,
132            end_time: None,
133            completion_start_time: None,
134            model: None,
135            model_parameters: None,
136            input: None,
137            version: None,
138            metadata: None,
139            output: None,
140            usage: None,
141            level,
142            status_message: None,
143            parent_observation_id: None,
144            prompt_id: None,
145            usage_details: None,
146            cost_details: None,
147            environment: None,
148        }
149    }
150}
151