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

/// SessionEventAgentSessionTurnItemAdded : Emitted when an item is added to a turn.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionEventAgentSessionTurnItemAdded {
    /// The type of the object. Always `agent.session.turn.item.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 index of the item in the turn output, when the item is agent output.
    #[serde(rename = "output_index", deserialize_with = "Option::deserialize")]
    pub output_index: Option<i64>,
    #[serde(rename = "item")]
    pub item: Box<models::SessionTurnItemResource>,
}

impl SessionEventAgentSessionTurnItemAdded {
    /// Emitted when an item is added to a turn.
    pub fn new(
        r#type: Type,
        event_id: String,
        session_id: String,
        turn_id: Option<String>,
        output_index: Option<i64>,
        item: models::SessionTurnItemResource,
    ) -> SessionEventAgentSessionTurnItemAdded {
        SessionEventAgentSessionTurnItemAdded {
            r#type,
            event_id,
            session_id,
            turn_id,
            output_index,
            item: Box::new(item),
        }
    }
}
/// The type of the object. Always `agent.session.turn.item.added`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "agent.session.turn.item.added")]
    AgentSessionTurnItemAdded,
}

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

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