Skip to main content

langfuse_client_base/models/
create_score_request.rs

1#![allow(deprecated)]
2/*
3 * server
4 *
5 * ## Real-time data  The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion).  ## 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
6 *
7 * The version of the OpenAPI document:
8 *
9 * Generated by: https://openapi-generator.tech
10 */
11
12use crate::models;
13use serde::{Deserialize, Serialize};
14
15#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct CreateScoreRequest {
17    #[serde(
18        rename = "id",
19        default,
20        with = "::serde_with::rust::double_option",
21        skip_serializing_if = "Option::is_none"
22    )]
23    pub id: Option<Option<String>>,
24    #[serde(
25        rename = "traceId",
26        default,
27        with = "::serde_with::rust::double_option",
28        skip_serializing_if = "Option::is_none"
29    )]
30    pub trace_id: Option<Option<String>>,
31    #[serde(
32        rename = "sessionId",
33        default,
34        with = "::serde_with::rust::double_option",
35        skip_serializing_if = "Option::is_none"
36    )]
37    pub session_id: Option<Option<String>>,
38    #[serde(
39        rename = "observationId",
40        default,
41        with = "::serde_with::rust::double_option",
42        skip_serializing_if = "Option::is_none"
43    )]
44    pub observation_id: Option<Option<String>>,
45    #[serde(
46        rename = "datasetRunId",
47        default,
48        with = "::serde_with::rust::double_option",
49        skip_serializing_if = "Option::is_none"
50    )]
51    pub dataset_run_id: Option<Option<String>>,
52    #[serde(rename = "name")]
53    pub name: String,
54    #[serde(rename = "value")]
55    pub value: models::CreateScoreValue,
56    #[serde(
57        rename = "comment",
58        default,
59        with = "::serde_with::rust::double_option",
60        skip_serializing_if = "Option::is_none"
61    )]
62    pub comment: Option<Option<String>>,
63    #[serde(
64        rename = "metadata",
65        default,
66        with = "::serde_with::rust::double_option",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
70    /// The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
71    #[serde(
72        rename = "environment",
73        default,
74        with = "::serde_with::rust::double_option",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub environment: Option<Option<String>>,
78    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
79    #[serde(
80        rename = "queueId",
81        default,
82        with = "::serde_with::rust::double_option",
83        skip_serializing_if = "Option::is_none"
84    )]
85    pub queue_id: Option<Option<String>>,
86    #[serde(rename = "dataType", skip_serializing_if = "Option::is_none")]
87    pub data_type: Option<models::ScoreDataType>,
88    /// 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.
89    #[serde(
90        rename = "configId",
91        default,
92        with = "::serde_with::rust::double_option",
93        skip_serializing_if = "Option::is_none"
94    )]
95    pub config_id: Option<Option<String>>,
96    #[serde(rename = "source", skip_serializing_if = "Option::is_none")]
97    pub source: Option<models::CreateScoreSource>,
98    /// The timestamp of the score, as an ISO 8601 datetime with a timezone offset. Defaults to the time the request is received. To update an existing score, send it again with the same id and timestamp.
99    #[serde(
100        rename = "timestamp",
101        default,
102        with = "::serde_with::rust::double_option",
103        skip_serializing_if = "Option::is_none"
104    )]
105    pub timestamp: Option<Option<jiff::Timestamp>>,
106}
107
108impl CreateScoreRequest {
109    pub fn new(name: String, value: models::CreateScoreValue) -> CreateScoreRequest {
110        CreateScoreRequest {
111            id: None,
112            trace_id: None,
113            session_id: None,
114            observation_id: None,
115            dataset_run_id: None,
116            name,
117            value,
118            comment: None,
119            metadata: None,
120            environment: None,
121            queue_id: None,
122            data_type: None,
123            config_id: None,
124            source: None,
125            timestamp: None,
126        }
127    }
128}
129
130impl crate::models::validation::Validate for CreateScoreRequest {
131    fn validate_into(
132        &self,
133        _path: &crate::models::validation::Path<'_>,
134        _errors: &mut Vec<crate::models::validation::ValidationError>,
135    ) {
136    }
137}