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