langfuse-client-base 0.14.0

Auto-generated Langfuse API client from OpenAPI specification
Documentation
/*
 * server
 *
 * ## 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
 *
 * The version of the OpenAPI document:
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ObservationsViewSingle {
    /// The unique identifier of the observation
    #[serde(rename = "id")]
    pub id: String,
    /// The trace ID associated with the observation
    #[serde(rename = "traceId", deserialize_with = "Option::deserialize")]
    pub trace_id: Option<String>,
    /// The type of the observation
    #[serde(rename = "type")]
    pub r#type: String,
    /// The name of the observation
    #[serde(rename = "name", deserialize_with = "Option::deserialize")]
    pub name: Option<String>,
    /// The start time of the observation
    #[serde(rename = "startTime")]
    pub start_time: chrono::DateTime<chrono::FixedOffset>,
    /// The end time of the observation.
    #[serde(rename = "endTime", deserialize_with = "Option::deserialize")]
    pub end_time: Option<chrono::DateTime<chrono::FixedOffset>>,
    /// The completion start time of the observation
    #[serde(
        rename = "completionStartTime",
        deserialize_with = "Option::deserialize"
    )]
    pub completion_start_time: Option<chrono::DateTime<chrono::FixedOffset>>,
    /// The model used for the observation
    #[serde(rename = "model", deserialize_with = "Option::deserialize")]
    pub model: Option<String>,
    /// The parameters of the model used for the observation
    #[serde(rename = "modelParameters", deserialize_with = "Option::deserialize")]
    pub model_parameters: Option<serde_json::Value>,
    /// The input data of the observation
    #[serde(rename = "input", deserialize_with = "Option::deserialize")]
    pub input: Option<serde_json::Value>,
    /// The version of the observation
    #[serde(rename = "version", deserialize_with = "Option::deserialize")]
    pub version: Option<String>,
    /// Additional metadata of the observation
    #[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
    pub metadata: Option<serde_json::Value>,
    /// The output data of the observation
    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
    pub output: Option<serde_json::Value>,
    #[serde(rename = "usage")]
    pub usage: Box<models::Usage>,
    #[serde(rename = "level")]
    pub level: models::ObservationLevel,
    /// The status message of the observation
    #[serde(rename = "statusMessage", deserialize_with = "Option::deserialize")]
    pub status_message: Option<String>,
    /// The parent observation ID
    #[serde(
        rename = "parentObservationId",
        deserialize_with = "Option::deserialize"
    )]
    pub parent_observation_id: Option<String>,
    /// The prompt ID associated with the observation
    #[serde(rename = "promptId", deserialize_with = "Option::deserialize")]
    pub prompt_id: 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")]
    pub usage_details: std::collections::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")]
    pub cost_details: std::collections::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")]
    pub environment: String,
    /// The name of the prompt associated with the observation
    #[serde(rename = "promptName", deserialize_with = "Option::deserialize")]
    pub prompt_name: Option<String>,
    /// The version of the prompt associated with the observation
    #[serde(rename = "promptVersion", deserialize_with = "Option::deserialize")]
    pub prompt_version: Option<i32>,
    /// The unique identifier of the model
    #[serde(rename = "modelId", deserialize_with = "Option::deserialize")]
    pub model_id: Option<String>,
    /// The price of the input in USD
    #[serde(rename = "inputPrice", deserialize_with = "Option::deserialize")]
    pub input_price: Option<f64>,
    /// The price of the output in USD.
    #[serde(rename = "outputPrice", deserialize_with = "Option::deserialize")]
    pub output_price: Option<f64>,
    /// The total price in USD.
    #[serde(rename = "totalPrice", deserialize_with = "Option::deserialize")]
    pub total_price: Option<f64>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the input in USD
    #[serde(
        rename = "calculatedInputCost",
        deserialize_with = "Option::deserialize"
    )]
    pub calculated_input_cost: Option<f64>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated cost of the output in USD
    #[serde(
        rename = "calculatedOutputCost",
        deserialize_with = "Option::deserialize"
    )]
    pub calculated_output_cost: Option<f64>,
    /// (Deprecated. Use usageDetails and costDetails instead.) The calculated total cost in USD
    #[serde(
        rename = "calculatedTotalCost",
        deserialize_with = "Option::deserialize"
    )]
    pub calculated_total_cost: Option<f64>,
    /// The latency in seconds.
    #[serde(rename = "latency", deserialize_with = "Option::deserialize")]
    pub latency: Option<f64>,
    /// The time to the first token in seconds
    #[serde(rename = "timeToFirstToken", deserialize_with = "Option::deserialize")]
    pub time_to_first_token: Option<f64>,
    #[serde(rename = "_deprecation", skip_serializing_if = "Option::is_none")]
    pub _deprecation: Option<Box<models::Deprecation>>,
}

impl ObservationsViewSingle {
    pub fn new(
        id: String,
        trace_id: Option<String>,
        r#type: String,
        name: Option<String>,
        start_time: chrono::DateTime<chrono::FixedOffset>,
        end_time: Option<chrono::DateTime<chrono::FixedOffset>>,
        completion_start_time: Option<chrono::DateTime<chrono::FixedOffset>>,
        model: Option<String>,
        model_parameters: Option<serde_json::Value>,
        input: Option<serde_json::Value>,
        version: Option<String>,
        metadata: Option<serde_json::Value>,
        output: Option<serde_json::Value>,
        usage: models::Usage,
        level: models::ObservationLevel,
        status_message: Option<String>,
        parent_observation_id: Option<String>,
        prompt_id: Option<String>,
        usage_details: std::collections::HashMap<String, i32>,
        cost_details: std::collections::HashMap<String, f64>,
        environment: String,
        prompt_name: Option<String>,
        prompt_version: Option<i32>,
        model_id: Option<String>,
        input_price: Option<f64>,
        output_price: Option<f64>,
        total_price: Option<f64>,
        calculated_input_cost: Option<f64>,
        calculated_output_cost: Option<f64>,
        calculated_total_cost: Option<f64>,
        latency: Option<f64>,
        time_to_first_token: Option<f64>,
    ) -> ObservationsViewSingle {
        ObservationsViewSingle {
            id,
            trace_id,
            r#type,
            name,
            start_time,
            end_time,
            completion_start_time,
            model,
            model_parameters,
            input,
            version,
            metadata,
            output,
            usage: Box::new(usage),
            level,
            status_message,
            parent_observation_id,
            prompt_id,
            usage_details,
            cost_details,
            environment,
            prompt_name,
            prompt_version,
            model_id,
            input_price,
            output_price,
            total_price,
            calculated_input_cost,
            calculated_output_cost,
            calculated_total_cost,
            latency,
            time_to_first_token,
            _deprecation: None,
        }
    }
}