Skip to main content

langfuse_client_base/models/
numeric_score_v3.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 NumericScoreV3 {
16    #[serde(rename = "id")]
17    pub id: String,
18    #[serde(rename = "projectId")]
19    pub project_id: String,
20    #[serde(rename = "name")]
21    pub name: String,
22    #[serde(rename = "source")]
23    pub source: models::ScoreSource,
24    #[serde(rename = "timestamp")]
25    pub timestamp: chrono::DateTime<chrono::FixedOffset>,
26    /// The environment from which this score originated.
27    #[serde(rename = "environment")]
28    pub environment: String,
29    #[serde(rename = "createdAt")]
30    pub created_at: chrono::DateTime<chrono::FixedOffset>,
31    #[serde(rename = "updatedAt")]
32    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
33    /// Optional comment attached to the score. Present when \"details\" is included in the fields parameter.
34    #[serde(
35        rename = "comment",
36        default,
37        with = "::serde_with::rust::double_option",
38        skip_serializing_if = "Option::is_none"
39    )]
40    pub comment: Option<Option<String>>,
41    /// The score config ID, if this score was created from a config. Present when \"details\" is included in the fields parameter.
42    #[serde(
43        rename = "configId",
44        default,
45        with = "::serde_with::rust::double_option",
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub config_id: Option<Option<String>>,
49    /// Arbitrary metadata attached to the score. Present when \"details\" is included in the fields parameter.
50    #[serde(
51        rename = "metadata",
52        default,
53        with = "::serde_with::rust::double_option",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
57    /// The user who created this score, if available. Present when \"annotation\" is included in the fields parameter.
58    #[serde(
59        rename = "authorUserId",
60        default,
61        with = "::serde_with::rust::double_option",
62        skip_serializing_if = "Option::is_none"
63    )]
64    pub author_user_id: Option<Option<String>>,
65    /// The annotation queue this score belongs to, if any. Present when \"annotation\" is included in the fields parameter.
66    #[serde(
67        rename = "queueId",
68        default,
69        with = "::serde_with::rust::double_option",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub queue_id: Option<Option<String>>,
73    #[serde(rename = "subject", skip_serializing_if = "Option::is_none")]
74    pub subject: Option<Box<models::ScoreSubjectV3>>,
75    /// The numeric value of the score.
76    #[serde(rename = "value")]
77    pub value: f64,
78}
79
80impl NumericScoreV3 {
81    pub fn new(
82        id: String,
83        project_id: String,
84        name: String,
85        source: models::ScoreSource,
86        timestamp: chrono::DateTime<chrono::FixedOffset>,
87        environment: String,
88        created_at: chrono::DateTime<chrono::FixedOffset>,
89        updated_at: chrono::DateTime<chrono::FixedOffset>,
90        value: f64,
91    ) -> NumericScoreV3 {
92        NumericScoreV3 {
93            id,
94            project_id,
95            name,
96            source,
97            timestamp,
98            environment,
99            created_at,
100            updated_at,
101            comment: None,
102            config_id: None,
103            metadata: None,
104            author_user_id: None,
105            queue_id: None,
106            subject: None,
107            value,
108        }
109    }
110}