langfuse-client-base 0.12.0

Auto-generated Langfuse API client from OpenAPI specification
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
 *
 * 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 TraceWithDetails {
    /// The unique identifier of a trace
    #[serde(rename = "id")]
    pub id: String,
    /// The timestamp when the trace was created
    #[serde(rename = "timestamp")]
    pub timestamp: String,
    /// The name of the trace
    #[serde(
        rename = "name",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub name: Option<Option<String>>,
    /// The input data of the trace. Can be any JSON.
    #[serde(
        rename = "input",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input: Option<Option<serde_json::Value>>,
    /// The output data of the trace. Can be any JSON.
    #[serde(
        rename = "output",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output: Option<Option<serde_json::Value>>,
    /// The session identifier associated with the trace
    #[serde(
        rename = "sessionId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub session_id: Option<Option<String>>,
    /// The release version of the application when the trace was created
    #[serde(
        rename = "release",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub release: Option<Option<String>>,
    /// The version of the trace
    #[serde(
        rename = "version",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub version: Option<Option<String>>,
    /// The user identifier associated with the trace
    #[serde(
        rename = "userId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub user_id: Option<Option<String>>,
    /// The metadata associated with the trace. Can be any JSON.
    #[serde(
        rename = "metadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub metadata: Option<Option<serde_json::Value>>,
    /// The tags associated with the trace.
    #[serde(rename = "tags")]
    pub tags: Vec<String>,
    /// Public traces are accessible via url without login
    #[serde(rename = "public")]
    pub public: bool,
    /// The environment from which this trace originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
    #[serde(rename = "environment")]
    pub environment: String,
    /// Path of trace in Langfuse UI
    #[serde(rename = "htmlPath")]
    pub html_path: String,
    /// Latency of trace in seconds
    #[serde(
        rename = "latency",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub latency: Option<Option<f64>>,
    /// Cost of trace in USD
    #[serde(
        rename = "totalCost",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub total_cost: Option<Option<f64>>,
    /// List of observation ids
    #[serde(
        rename = "observations",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub observations: Option<Option<Vec<String>>>,
    /// List of score ids
    #[serde(
        rename = "scores",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub scores: Option<Option<Vec<String>>>,
}

impl TraceWithDetails {
    pub fn new(
        id: String,
        timestamp: String,
        tags: Vec<String>,
        public: bool,
        environment: String,
        html_path: String,
    ) -> TraceWithDetails {
        TraceWithDetails {
            id,
            timestamp,
            name: None,
            input: None,
            output: None,
            session_id: None,
            release: None,
            version: None,
            user_id: None,
            metadata: None,
            tags,
            public,
            environment,
            html_path,
            latency: None,
            total_cost: None,
            observations: None,
            scores: None,
        }
    }
}