Skip to main content

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    /// The name of the score. Always overrides \"output\" for correction scores.
52    #[serde(rename = "name")]
53    pub name: String,
54    #[serde(
55        rename = "environment",
56        default,
57        with = "::serde_with::rust::double_option",
58        skip_serializing_if = "Option::is_none"
59    )]
60    pub environment: Option<Option<String>>,
61    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
62    #[serde(
63        rename = "queueId",
64        default,
65        with = "::serde_with::rust::double_option",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub queue_id: Option<Option<String>>,
69    #[serde(rename = "value")]
70    pub value: Box<models::CreateScoreValue>,
71    #[serde(
72        rename = "comment",
73        default,
74        with = "::serde_with::rust::double_option",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub comment: Option<Option<String>>,
78    #[serde(
79        rename = "metadata",
80        default,
81        with = "::serde_with::rust::double_option",
82        skip_serializing_if = "Option::is_none"
83    )]
84    pub metadata: Option<Option<serde_json::Value>>,
85    #[serde(rename = "dataType", skip_serializing_if = "Option::is_none")]
86    pub data_type: Option<models::ScoreDataType>,
87    /// 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
88    #[serde(
89        rename = "configId",
90        default,
91        with = "::serde_with::rust::double_option",
92        skip_serializing_if = "Option::is_none"
93    )]
94    pub config_id: Option<Option<String>>,
95}
96
97impl ScoreBody {
98    pub fn new(name: String, value: models::CreateScoreValue) -> ScoreBody {
99        ScoreBody {
100            id: None,
101            trace_id: None,
102            session_id: None,
103            observation_id: None,
104            dataset_run_id: None,
105            name,
106            environment: None,
107            queue_id: None,
108            value: Box::new(value),
109            comment: None,
110            metadata: None,
111            data_type: None,
112            config_id: None,
113        }
114    }
115}