Skip to main content

langfuse_client_base/models/
boolean_score.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 BooleanScore {
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. Equals 1 for \"True\" and 0 for \"False\"
79    #[serde(rename = "value")]
80    pub value: f64,
81    /// The string representation of the score value. Is inferred from the numeric value and equals \"True\" or \"False\"
82    #[serde(rename = "stringValue")]
83    pub string_value: String,
84}
85
86impl BooleanScore {
87    pub fn new(
88        id: String,
89        name: String,
90        source: models::ScoreSource,
91        timestamp: chrono::DateTime<chrono::FixedOffset>,
92        created_at: chrono::DateTime<chrono::FixedOffset>,
93        updated_at: chrono::DateTime<chrono::FixedOffset>,
94        author_user_id: Option<String>,
95        comment: Option<String>,
96        metadata: std::collections::HashMap<String, serde_json::Value>,
97        config_id: Option<String>,
98        queue_id: Option<String>,
99        environment: String,
100        value: f64,
101        string_value: String,
102    ) -> BooleanScore {
103        BooleanScore {
104            id,
105            trace_id: None,
106            session_id: None,
107            observation_id: None,
108            dataset_run_id: None,
109            name,
110            source,
111            timestamp,
112            created_at,
113            updated_at,
114            author_user_id,
115            comment,
116            metadata,
117            config_id,
118            queue_id,
119            environment,
120            value,
121            string_value,
122        }
123    }
124}