Skip to main content

langfuse_client_base/models/
numeric_score_v1.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 NumericScoreV1 {
16    #[serde(rename = "id")]
17    pub id: String,
18    #[serde(rename = "traceId")]
19    pub trace_id: String,
20    #[serde(rename = "name")]
21    pub name: String,
22    #[serde(rename = "source")]
23    pub source: models::ScoreSource,
24    /// The observation ID associated with the score
25    #[serde(
26        rename = "observationId",
27        default,
28        with = "::serde_with::rust::double_option",
29        skip_serializing_if = "Option::is_none"
30    )]
31    pub observation_id: Option<Option<String>>,
32    #[serde(rename = "timestamp")]
33    pub timestamp: String,
34    #[serde(rename = "createdAt")]
35    pub created_at: String,
36    #[serde(rename = "updatedAt")]
37    pub updated_at: String,
38    /// The user ID of the author
39    #[serde(
40        rename = "authorUserId",
41        default,
42        with = "::serde_with::rust::double_option",
43        skip_serializing_if = "Option::is_none"
44    )]
45    pub author_user_id: Option<Option<String>>,
46    /// Comment on the score
47    #[serde(
48        rename = "comment",
49        default,
50        with = "::serde_with::rust::double_option",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub comment: Option<Option<String>>,
54    /// Metadata associated with the score
55    #[serde(rename = "metadata", deserialize_with = "Option::deserialize")]
56    pub metadata: Option<serde_json::Value>,
57    /// 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
58    #[serde(
59        rename = "configId",
60        default,
61        with = "::serde_with::rust::double_option",
62        skip_serializing_if = "Option::is_none"
63    )]
64    pub config_id: Option<Option<String>>,
65    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
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    /// The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
74    #[serde(rename = "environment")]
75    pub environment: String,
76    /// The numeric value of the score
77    #[serde(rename = "value")]
78    pub value: f64,
79}
80
81impl NumericScoreV1 {
82    pub fn new(
83        id: String,
84        trace_id: String,
85        name: String,
86        source: models::ScoreSource,
87        timestamp: String,
88        created_at: String,
89        updated_at: String,
90        metadata: Option<serde_json::Value>,
91        environment: String,
92        value: f64,
93    ) -> NumericScoreV1 {
94        NumericScoreV1 {
95            id,
96            trace_id,
97            name,
98            source,
99            observation_id: None,
100            timestamp,
101            created_at,
102            updated_at,
103            author_user_id: None,
104            comment: None,
105            metadata,
106            config_id: None,
107            queue_id: None,
108            environment,
109            value,
110        }
111    }
112}