Skip to main content

langfuse_client_base/models/
base_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
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 BaseScoreV1 {
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: chrono::DateTime<chrono::FixedOffset>,
34    #[serde(rename = "createdAt")]
35    pub created_at: chrono::DateTime<chrono::FixedOffset>,
36    #[serde(rename = "updatedAt")]
37    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
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}
77
78impl BaseScoreV1 {
79    pub fn new(
80        id: String,
81        trace_id: String,
82        name: String,
83        source: models::ScoreSource,
84        timestamp: chrono::DateTime<chrono::FixedOffset>,
85        created_at: chrono::DateTime<chrono::FixedOffset>,
86        updated_at: chrono::DateTime<chrono::FixedOffset>,
87        metadata: Option<serde_json::Value>,
88        environment: String,
89    ) -> BaseScoreV1 {
90        BaseScoreV1 {
91            id,
92            trace_id,
93            name,
94            source,
95            observation_id: None,
96            timestamp,
97            created_at,
98            updated_at,
99            author_user_id: None,
100            comment: None,
101            metadata,
102            config_id: None,
103            queue_id: None,
104            environment,
105        }
106    }
107}