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)]
15pub struct NumericScore {
16    /// The numeric value of the score
17    #[serde(rename = "value")]
18    pub value: f64,
19    #[serde(rename = "id")]
20    pub id: String,
21    #[serde(
22        rename = "traceId",
23        default,
24        with = "::serde_with::rust::double_option",
25        skip_serializing_if = "Option::is_none"
26    )]
27    pub trace_id: Option<Option<String>>,
28    #[serde(
29        rename = "sessionId",
30        default,
31        with = "::serde_with::rust::double_option",
32        skip_serializing_if = "Option::is_none"
33    )]
34    pub session_id: Option<Option<String>>,
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    #[serde(
43        rename = "datasetRunId",
44        default,
45        with = "::serde_with::rust::double_option",
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub dataset_run_id: Option<Option<String>>,
49    #[serde(rename = "name")]
50    pub name: String,
51    #[serde(rename = "source")]
52    pub source: models::ScoreSource,
53    #[serde(rename = "timestamp")]
54    pub timestamp: String,
55    #[serde(rename = "createdAt")]
56    pub created_at: String,
57    #[serde(rename = "updatedAt")]
58    pub updated_at: String,
59    #[serde(
60        rename = "authorUserId",
61        default,
62        with = "::serde_with::rust::double_option",
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub author_user_id: Option<Option<String>>,
66    #[serde(
67        rename = "comment",
68        default,
69        with = "::serde_with::rust::double_option",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub comment: Option<Option<String>>,
73    #[serde(
74        rename = "metadata",
75        default,
76        with = "::serde_with::rust::double_option",
77        skip_serializing_if = "Option::is_none"
78    )]
79    pub metadata: Option<Option<serde_json::Value>>,
80    /// 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
81    #[serde(
82        rename = "configId",
83        default,
84        with = "::serde_with::rust::double_option",
85        skip_serializing_if = "Option::is_none"
86    )]
87    pub config_id: Option<Option<String>>,
88    /// Reference an annotation queue on a score. Populated if the score was initially created in an annotation queue.
89    #[serde(
90        rename = "queueId",
91        default,
92        with = "::serde_with::rust::double_option",
93        skip_serializing_if = "Option::is_none"
94    )]
95    pub queue_id: Option<Option<String>>,
96    /// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
97    #[serde(
98        rename = "environment",
99        default,
100        with = "::serde_with::rust::double_option",
101        skip_serializing_if = "Option::is_none"
102    )]
103    pub environment: Option<Option<String>>,
104}
105
106impl NumericScore {
107    pub fn new(
108        value: f64,
109        id: String,
110        name: String,
111        source: models::ScoreSource,
112        timestamp: String,
113        created_at: String,
114        updated_at: String,
115    ) -> NumericScore {
116        NumericScore {
117            value,
118            id,
119            trace_id: None,
120            session_id: None,
121            observation_id: None,
122            dataset_run_id: None,
123            name,
124            source,
125            timestamp,
126            created_at,
127            updated_at,
128            author_user_id: None,
129            comment: None,
130            metadata: None,
131            config_id: None,
132            queue_id: None,
133            environment: None,
134        }
135    }
136}