openai-client-base 0.16.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};

/// SessionEventAgentSessionTurnContentPartAdded : Emitted when an output text content part is added.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionEventAgentSessionTurnContentPartAdded {
    /// The type of the object. Always `agent.session.turn.content_part.added`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The unique ID of the event.
    #[serde(rename = "event_id")]
    pub event_id: String,
    /// The ID of the session associated with the event.
    #[serde(rename = "session_id")]
    pub session_id: String,
    /// The ID of the turn associated with the event, when applicable.
    #[serde(rename = "turn_id", deserialize_with = "Option::deserialize")]
    pub turn_id: Option<String>,
    /// The ID of the message item.
    #[serde(rename = "item_id")]
    pub item_id: String,
    /// The index of the item in the turn output.
    #[serde(rename = "output_index")]
    pub output_index: i64,
    /// The index of the content part in the message.
    #[serde(rename = "content_index")]
    pub content_index: i64,
    #[serde(rename = "part")]
    pub part: models::OutputTextResource,
}

impl SessionEventAgentSessionTurnContentPartAdded {
    /// Emitted when an output text content part is added.
    pub fn new(
        r#type: Type,
        event_id: String,
        session_id: String,
        turn_id: Option<String>,
        item_id: String,
        output_index: i64,
        content_index: i64,
        part: models::OutputTextResource,
    ) -> SessionEventAgentSessionTurnContentPartAdded {
        SessionEventAgentSessionTurnContentPartAdded {
            r#type,
            event_id,
            session_id,
            turn_id,
            item_id,
            output_index,
            content_index,
            part,
        }
    }
}
/// The type of the object. Always `agent.session.turn.content_part.added`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "agent.session.turn.content_part.added")]
    AgentSessionTurnContentPartAdded,
}

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

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