Skip to main content

langfuse_client_base/models/
numeric_score.rs

1/*
2 * langfuse
3 *
4 * ## 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 - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
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 NumericScore {
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: String,
56    #[serde(rename = "createdAt")]
57    pub created_at: String,
58    #[serde(rename = "updatedAt")]
59    pub updated_at: String,
60    /// The user ID of the author
61    #[serde(
62        rename = "authorUserId",
63        default,
64        with = "::serde_with::rust::double_option",
65        skip_serializing_if = "Option::is_none"
66    )]
67    pub author_user_id: Option<Option<String>>,
68    /// Comment on the score
69    #[serde(
70        rename = "comment",
71        default,
72        with = "::serde_with::rust::double_option",
73        skip_serializing_if = "Option::is_none"
74    )]
75    pub comment: Option<Option<String>>,
76    /// Metadata associated with the score
77    #[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
78    pub metadata: Option<serde_json::Value>,
79    /// 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
80    #[serde(
81        rename = "configId",
82        default,
83        with = "::serde_with::rust::double_option",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub config_id: Option<Option<String>>,
87    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
88    #[serde(
89        rename = "queueId",
90        default,
91        with = "::serde_with::rust::double_option",
92        skip_serializing_if = "Option::is_none"
93    )]
94    pub queue_id: Option<Option<String>>,
95    /// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
96    #[serde(rename = "environment")]
97    pub environment: String,
98    /// The numeric value of the score
99    #[serde(rename = "value")]
100    pub value: f64,
101}
102
103impl NumericScore {
104    pub fn new(
105        id: String,
106        name: String,
107        source: models::ScoreSource,
108        timestamp: String,
109        created_at: String,
110        updated_at: String,
111        metadata: Option<serde_json::Value>,
112        environment: String,
113        value: f64,
114    ) -> NumericScore {
115        NumericScore {
116            id,
117            trace_id: None,
118            session_id: None,
119            observation_id: None,
120            dataset_run_id: None,
121            name,
122            source,
123            timestamp,
124            created_at,
125            updated_at,
126            author_user_id: None,
127            comment: None,
128            metadata,
129            config_id: None,
130            queue_id: None,
131            environment,
132            value,
133        }
134    }
135}