langfuse_client_base/models/experiment.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#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct Experiment {
16 #[serde(rename = "id")]
17 pub id: String,
18 #[serde(rename = "name")]
19 pub name: String,
20 #[serde(rename = "description", deserialize_with = "Option::deserialize")]
21 pub description: Option<String>,
22 /// Start of the experiment, i.e. the earliest event within the requested time range. Clipped to `fromStartTime` when the experiment started before the requested range.
23 #[serde(rename = "startTime")]
24 pub start_time: chrono::DateTime<chrono::FixedOffset>,
25 /// End of the experiment, i.e. the latest event end within the requested time range.
26 #[serde(rename = "endTime")]
27 pub end_time: chrono::DateTime<chrono::FixedOffset>,
28 /// Number of experiment items within the requested time range.
29 #[serde(rename = "itemCount")]
30 pub item_count: i32,
31 /// Null when the experiment is not associated with a dataset.
32 #[serde(rename = "datasetId", deserialize_with = "Option::deserialize")]
33 pub dataset_id: Option<String>,
34 /// Included only when `fields=metadata` is requested.
35 #[serde(
36 rename = "metadata",
37 default,
38 with = "::serde_with::rust::double_option",
39 skip_serializing_if = "Option::is_none"
40 )]
41 pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
42 /// Included only when `fields=scores` is requested. Contains scores directly attached to the experiment.
43 #[serde(
44 rename = "scores",
45 default,
46 with = "::serde_with::rust::double_option",
47 skip_serializing_if = "Option::is_none"
48 )]
49 pub scores: Option<Option<Vec<models::ScoreV3>>>,
50}
51
52impl Experiment {
53 pub fn new(
54 id: String,
55 name: String,
56 description: Option<String>,
57 start_time: chrono::DateTime<chrono::FixedOffset>,
58 end_time: chrono::DateTime<chrono::FixedOffset>,
59 item_count: i32,
60 dataset_id: Option<String>,
61 ) -> Experiment {
62 Experiment {
63 id,
64 name,
65 description,
66 start_time,
67 end_time,
68 item_count,
69 dataset_id,
70 metadata: None,
71 scores: None,
72 }
73 }
74}