/*
* 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};
/// EvaluationRule : Live evaluation rule for incoming observations. A rule determines which evaluators should be used, which observations should trigger scoring, how often scoring should run, and which observation fields should populate prompt variables.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct EvaluationRule {
/// Stable evaluation-rule identifier.
#[serde(rename = "id")]
pub id: String,
/// Human-readable rule name. This is independent from evaluator names and does not need to be unique.
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "createdBy")]
pub created_by: Box<models::Creator>,
/// Whether live execution is enabled for this rule.
#[serde(rename = "enabled")]
pub enabled: bool,
/// Fraction of matching observations that should be evaluated. Must be between `0` and `1`. - `1` evaluates every matching observation. - `0.25` evaluates approximately 25% of matching observations.
#[serde(rename = "sampling")]
pub sampling: f64,
/// List of stored filter conditions returned verbatim. Filters with a `key` use the keyed response shape; all others use the base shape. These response shapes are not broken down by internal filter type. An empty list matches every incoming object.
#[serde(rename = "filter")]
pub filter: Vec<models::EvaluationRuleReadFilter>,
/// Evaluators attached to this rule in deterministic assignment order.
#[serde(rename = "evaluatorAssignments")]
pub evaluator_assignments: Vec<models::EvaluatorAssignment>,
/// Timestamp when the evaluation rule was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::FixedOffset>,
/// Timestamp when the evaluation rule was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::FixedOffset>,
}
impl EvaluationRule {
/// Live evaluation rule for incoming observations. A rule determines which evaluators should be used, which observations should trigger scoring, how often scoring should run, and which observation fields should populate prompt variables.
pub fn new(
id: String,
name: String,
created_by: models::Creator,
enabled: bool,
sampling: f64,
filter: Vec<models::EvaluationRuleReadFilter>,
evaluator_assignments: Vec<models::EvaluatorAssignment>,
created_at: chrono::DateTime<chrono::FixedOffset>,
updated_at: chrono::DateTime<chrono::FixedOffset>,
) -> EvaluationRule {
EvaluationRule {
id,
name,
created_by: Box::new(created_by),
enabled,
sampling,
filter,
evaluator_assignments,
created_at,
updated_at,
}
}
}