Skip to main content

langfuse_client_base/models/
numeric_score_1.rs

1/*
2 * server
3 *
4 * ## 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`
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct NumericScore1 {
16    #[serde(rename = "id")]
17    pub id: String,
18    /// The trace ID associated with the score
19    #[serde(
20        rename = "traceId",
21        default,
22        with = "::serde_with::rust::double_option",
23        skip_serializing_if = "Option::is_none"
24    )]
25    pub trace_id: Option<Option<String>>,
26    /// The session ID associated with the score
27    #[serde(
28        rename = "sessionId",
29        default,
30        with = "::serde_with::rust::double_option",
31        skip_serializing_if = "Option::is_none"
32    )]
33    pub session_id: Option<Option<String>>,
34    /// The observation ID associated with the score
35    #[serde(
36        rename = "observationId",
37        default,
38        with = "::serde_with::rust::double_option",
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub observation_id: Option<Option<String>>,
42    /// The dataset run ID associated with the score
43    #[serde(
44        rename = "datasetRunId",
45        default,
46        with = "::serde_with::rust::double_option",
47        skip_serializing_if = "Option::is_none"
48    )]
49    pub dataset_run_id: Option<Option<String>>,
50    #[serde(rename = "name")]
51    pub name: String,
52    #[serde(rename = "source")]
53    pub source: models::ScoreSource,
54    #[serde(rename = "timestamp")]
55    pub timestamp: chrono::DateTime<chrono::FixedOffset>,
56    #[serde(rename = "createdAt")]
57    pub created_at: chrono::DateTime<chrono::FixedOffset>,
58    #[serde(rename = "updatedAt")]
59    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
60    /// The user ID of the author
61    #[serde(rename = "authorUserId", deserialize_with = "Option::deserialize")]
62    pub author_user_id: Option<String>,
63    /// Comment on the score
64    #[serde(rename = "comment", deserialize_with = "Option::deserialize")]
65    pub comment: Option<String>,
66    /// Metadata associated with the score
67    #[serde(
68        rename = "metadata",
69        default,
70        with = "::serde_with::rust::double_option",
71        skip_serializing_if = "Option::is_none"
72    )]
73    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
74    /// 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
75    #[serde(rename = "configId", deserialize_with = "Option::deserialize")]
76    pub config_id: Option<String>,
77    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
78    #[serde(rename = "queueId", deserialize_with = "Option::deserialize")]
79    pub queue_id: Option<String>,
80    /// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
81    #[serde(rename = "environment")]
82    pub environment: String,
83    /// The numeric value of the score
84    #[serde(rename = "value")]
85    pub value: f64,
86    #[serde(rename = "dataType")]
87    pub data_type: DataType,
88}
89
90impl NumericScore1 {
91    pub fn new(
92        id: String,
93        name: String,
94        source: models::ScoreSource,
95        timestamp: chrono::DateTime<chrono::FixedOffset>,
96        created_at: chrono::DateTime<chrono::FixedOffset>,
97        updated_at: chrono::DateTime<chrono::FixedOffset>,
98        author_user_id: Option<String>,
99        comment: Option<String>,
100        config_id: Option<String>,
101        queue_id: Option<String>,
102        environment: String,
103        value: f64,
104        data_type: DataType,
105    ) -> NumericScore1 {
106        NumericScore1 {
107            id,
108            trace_id: None,
109            session_id: None,
110            observation_id: None,
111            dataset_run_id: None,
112            name,
113            source,
114            timestamp,
115            created_at,
116            updated_at,
117            author_user_id,
118            comment,
119            metadata: None,
120            config_id,
121            queue_id,
122            environment,
123            value,
124            data_type,
125        }
126    }
127}
128///
129#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
130pub enum DataType {
131    #[serde(rename = "NUMERIC")]
132    Numeric,
133}
134
135impl Default for DataType {
136    fn default() -> DataType {
137        Self::Numeric
138    }
139}