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

/// WebSearchToolCall : The results of a web search tool call. See the [web search guide](/docs/guides/tools-web-search) for more information.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct WebSearchToolCall {
    /// 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,
    /// The status of the web search tool call.
    #[serde(rename = "status")]
    pub status: Status,
    #[serde(rename = "action")]
    pub action: Box<models::WebSearchToolCallAction>,
}

impl WebSearchToolCall {
    /// The results of a web search tool call. See the [web search guide](/docs/guides/tools-web-search) for more information.
    pub fn new(
        id: String,
        r#type: Type,
        status: Status,
        action: models::WebSearchToolCallAction,
    ) -> WebSearchToolCall {
        WebSearchToolCall {
            id,
            r#type,
            status,
            action: Box::new(action),
        }
    }
}
/// 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
    }
}
/// The status of the web search tool call.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
    #[serde(rename = "in_progress")]
    InProgress,
    #[serde(rename = "searching")]
    Searching,
    #[serde(rename = "completed")]
    Completed,
    #[serde(rename = "failed")]
    Failed,
}

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

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