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

/// GraderPython : A PythonGrader object that runs a python script on the input.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct GraderPython {
    /// The object type, which is always `python`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The name of the grader.
    #[serde(rename = "name")]
    pub name: String,
    /// The source code of the python script.
    #[serde(rename = "source")]
    pub source: String,
    /// The image tag to use for the python script.
    #[serde(rename = "image_tag", skip_serializing_if = "Option::is_none")]
    pub image_tag: Option<String>,
}

impl GraderPython {
    /// A PythonGrader object that runs a python script on the input.
    pub fn new(r#type: Type, name: String, source: String) -> GraderPython {
        GraderPython {
            r#type,
            name,
            source,
            image_tag: None,
        }
    }
}
/// The object type, which is always `python`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "python")]
    Python,
}

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

impl std::fmt::Display for GraderPython {
    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),
        }
    }
}