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

/// WebSearchActionSearch : Action type \"search\" - Performs a web search query.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebSearchActionSearch {
    /// The action type.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// [DEPRECATED] The search query.
    #[serde(rename = "query")]
    pub query: String,
    /// The search queries.
    #[serde(rename = "queries", skip_serializing_if = "Option::is_none")]
    pub queries: Option<Vec<String>>,
    /// The sources used in the search.
    #[serde(rename = "sources", skip_serializing_if = "Option::is_none")]
    pub sources: Option<Vec<models::WebSearchSource>>,
}

impl WebSearchActionSearch {
    /// Action type \"search\" - Performs a web search query.
    pub fn new(r#type: Type, query: String) -> WebSearchActionSearch {
        WebSearchActionSearch {
            r#type,
            query,
            queries: None,
            sources: None,
        }
    }
}
/// The action type.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "search")]
    Search,
}

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

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