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

/// AgentToolConfigParamWebSearch : Web search.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AgentToolConfigParamWebSearch {
    /// The type of the object. Always `web_search`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(
        rename = "mode",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub mode: Option<Option<models::WebSearchModeParam>>,
    #[serde(
        rename = "context_size",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub context_size: Option<Option<models::WebSearchContextSizeParam>>,
    /// Domains the search may include.
    #[serde(
        rename = "allowed_domains",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub allowed_domains: Option<Option<Vec<String>>>,
    #[serde(
        rename = "location",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub location: Option<Option<models::WebSearchLocationParam>>,
}

impl AgentToolConfigParamWebSearch {
    /// Web search.
    pub fn new(r#type: Type) -> AgentToolConfigParamWebSearch {
        AgentToolConfigParamWebSearch {
            r#type,
            mode: None,
            context_size: None,
            allowed_domains: None,
            location: None,
        }
    }
}
/// The type of the object. Always `web_search`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "web_search")]
    WebSearch,
}

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

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