langfuse_client_base/models/
score_body.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 ScoreBody {
16    #[serde(
17        rename = "id",
18        default,
19        with = "::serde_with::rust::double_option",
20        skip_serializing_if = "Option::is_none"
21    )]
22    pub id: Option<Option<String>>,
23    #[serde(
24        rename = "traceId",
25        default,
26        with = "::serde_with::rust::double_option",
27        skip_serializing_if = "Option::is_none"
28    )]
29    pub trace_id: Option<Option<String>>,
30    #[serde(
31        rename = "sessionId",
32        default,
33        with = "::serde_with::rust::double_option",
34        skip_serializing_if = "Option::is_none"
35    )]
36    pub session_id: Option<Option<String>>,
37    #[serde(
38        rename = "observationId",
39        default,
40        with = "::serde_with::rust::double_option",
41        skip_serializing_if = "Option::is_none"
42    )]
43    pub observation_id: Option<Option<String>>,
44    #[serde(
45        rename = "datasetRunId",
46        default,
47        with = "::serde_with::rust::double_option",
48        skip_serializing_if = "Option::is_none"
49    )]
50    pub dataset_run_id: Option<Option<String>>,
51    #[serde(rename = "name")]
52    pub name: String,
53    #[serde(
54        rename = "environment",
55        default,
56        with = "::serde_with::rust::double_option",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub environment: Option<Option<String>>,
60    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
61    #[serde(
62        rename = "queueId",
63        default,
64        with = "::serde_with::rust::double_option",
65        skip_serializing_if = "Option::is_none"
66    )]
67    pub queue_id: Option<Option<String>>,
68    #[serde(rename = "value")]
69    pub value: Box<models::CreateScoreValue>,
70    #[serde(
71        rename = "comment",
72        default,
73        with = "::serde_with::rust::double_option",
74        skip_serializing_if = "Option::is_none"
75    )]
76    pub comment: Option<Option<String>>,
77    #[serde(
78        rename = "metadata",
79        default,
80        with = "::serde_with::rust::double_option",
81        skip_serializing_if = "Option::is_none"
82    )]
83    pub metadata: Option<Option<serde_json::Value>>,
84    #[serde(rename = "dataType", skip_serializing_if = "Option::is_none")]
85    pub data_type: Option<models::ScoreDataType>,
86    /// Reference a score config on a score. When set, the score name must equal the config name and scores must comply with the config's range and data type. For categorical scores, the value must map to a config category. Numeric scores might be constrained by the score config's max and min values
87    #[serde(
88        rename = "configId",
89        default,
90        with = "::serde_with::rust::double_option",
91        skip_serializing_if = "Option::is_none"
92    )]
93    pub config_id: Option<Option<String>>,
94}
95
96impl ScoreBody {
97    pub fn new(name: String, value: models::CreateScoreValue) -> ScoreBody {
98        ScoreBody {
99            id: None,
100            trace_id: None,
101            session_id: None,
102            observation_id: None,
103            dataset_run_id: None,
104            name,
105            environment: None,
106            queue_id: None,
107            value: Box::new(value),
108            comment: None,
109            metadata: None,
110            data_type: None,
111            config_id: None,
112        }
113    }
114}