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(rename = "metadata")]
68    pub metadata: std::collections::HashMap<String, serde_json::Value>,
69    /// 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
70    #[serde(rename = "configId", deserialize_with = "Option::deserialize")]
71    pub config_id: Option<String>,
72    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
73    #[serde(rename = "queueId", deserialize_with = "Option::deserialize")]
74    pub queue_id: Option<String>,
75    /// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
76    #[serde(rename = "environment")]
77    pub environment: String,
78    /// The numeric value of the score
79    #[serde(rename = "value")]
80    pub value: f64,
81    #[serde(rename = "dataType")]
82    pub data_type: DataType,
83}
84
85impl NumericScore1 {
86    pub fn new(
87        id: String,
88        name: String,
89        source: models::ScoreSource,
90        timestamp: chrono::DateTime<chrono::FixedOffset>,
91        created_at: chrono::DateTime<chrono::FixedOffset>,
92        updated_at: chrono::DateTime<chrono::FixedOffset>,
93        author_user_id: Option<String>,
94        comment: Option<String>,
95        metadata: std::collections::HashMap<String, serde_json::Value>,
96        config_id: Option<String>,
97        queue_id: Option<String>,
98        environment: String,
99        value: f64,
100        data_type: DataType,
101    ) -> NumericScore1 {
102        NumericScore1 {
103            id,
104            trace_id: None,
105            session_id: None,
106            observation_id: None,
107            dataset_run_id: None,
108            name,
109            source,
110            timestamp,
111            created_at,
112            updated_at,
113            author_user_id,
114            comment,
115            metadata,
116            config_id,
117            queue_id,
118            environment,
119            value,
120            data_type,
121        }
122    }
123}
124///
125#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
126pub enum DataType {
127    #[serde(rename = "NUMERIC")]
128    Numeric,
129}
130
131impl Default for DataType {
132    fn default() -> DataType {
133        Self::Numeric
134    }
135}