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

/// MessageDeltaObjectDelta : The delta containing the fields that have changed on the Message.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct MessageDeltaObjectDelta {
    /// The entity that produced the message. One of `user` or `assistant`.
    #[serde(rename = "role", skip_serializing_if = "Option::is_none")]
    pub role: Option<Role>,
    /// The content of the message in array of text and/or images.
    #[serde(rename = "content", skip_serializing_if = "Option::is_none")]
    pub content: Option<Vec<models::MessageDeltaObjectDeltaContentInner>>,
}

impl MessageDeltaObjectDelta {
    /// The delta containing the fields that have changed on the Message.
    pub fn new() -> MessageDeltaObjectDelta {
        MessageDeltaObjectDelta {
            role: None,
            content: None,
        }
    }
}
/// The entity that produced the message. One of `user` or `assistant`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "user")]
    User,
    #[serde(rename = "assistant")]
    Assistant,
}

impl Default for Role {
    fn default() -> Role {
        Self::User
    }
}

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