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

/// ChatkitWorkflow : Workflow metadata and state returned for the session.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ChatkitWorkflow {
    /// Identifier of the workflow backing the session.
    #[serde(rename = "id")]
    pub id: String,
    /// Specific workflow version used for the session. Defaults to null when using the latest deployment.
    #[serde(rename = "version", deserialize_with = "Option::deserialize")]
    pub version: Option<String>,
    /// State variable key-value pairs applied when invoking the workflow. Defaults to null when no overrides were provided.
    #[serde(rename = "state_variables", deserialize_with = "Option::deserialize")]
    pub state_variables: Option<std::collections::HashMap<String, models::Object019Value>>,
    #[serde(rename = "tracing")]
    pub tracing: Box<models::ChatkitWorkflowTracing>,
}

impl ChatkitWorkflow {
    /// Workflow metadata and state returned for the session.
    pub fn new(
        id: String,
        version: Option<String>,
        state_variables: Option<std::collections::HashMap<String, models::Object019Value>>,
        tracing: models::ChatkitWorkflowTracing,
    ) -> ChatkitWorkflow {
        ChatkitWorkflow {
            id,
            version,
            state_variables,
            tracing: Box::new(tracing),
        }
    }
}

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