/*
* server
*
* ## 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`
*
* The version of the OpenAPI document:
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateScoreRequest {
#[serde(
rename = "id",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub id: Option<Option<String>>,
#[serde(
rename = "traceId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub trace_id: Option<Option<String>>,
#[serde(
rename = "sessionId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub session_id: Option<Option<String>>,
#[serde(
rename = "observationId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub observation_id: Option<Option<String>>,
#[serde(
rename = "datasetRunId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub dataset_run_id: Option<Option<String>>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "value")]
pub value: Box<models::CreateScoreValue>,
#[serde(
rename = "comment",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub comment: Option<Option<String>>,
#[serde(
rename = "metadata",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
/// The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
#[serde(
rename = "environment",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub environment: Option<Option<String>>,
/// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
#[serde(
rename = "queueId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub queue_id: Option<Option<String>>,
#[serde(rename = "dataType", skip_serializing_if = "Option::is_none")]
pub data_type: Option<models::ScoreDataType>,
/// 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.
#[serde(
rename = "configId",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub config_id: Option<Option<String>>,
#[serde(rename = "source", skip_serializing_if = "Option::is_none")]
pub source: Option<models::CreateScoreSource>,
/// 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.
#[serde(
rename = "timestamp",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub timestamp: Option<Option<chrono::DateTime<chrono::FixedOffset>>>,
}
impl CreateScoreRequest {
pub fn new(name: String, value: models::CreateScoreValue) -> CreateScoreRequest {
CreateScoreRequest {
id: None,
trace_id: None,
session_id: None,
observation_id: None,
dataset_run_id: None,
name,
value: Box::new(value),
comment: None,
metadata: None,
environment: None,
queue_id: None,
data_type: None,
config_id: None,
source: None,
timestamp: None,
}
}
}