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