langfuse-client-base 0.12.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};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateScoreRequest {
    #[serde(
        rename = "id",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub id: Option<Option<String>>,
    #[serde(
        rename = "traceId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub trace_id: Option<Option<String>>,
    #[serde(
        rename = "sessionId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub session_id: Option<Option<String>>,
    #[serde(
        rename = "observationId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub observation_id: Option<Option<String>>,
    #[serde(
        rename = "datasetRunId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub dataset_run_id: Option<Option<String>>,
    #[serde(rename = "name")]
    pub name: String,
    #[serde(rename = "value")]
    pub value: Box<models::CreateScoreValue>,
    #[serde(
        rename = "comment",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub comment: Option<Option<String>>,
    #[serde(
        rename = "metadata",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
    /// The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
    #[serde(
        rename = "environment",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub environment: Option<Option<String>>,
    /// The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.
    #[serde(
        rename = "queueId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub queue_id: Option<Option<String>>,
    #[serde(rename = "dataType", skip_serializing_if = "Option::is_none")]
    pub data_type: Option<models::ScoreDataType>,
    /// Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.
    #[serde(
        rename = "configId",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub config_id: Option<Option<String>>,
}

impl CreateScoreRequest {
    pub fn new(name: String, value: models::CreateScoreValue) -> CreateScoreRequest {
        CreateScoreRequest {
            id: None,
            trace_id: None,
            session_id: None,
            observation_id: None,
            dataset_run_id: None,
            name,
            value: Box::new(value),
            comment: None,
            metadata: None,
            environment: None,
            queue_id: None,
            data_type: None,
            config_id: None,
        }
    }
}