langfuse_client_base/models/unstable_create_evaluation_rule_request.rs
1/*
2 * langfuse
3 *
4 * ## 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
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/// 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
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct UnstableCreateEvaluationRuleRequest {
17 /// Human-readable deployment name.
18 #[serde(rename = "name")]
19 pub name: String,
20 #[serde(rename = "evaluator")]
21 pub evaluator: Box<models::UnstableEvaluationRuleEvaluatorReference>,
22 #[serde(rename = "target")]
23 pub target: models::UnstableEvaluationRuleTarget,
24 /// Whether the deployment should be active immediately after creation.
25 #[serde(rename = "enabled")]
26 pub enabled: bool,
27 /// Optional sampling fraction. Defaults to `1`.
28 #[serde(
29 rename = "sampling",
30 default,
31 with = "::serde_with::rust::double_option",
32 skip_serializing_if = "Option::is_none"
33 )]
34 pub sampling: Option<Option<f64>>,
35 /// 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.
36 #[serde(
37 rename = "filter",
38 default,
39 with = "::serde_with::rust::double_option",
40 skip_serializing_if = "Option::is_none"
41 )]
42 pub filter: Option<Option<Vec<models::UnstableEvaluationRuleFilter>>>,
43 /// Required variable mappings. Every evaluator variable must appear exactly once. Build this list from the evaluator `variables` array returned by the evaluator endpoints.
44 #[serde(rename = "mapping")]
45 pub mapping: Vec<models::UnstableEvaluationRuleMapping>,
46}
47
48impl UnstableCreateEvaluationRuleRequest {
49 /// 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
50 pub fn new(
51 name: String,
52 evaluator: models::UnstableEvaluationRuleEvaluatorReference,
53 target: models::UnstableEvaluationRuleTarget,
54 enabled: bool,
55 mapping: Vec<models::UnstableEvaluationRuleMapping>,
56 ) -> UnstableCreateEvaluationRuleRequest {
57 UnstableCreateEvaluationRuleRequest {
58 name,
59 evaluator: Box::new(evaluator),
60 target,
61 enabled,
62 sampling: None,
63 filter: None,
64 mapping,
65 }
66 }
67}