/*
* 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 NumericScoreV11 {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "traceId")]
pub trace_id: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "source")]
pub source: models::ScoreSource,
/// The observation ID associated with the score
#[serde(
rename = "observationId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub observation_id: Option<Option<String>>,
#[serde(rename = "timestamp")]
pub timestamp: chrono::DateTime<chrono::FixedOffset>,
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::FixedOffset>,
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::FixedOffset>,
/// The user ID of the author
#[serde(rename = "authorUserId", deserialize_with = "Option::deserialize")]
pub author_user_id: Option<String>,
/// Comment on the score
#[serde(rename = "comment", deserialize_with = "Option::deserialize")]
pub comment: Option<String>,
/// Metadata associated with the score
#[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>>>,
/// Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range
#[serde(rename = "configId", deserialize_with = "Option::deserialize")]
pub config_id: Option<String>,
/// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
#[serde(rename = "queueId", deserialize_with = "Option::deserialize")]
pub queue_id: Option<String>,
/// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
#[serde(rename = "environment")]
pub environment: String,
/// The numeric value of the score
#[serde(rename = "value")]
pub value: f64,
#[serde(rename = "dataType")]
pub data_type: DataType,
}
impl NumericScoreV11 {
pub fn new(
id: String,
trace_id: String,
name: String,
source: models::ScoreSource,
timestamp: chrono::DateTime<chrono::FixedOffset>,
created_at: chrono::DateTime<chrono::FixedOffset>,
updated_at: chrono::DateTime<chrono::FixedOffset>,
author_user_id: Option<String>,
comment: Option<String>,
config_id: Option<String>,
queue_id: Option<String>,
environment: String,
value: f64,
data_type: DataType,
) -> NumericScoreV11 {
NumericScoreV11 {
id,
trace_id,
name,
source,
observation_id: None,
timestamp,
created_at,
updated_at,
author_user_id,
comment,
metadata: None,
config_id,
queue_id,
environment,
value,
data_type,
}
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DataType {
#[serde(rename = "NUMERIC")]
Numeric,
}
impl Default for DataType {
fn default() -> DataType {
Self::Numeric
}
}