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

/// BetaWebSearchToolCall : The results of a web search tool call. See the [web search guide](https://developers.openai.com/api/docs/guides/tools-web-search) for more information.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaWebSearchToolCall {
    #[serde(
        rename = "agent",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub agent: Option<Option<Box<models::BetaAgentTag>>>,
    /// The unique ID of the web search tool call.
    #[serde(rename = "id")]
    pub id: String,
    /// The type of the web search tool call. Always `web_search_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "status")]
    pub status: models::BetaWebSearchCallStatus,
    #[serde(rename = "action", skip_serializing_if = "Option::is_none")]
    pub action: Option<Box<models::BetaWebSearchToolCallAction>>,
}

impl BetaWebSearchToolCall {
    /// The results of a web search tool call. See the [web search guide](https://developers.openai.com/api/docs/guides/tools-web-search) for more information.
    pub fn new(
        id: String,
        r#type: Type,
        status: models::BetaWebSearchCallStatus,
    ) -> BetaWebSearchToolCall {
        BetaWebSearchToolCall {
            agent: None,
            id,
            r#type,
            status,
            action: None,
        }
    }
}
/// The type of the web search tool call. Always `web_search_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "web_search_call")]
    WebSearchCall,
}

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

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