openai-client-base 0.12.0

Auto-generated Rust client for the OpenAI API
/*
 * OpenAI API
 *
 * The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
 *
 * The version of the OpenAPI document: 2.3.0
 *
 * Generated by: https://openapi-generator.tech
 */

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

/// CreateEvalCustomDataSourceConfig : A CustomDataSourceConfig object that defines the schema for the data source used for the evaluation runs. This schema is used to define the shape of the data that will be: - Used to define your testing criteria and - What data is required when creating a run
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CreateEvalCustomDataSourceConfig {
    /// The type of data source. Always `custom`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The json schema for each row in the data source.
    #[serde(rename = "item_schema")]
    pub item_schema: std::collections::HashMap<String, serde_json::Value>,
    /// Whether the eval should expect you to populate the sample namespace (ie, by generating responses off of your data source)
    #[serde(
        rename = "include_sample_schema",
        skip_serializing_if = "Option::is_none"
    )]
    pub include_sample_schema: Option<bool>,
}

impl CreateEvalCustomDataSourceConfig {
    /// A CustomDataSourceConfig object that defines the schema for the data source used for the evaluation runs. This schema is used to define the shape of the data that will be: - Used to define your testing criteria and - What data is required when creating a run
    pub fn new(
        r#type: Type,
        item_schema: std::collections::HashMap<String, serde_json::Value>,
    ) -> CreateEvalCustomDataSourceConfig {
        CreateEvalCustomDataSourceConfig {
            r#type,
            item_schema,
            include_sample_schema: None,
        }
    }
}
/// The type of data source. Always `custom`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "custom")]
    Custom,
}

impl Default for Type {
    fn default() -> Type {
        Self::Custom
    }
}

impl std::fmt::Display for CreateEvalCustomDataSourceConfig {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match serde_json::to_string(self) {
            Ok(s) => write!(f, "{}", s),
            Err(_) => Err(std::fmt::Error),
        }
    }
}