/*
* 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};
/// UnstableEvaluationRuleMapping : Maps one evaluator prompt variable to one source field from the target object. How to build a valid mapping list: 1. Create the evaluator or fetch it with `GET /evaluators/{id}`. 2. Read the evaluator `variables` array. 3. Add exactly one mapping object for each variable in that array. 4. Use the variable name exactly as returned, without braces such as `{{` or `}}`. 5. Choose a `source` that is valid for the selected `target`. `jsonPath` is optional. Use it only when the selected source is a JSON object and you want to extract one nested field before inserting it into the evaluator prompt. Recovery guidance: - `invalid_variable_mapping`: the variable name is unknown for this evaluator, or the selected `source` is not valid for the chosen `target` - `missing_variable_mapping`: one or more evaluator variables are not mapped yet - `duplicate_variable_mapping`: the same evaluator variable appears more than once - `invalid_json_path`: the JSONPath expression is malformed. Remove it or correct it.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct UnstableEvaluationRuleMapping {
/// Prompt variable name without braces. Example: for the prompt `Judge {{input}} against {{output}}`, use `input` and `output`.
#[serde(rename = "variable")]
pub variable: String,
#[serde(rename = "source")]
pub source: models::UnstableEvaluationRuleMappingSource,
/// Optional JSONPath selector applied to the selected source before it is passed to the evaluator prompt. Requirements: - Must start with `$` - Must be a syntactically valid JSONPath expression - Most useful with `source=metadata`
#[serde(
rename = "jsonPath",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub json_path: Option<Option<String>>,
}
impl UnstableEvaluationRuleMapping {
/// Maps one evaluator prompt variable to one source field from the target object. How to build a valid mapping list: 1. Create the evaluator or fetch it with `GET /evaluators/{id}`. 2. Read the evaluator `variables` array. 3. Add exactly one mapping object for each variable in that array. 4. Use the variable name exactly as returned, without braces such as `{{` or `}}`. 5. Choose a `source` that is valid for the selected `target`. `jsonPath` is optional. Use it only when the selected source is a JSON object and you want to extract one nested field before inserting it into the evaluator prompt. Recovery guidance: - `invalid_variable_mapping`: the variable name is unknown for this evaluator, or the selected `source` is not valid for the chosen `target` - `missing_variable_mapping`: one or more evaluator variables are not mapped yet - `duplicate_variable_mapping`: the same evaluator variable appears more than once - `invalid_json_path`: the JSONPath expression is malformed. Remove it or correct it.
pub fn new(
variable: String,
source: models::UnstableEvaluationRuleMappingSource,
) -> UnstableEvaluationRuleMapping {
UnstableEvaluationRuleMapping {
variable,
source,
json_path: None,
}
}
}