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