langfuse-client-base 0.13.0

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};

/// UnstableCreateEvaluationRuleRequest : Request body for creating an evaluation rule.  Checklist for agents and SDK clients: - reference an existing evaluator family by `evaluator.name` and `evaluator.scope` - choose `target=observation` or `target=experiment` - if `target=experiment` and you want a dataset filter, call `GET /api/public/v2/datasets` first and use dataset `id` values in `filter[].value` - fetch or inspect the evaluator first, then provide a complete variable mapping for every evaluator variable listed in `variables` - optionally narrow execution with `filter` - set `enabled=true` only when you want live execution immediately
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct UnstableCreateEvaluationRuleRequest {
    /// Human-readable deployment name.
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "evaluator")]
    pub evaluator: Box<models::UnstableEvaluationRuleEvaluatorReference>,
    #[serde(rename = "target")]
    pub target: models::UnstableEvaluationRuleTarget,
    /// Whether the deployment should be active immediately after creation.
    #[serde(rename = "enabled")]
    pub enabled: bool,
    /// Optional sampling fraction. Defaults to `1`.
    #[serde(
        rename = "sampling",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub sampling: Option<Option<f64>>,
    /// Optional filter list.  Omit or pass an empty list to evaluate all matching targets for the selected `target`. Each filter object must use a column that is valid for that `target`. For `target=experiment`, `column=datasetId` expects dataset `id` values from `GET /api/public/v2/datasets`, not dataset names.
    #[serde(
        rename = "filter",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub filter: Option<Option<Vec<models::UnstableEvaluationRuleFilter>>>,
    /// Required variable mappings.  Every evaluator variable must appear exactly once. Build this list from the evaluator `variables` array returned by the evaluator endpoints.
    #[serde(rename = "mapping")]
    pub mapping: Vec<models::UnstableEvaluationRuleMapping>,
}

impl UnstableCreateEvaluationRuleRequest {
    /// Request body for creating an evaluation rule.  Checklist for agents and SDK clients: - reference an existing evaluator family by `evaluator.name` and `evaluator.scope` - choose `target=observation` or `target=experiment` - if `target=experiment` and you want a dataset filter, call `GET /api/public/v2/datasets` first and use dataset `id` values in `filter[].value` - fetch or inspect the evaluator first, then provide a complete variable mapping for every evaluator variable listed in `variables` - optionally narrow execution with `filter` - set `enabled=true` only when you want live execution immediately
    pub fn new(
        name: String,
        evaluator: models::UnstableEvaluationRuleEvaluatorReference,
        target: models::UnstableEvaluationRuleTarget,
        enabled: bool,
        mapping: Vec<models::UnstableEvaluationRuleMapping>,
    ) -> UnstableCreateEvaluationRuleRequest {
        UnstableCreateEvaluationRuleRequest {
            name,
            evaluator: Box::new(evaluator),
            target,
            enabled,
            sampling: None,
            filter: None,
            mapping,
        }
    }
}