langfuse_client_base/models/
create_score_request.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 CreateScoreRequest {
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(rename = "value")]
54    pub value: Box<models::CreateScoreValue>,
55    #[serde(
56        rename = "comment",
57        default,
58        with = "::serde_with::rust::double_option",
59        skip_serializing_if = "Option::is_none"
60    )]
61    pub comment: Option<Option<String>>,
62    #[serde(
63        rename = "metadata",
64        default,
65        with = "::serde_with::rust::double_option",
66        skip_serializing_if = "Option::is_none"
67    )]
68    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
69    /// The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
70    #[serde(
71        rename = "environment",
72        default,
73        with = "::serde_with::rust::double_option",
74        skip_serializing_if = "Option::is_none"
75    )]
76    pub environment: Option<Option<String>>,
77    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
78    #[serde(
79        rename = "queueId",
80        default,
81        with = "::serde_with::rust::double_option",
82        skip_serializing_if = "Option::is_none"
83    )]
84    pub queue_id: Option<Option<String>>,
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. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.
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 CreateScoreRequest {
98    pub fn new(name: String, value: models::CreateScoreValue) -> CreateScoreRequest {
99        CreateScoreRequest {
100            id: None,
101            trace_id: None,
102            session_id: None,
103            observation_id: None,
104            dataset_run_id: None,
105            name,
106            value: Box::new(value),
107            comment: None,
108            metadata: None,
109            environment: None,
110            queue_id: None,
111            data_type: None,
112            config_id: None,
113        }
114    }
115}