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

/// RealtimeConversationItemMessageSystem : A system message in a Realtime conversation can be used to provide additional context or instructions to the model. This is similar but distinct from the instruction prompt provided at the start of a conversation, as system messages can be added at any point in the conversation. For major changes to the conversation's behavior, use instructions, but for smaller updates (e.g. \"the user is now asking about a different topic\"), use system messages.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RealtimeConversationItemMessageSystem {
    /// The unique ID of the item. This may be provided by the client or generated by the server.
    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,
    /// Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item.
    #[serde(rename = "object", skip_serializing_if = "Option::is_none")]
    pub object: Option<Object>,
    /// The type of the item. Always `message`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The status of the item. Has no effect on the conversation.
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<Status>,
    /// The role of the message sender. Always `system`.
    #[serde(rename = "role")]
    pub role: Role,
    /// The content of the message.
    #[serde(rename = "content")]
    pub content: Vec<models::RealtimeConversationItemMessageSystemContentInner>,
}

impl RealtimeConversationItemMessageSystem {
    /// A system message in a Realtime conversation can be used to provide additional context or instructions to the model. This is similar but distinct from the instruction prompt provided at the start of a conversation, as system messages can be added at any point in the conversation. For major changes to the conversation's behavior, use instructions, but for smaller updates (e.g. \"the user is now asking about a different topic\"), use system messages.
    pub fn new(
        r#type: Type,
        role: Role,
        content: Vec<models::RealtimeConversationItemMessageSystemContentInner>,
    ) -> RealtimeConversationItemMessageSystem {
        RealtimeConversationItemMessageSystem {
            id: None,
            object: None,
            r#type,
            status: None,
            role,
            content,
        }
    }
}
/// Identifier for the API object being returned - always `realtime.item`. Optional when creating a new item.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "realtime.item")]
    RealtimeItem,
}

impl Default for Object {
    fn default() -> Object {
        Self::RealtimeItem
    }
}
/// The type of the item. Always `message`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "message")]
    Message,
}

impl Default for Type {
    fn default() -> Type {
        Self::Message
    }
}
/// The status of the item. Has no effect on the conversation.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "incomplete")]
    Incomplete,
    #[serde(rename = "in_progress")]
    InProgress,
}

impl Default for Status {
    fn default() -> Status {
        Self::Completed
    }
}
/// The role of the message sender. Always `system`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "system")]
    System,
}

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

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