langfuse_client_base/models/score_config.rs
1/*
2 * server
3 *
4 * ## 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`
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/// ScoreConfig : Configuration for a score
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct ScoreConfig {
17 #[serde(rename = "id")]
18 pub id: String,
19 #[serde(rename = "name")]
20 pub name: String,
21 #[serde(rename = "createdAt")]
22 pub created_at: chrono::DateTime<chrono::FixedOffset>,
23 #[serde(rename = "updatedAt")]
24 pub updated_at: chrono::DateTime<chrono::FixedOffset>,
25 #[serde(rename = "projectId")]
26 pub project_id: String,
27 #[serde(rename = "dataType")]
28 pub data_type: models::ScoreConfigDataType,
29 /// Whether the score config is archived. Defaults to false
30 #[serde(rename = "isArchived")]
31 pub is_archived: bool,
32 /// Sets minimum value for numerical scores. If not set, the minimum value defaults to -∞
33 #[serde(
34 rename = "minValue",
35 default,
36 with = "::serde_with::rust::double_option",
37 skip_serializing_if = "Option::is_none"
38 )]
39 pub min_value: Option<Option<f64>>,
40 /// Sets maximum value for numerical scores. If not set, the maximum value defaults to +∞
41 #[serde(
42 rename = "maxValue",
43 default,
44 with = "::serde_with::rust::double_option",
45 skip_serializing_if = "Option::is_none"
46 )]
47 pub max_value: Option<Option<f64>>,
48 /// Configures custom categories for categorical scores
49 #[serde(
50 rename = "categories",
51 default,
52 with = "::serde_with::rust::double_option",
53 skip_serializing_if = "Option::is_none"
54 )]
55 pub categories: Option<Option<Vec<models::ConfigCategory>>>,
56 /// Description of the score config
57 #[serde(
58 rename = "description",
59 default,
60 with = "::serde_with::rust::double_option",
61 skip_serializing_if = "Option::is_none"
62 )]
63 pub description: Option<Option<String>>,
64}
65
66impl ScoreConfig {
67 /// Configuration for a score
68 pub fn new(
69 id: String,
70 name: String,
71 created_at: chrono::DateTime<chrono::FixedOffset>,
72 updated_at: chrono::DateTime<chrono::FixedOffset>,
73 project_id: String,
74 data_type: models::ScoreConfigDataType,
75 is_archived: bool,
76 ) -> ScoreConfig {
77 ScoreConfig {
78 id,
79 name,
80 created_at,
81 updated_at,
82 project_id,
83 data_type,
84 is_archived,
85 min_value: None,
86 max_value: None,
87 categories: None,
88 description: None,
89 }
90 }
91}