langfuse-client-base 0.15.0

Auto-generated Langfuse API client from OpenAPI specification
Documentation
/*
 * server
 *
 * ## Real-time data  The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion).  ## 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
 *
 * 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 ExperimentItem {
    #[serde(rename = "id")]
    pub id: String,
    #[serde(rename = "traceId")]
    pub trace_id: String,
    #[serde(rename = "startTime")]
    pub start_time: chrono::DateTime<chrono::FixedOffset>,
    #[serde(rename = "endTime", deserialize_with = "Option::deserialize")]
    pub end_time: Option<chrono::DateTime<chrono::FixedOffset>>,
    #[serde(rename = "level")]
    pub level: models::ObservationLevel,
    #[serde(rename = "environment")]
    pub environment: String,
    #[serde(rename = "experimentId")]
    pub experiment_id: String,
    #[serde(rename = "experimentName")]
    pub experiment_name: String,
    #[serde(rename = "experimentItemId")]
    pub experiment_item_id: String,
    /// Included when `fields=dataset` is requested.
    #[serde(
        rename = "experimentDatasetId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub experiment_dataset_id: Option<Option<String>>,
    /// Included when `fields=dataset` is requested.
    #[serde(
        rename = "experimentItemVersion",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub experiment_item_version: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
    /// Included when `fields=io` is requested.
    #[serde(
        rename = "input",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub input: Option<Option<serde_json::Value>>,
    /// Included when `fields=io` is requested.
    #[serde(
        rename = "output",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub output: Option<Option<serde_json::Value>>,
    /// Included when `fields=io` is requested.
    #[serde(
        rename = "expectedOutput",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub expected_output: Option<Option<serde_json::Value>>,
    /// Included when `fields=metadata` is requested.
    #[serde(
        rename = "metadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// Included when `fields=itemMetadata` is requested.
    #[serde(
        rename = "experimentItemMetadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub experiment_item_metadata:
        Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// Included when `fields=experimentMetadata` is requested.
    #[serde(
        rename = "experimentMetadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub experiment_metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// Included when `fields=experimentMetadata` is requested.
    #[serde(
        rename = "experimentDescription",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub experiment_description: Option<Option<String>>,
    /// Included only when `fields=scores` is requested. Contains item and trace scores only; experiment-level scores are returned by the experiments endpoint.
    #[serde(
        rename = "scores",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub scores: Option<Option<Vec<models::ScoreV3>>>,
}

impl ExperimentItem {
    pub fn new(
        id: String,
        trace_id: String,
        start_time: chrono::DateTime<chrono::FixedOffset>,
        end_time: Option<chrono::DateTime<chrono::FixedOffset>>,
        level: models::ObservationLevel,
        environment: String,
        experiment_id: String,
        experiment_name: String,
        experiment_item_id: String,
    ) -> ExperimentItem {
        ExperimentItem {
            id,
            trace_id,
            start_time,
            end_time,
            level,
            environment,
            experiment_id,
            experiment_name,
            experiment_item_id,
            experiment_dataset_id: None,
            experiment_item_version: None,
            input: None,
            output: None,
            expected_output: None,
            metadata: None,
            experiment_item_metadata: None,
            experiment_metadata: None,
            experiment_description: None,
            scores: None,
        }
    }
}