/*
* 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 DatasetItem {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "status")]
pub status: models::DatasetStatus,
/// Input data for the dataset item
#[serde(rename = "input", deserialize_with = "Option::deserialize")]
pub input: Option<serde_json::Value>,
/// Expected output for the dataset item
#[serde(rename = "expectedOutput", deserialize_with = "Option::deserialize")]
pub expected_output: Option<serde_json::Value>,
/// Metadata associated with the dataset item
#[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
pub metadata: Option<serde_json::Value>,
/// The trace ID that sourced this dataset item
#[serde(rename = "sourceTraceId", deserialize_with = "Option::deserialize")]
pub source_trace_id: Option<String>,
/// The observation ID that sourced this dataset item
#[serde(
rename = "sourceObservationId",
deserialize_with = "Option::deserialize"
)]
pub source_observation_id: Option<String>,
#[serde(rename = "datasetId")]
pub dataset_id: String,
#[serde(rename = "datasetName")]
pub dataset_name: String,
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::FixedOffset>,
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::FixedOffset>,
/// When this version of the dataset item became current. Listing dataset items with a `version` at or after this timestamp returns this item version, until the item is changed again. Self-hosted deployments that set `LANGFUSE_DATASET_SERVICE_WRITE_TO_VERSIONED_IMPLEMENTATION=false` update items in place, so there it stays at the item's first write.
#[serde(
rename = "version",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub version: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
/// Resolved Langfuse media references found in input, expectedOutput, and metadata.
#[serde(rename = "mediaReferences")]
pub media_references: Vec<models::DatasetItemMediaReference>,
}
impl DatasetItem {
pub fn new(
id: String,
status: models::DatasetStatus,
input: Option<serde_json::Value>,
expected_output: Option<serde_json::Value>,
metadata: Option<serde_json::Value>,
source_trace_id: Option<String>,
source_observation_id: Option<String>,
dataset_id: String,
dataset_name: String,
created_at: chrono::DateTime<chrono::FixedOffset>,
updated_at: chrono::DateTime<chrono::FixedOffset>,
media_references: Vec<models::DatasetItemMediaReference>,
) -> DatasetItem {
DatasetItem {
id,
status,
input,
expected_output,
metadata,
source_trace_id,
source_observation_id,
dataset_id,
dataset_name,
created_at,
updated_at,
version: None,
media_references,
}
}
}