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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaResponsesWebSocketStreamEvent {
    #[serde(
        rename = "agent",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub agent: Option<Option<Box<models::BetaAgentTag>>>,
    /// The event type identifier.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The sequence number of this event.
    #[serde(rename = "sequence_number")]
    pub sequence_number: i32,
    /// The incremental input data (delta) for the custom tool call.
    #[serde(rename = "delta")]
    pub delta: String,
    /// The index of the output this event applies to.
    #[serde(rename = "output_index")]
    pub output_index: i32,
    /// Unique identifier for the API item associated with this event.
    #[serde(rename = "item_id")]
    pub item_id: String,
    /// The final code snippet output by the code interpreter.
    #[serde(rename = "code")]
    pub code: String,
    #[serde(rename = "response")]
    pub response: Box<models::BetaResponse>,
    /// The index of the content part within the output item.
    #[serde(rename = "content_index")]
    pub content_index: i32,
    #[serde(rename = "part")]
    pub part: Box<models::ResponseReasoningSummaryPartDoneEventPart>,
    /// A JSON string containing the finalized arguments for the MCP tool call.
    #[serde(rename = "arguments")]
    pub arguments: String,
    /// The index of the shell command that produced output.
    #[serde(rename = "command_index")]
    pub command_index: i32,
    /// The final shell command that was emitted.
    #[serde(rename = "command")]
    pub command: String,
    /// An obfuscation string that was added to pad the event payload.
    #[serde(rename = "obfuscation", skip_serializing_if = "Option::is_none")]
    pub obfuscation: Option<String>,
    /// The output contents emitted for the shell command.
    #[serde(rename = "output")]
    pub output: Vec<models::BetaFunctionShellCallOutputContent>,
    #[serde(rename = "item")]
    pub item: Box<models::BetaOutputItem>,
    /// The index of the summary part within the reasoning summary.
    #[serde(rename = "summary_index")]
    pub summary_index: i32,
    /// The completion status of the summary part. Omitted when the part completed normally and set to `incomplete` when generation was interrupted.
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<Status>,
    /// The text content that is finalized.
    #[serde(rename = "text")]
    pub text: String,
    /// The refusal text that is finalized.
    #[serde(rename = "refusal")]
    pub refusal: String,
    /// The log probabilities of the tokens in the delta.
    #[serde(rename = "logprobs")]
    pub logprobs: Vec<models::BetaResponseLogProb>,
    /// 0-based index for the partial image (backend is 1-based, but this is 0-based for the user).
    #[serde(rename = "partial_image_index")]
    pub partial_image_index: i32,
    /// Base64-encoded partial image data, suitable for rendering as an image.
    #[serde(rename = "partial_image_b64")]
    pub partial_image_b64: String,
    /// The image size that was used.
    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
    pub size: Option<String>,
    /// The image quality that was used.
    #[serde(rename = "quality", skip_serializing_if = "Option::is_none")]
    pub quality: Option<String>,
    /// The background setting that was used.
    #[serde(rename = "background", skip_serializing_if = "Option::is_none")]
    pub background: Option<String>,
    /// The output format that was used.
    #[serde(rename = "output_format", skip_serializing_if = "Option::is_none")]
    pub output_format: Option<String>,
    /// The index of the annotation within the content part.
    #[serde(rename = "annotation_index")]
    pub annotation_index: i32,
    #[serde(rename = "annotation", deserialize_with = "Option::deserialize")]
    pub annotation: Option<Box<models::BetaAnnotation>>,
    /// The complete input data for the custom tool call.
    #[serde(rename = "input")]
    pub input: String,
    /// The WebSocket lane that emitted this event. This field is present when the originating `response.create` event supplied a `stream_id`.
    #[serde(rename = "stream_id", skip_serializing_if = "Option::is_none")]
    pub stream_id: Option<String>,
}

impl BetaResponsesWebSocketStreamEvent {
    pub fn new(
        r#type: Type,
        sequence_number: i32,
        delta: String,
        output_index: i32,
        item_id: String,
        code: String,
        response: models::BetaResponse,
        content_index: i32,
        part: models::ResponseReasoningSummaryPartDoneEventPart,
        arguments: String,
        command_index: i32,
        command: String,
        output: Vec<models::BetaFunctionShellCallOutputContent>,
        item: models::BetaOutputItem,
        summary_index: i32,
        text: String,
        refusal: String,
        logprobs: Vec<models::BetaResponseLogProb>,
        partial_image_index: i32,
        partial_image_b64: String,
        annotation_index: i32,
        annotation: Option<models::BetaAnnotation>,
        input: String,
    ) -> BetaResponsesWebSocketStreamEvent {
        BetaResponsesWebSocketStreamEvent {
            agent: None,
            r#type,
            sequence_number,
            delta,
            output_index,
            item_id,
            code,
            response: Box::new(response),
            content_index,
            part: Box::new(part),
            arguments,
            command_index,
            command,
            obfuscation: None,
            output,
            item: Box::new(item),
            summary_index,
            status: None,
            text,
            refusal,
            logprobs,
            partial_image_index,
            partial_image_b64,
            size: None,
            quality: None,
            background: None,
            output_format: None,
            annotation_index,
            annotation: annotation.map(Box::new),
            input,
            stream_id: None,
        }
    }
}
/// The event type identifier.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "response.custom_tool_call_input.done")]
    ResponseCustomToolCallInputDone,
}

impl Default for Type {
    fn default() -> Type {
        Self::ResponseCustomToolCallInputDone
    }
}
/// The completion status of the summary part. Omitted when the part completed normally and set to `incomplete` when generation was interrupted.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "incomplete")]
    Incomplete,
}

impl Default for Status {
    fn default() -> Status {
        Self::Incomplete
    }
}

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