langfuse-client-base 0.13.1

Auto-generated Langfuse API client from OpenAPI specification
Documentation
/*
 * langfuse
 *
 * ## 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
 *
 * The version of the OpenAPI document:
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// UnstableEvaluationRule : Live evaluation rule for incoming data.  An evaluation rule answers: - which evaluator should be used - which target objects should trigger scoring - how often scoring should run - which target fields should populate each evaluator variable - whether the deployment is active, inactive, or paused  Important status semantics: - `enabled` is the desired on/off setting from the client - `status` is the effective runtime state after Langfuse applies validation and blocking rules - `enabled=true` with `status=paused` means the rule should run, but Langfuse has paused it until the underlying problem is fixed
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct UnstableEvaluationRule {
    /// Stable evaluation rule identifier.
    #[serde(rename = "id")]
    pub id: String,
    /// Human-readable deployment name. This is independent from the evaluator name.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "evaluator")]
    pub evaluator: Box<models::UnstableEvaluationRuleEvaluator>,
    #[serde(rename = "target")]
    pub target: models::UnstableEvaluationRuleTarget,
    /// Desired enabled state configured by the client.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    #[serde(rename = "status")]
    pub status: models::UnstableEvaluationRuleStatus,
    /// Machine-readable reason when `status=paused`, otherwise `null`.
    #[serde(
        rename = "pausedReason",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub paused_reason: Option<Option<String>>,
    /// Human-readable explanation when `status=paused`, otherwise `null`.
    #[serde(
        rename = "pausedMessage",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub paused_message: Option<Option<String>>,
    /// Fraction of matching target objects that should be evaluated.  Must be greater than `0` and less than or equal to `1`. - `1` means evaluate every matching target. - `0.25` means evaluate approximately 25% of matching targets.
    #[serde(rename = "sampling")]
    pub sampling: f64,
    /// List of filter conditions used to decide whether a target should be evaluated.
    #[serde(rename = "filter")]
    pub filter: Vec<models::UnstableEvaluationRuleFilter>,
    /// Variable mappings used to populate the evaluator prompt from the live target object.
    #[serde(rename = "mapping")]
    pub mapping: Vec<models::UnstableEvaluationRuleMapping>,
    /// 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 UnstableEvaluationRule {
    /// Live evaluation rule for incoming data.  An evaluation rule answers: - which evaluator should be used - which target objects should trigger scoring - how often scoring should run - which target fields should populate each evaluator variable - whether the deployment is active, inactive, or paused  Important status semantics: - `enabled` is the desired on/off setting from the client - `status` is the effective runtime state after Langfuse applies validation and blocking rules - `enabled=true` with `status=paused` means the rule should run, but Langfuse has paused it until the underlying problem is fixed
    pub fn new(
        id: String,
        name: String,
        evaluator: models::UnstableEvaluationRuleEvaluator,
        target: models::UnstableEvaluationRuleTarget,
        enabled: bool,
        status: models::UnstableEvaluationRuleStatus,
        sampling: f64,
        filter: Vec<models::UnstableEvaluationRuleFilter>,
        mapping: Vec<models::UnstableEvaluationRuleMapping>,
        created_at: chrono::DateTime<chrono::FixedOffset>,
        updated_at: chrono::DateTime<chrono::FixedOffset>,
    ) -> UnstableEvaluationRule {
        UnstableEvaluationRule {
            id,
            name,
            evaluator: Box::new(evaluator),
            target,
            enabled,
            status,
            paused_reason: None,
            paused_message: None,
            sampling,
            filter,
            mapping,
            created_at,
            updated_at,
        }
    }
}