langfuse-client 0.1.22

## 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
Documentation
/*
 * langfuse
 *
 * ## 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
 *
 * The version of the OpenAPI document: 
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};
#[cfg(not(feature = "ahash"))]
use std::collections::HashMap;
#[cfg(feature = "ahash")]
use ahash::HashMap;

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature="bon", derive(bon::Builder))]
pub struct ObservationsView {
    /// The name of the prompt associated with the observation
    #[serde(rename = "promptName", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub prompt_name: Option<Option<String>>,
    /// The version of the prompt associated with the observation
    #[serde(rename = "promptVersion", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub prompt_version: Option<Option<i32>>,
    /// The unique identifier of the model
    #[serde(rename = "modelId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub model_id: Option<Option<String>>,
    /// The price of the input in USD
    #[serde(rename = "inputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub input_price: Option<Option<f64>>,
    /// The price of the output in USD.
    #[serde(rename = "outputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub output_price: Option<Option<f64>>,
    /// The total price in USD.
    #[serde(rename = "totalPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub total_price: Option<Option<f64>>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD
    #[serde(rename = "calculatedInputCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub calculated_input_cost: Option<Option<f64>>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD
    #[serde(rename = "calculatedOutputCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub calculated_output_cost: Option<Option<f64>>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD
    #[serde(rename = "calculatedTotalCost", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub calculated_total_cost: Option<Option<f64>>,
    /// The latency in seconds.
    #[serde(rename = "latency", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub latency: Option<Option<f64>>,
    /// The time to the first token in seconds
    #[serde(rename = "timeToFirstToken", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub time_to_first_token: Option<Option<f64>>,
    /// The unique identifier of the observation
    #[serde(rename = "id")]
    pub id: String,
    /// The trace ID associated with the observation
    #[serde(rename = "traceId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub trace_id: Option<Option<String>>,
    /// The type of the observation
    #[serde(rename = "type")]
    pub r#type: String,
    /// The name of the observation
    #[serde(rename = "name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub name: Option<Option<String>>,
    /// The start time of the observation
    #[serde(rename = "startTime")]
    pub start_time: String,
    /// The end time of the observation.
    #[serde(rename = "endTime", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub end_time: Option<Option<String>>,
    /// The completion start time of the observation
    #[serde(rename = "completionStartTime", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub completion_start_time: Option<Option<String>>,
    /// The model used for the observation
    #[serde(rename = "model", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub model: Option<Option<String>>,
    /// The parameters of the model used for the observation
    #[serde(rename = "modelParameters", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub model_parameters: Option<Option<HashMap<String, models::MapValue>>>,
    /// The input data of the observation
    #[serde(rename = "input", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub input: Option<Option<serde_json::Value>>,
    /// The version of the observation
    #[serde(rename = "version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub version: Option<Option<String>>,
    /// Additional metadata of the observation
    #[serde(rename = "metadata", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<Option<serde_json::Value>>,
    /// The output data of the observation
    #[serde(rename = "output", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub output: Option<Option<serde_json::Value>>,
    #[serde(rename = "usage", skip_serializing_if = "Option::is_none")]
    pub usage: Option<models::Usage>,
    #[serde(rename = "level")]
    pub level: models::ObservationLevel,
    /// The status message of the observation
    #[serde(rename = "statusMessage", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub status_message: Option<Option<String>>,
    /// The parent observation ID
    #[serde(rename = "parentObservationId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub parent_observation_id: Option<Option<String>>,
    /// The prompt ID associated with the observation
    #[serde(rename = "promptId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub prompt_id: Option<Option<String>>,
    /// 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.
    #[serde(rename = "usageDetails", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub usage_details: Option<Option<HashMap<String, i32>>>,
    /// 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.
    #[serde(rename = "costDetails", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub cost_details: Option<Option<HashMap<String, f64>>>,
    /// The environment from which this observation originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
    #[serde(rename = "environment", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub environment: Option<Option<String>>,
}

impl ObservationsView {
    pub fn new(id: String, r#type: String, start_time: String, level: models::ObservationLevel) -> ObservationsView {
        ObservationsView {
            prompt_name: None,
            prompt_version: None,
            model_id: None,
            input_price: None,
            output_price: None,
            total_price: None,
            calculated_input_cost: None,
            calculated_output_cost: None,
            calculated_total_cost: None,
            latency: None,
            time_to_first_token: None,
            id,
            trace_id: None,
            r#type,
            name: None,
            start_time,
            end_time: None,
            completion_start_time: None,
            model: None,
            model_parameters: None,
            input: None,
            version: None,
            metadata: None,
            output: None,
            usage: None,
            level,
            status_message: None,
            parent_observation_id: None,
            prompt_id: None,
            usage_details: None,
            cost_details: None,
            environment: None,
        }
    }
}