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