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

/// FileSearchTool : A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FileSearchTool {
    /// The type of the file search tool. Always `file_search`.
    #[serde(rename = "type")]
    pub r#type: Type,
    /// The IDs of the vector stores to search.
    #[serde(rename = "vector_store_ids")]
    pub vector_store_ids: Vec<String>,
    /// The maximum number of results to return. This number should be between 1 and 50 inclusive.
    #[serde(rename = "max_num_results", skip_serializing_if = "Option::is_none")]
    pub max_num_results: Option<i32>,
    #[serde(rename = "ranking_options", skip_serializing_if = "Option::is_none")]
    pub ranking_options: Option<Box<models::RankingOptions>>,
    #[serde(
        rename = "filters",
        default,
        with = "::serde_with::rust::double_option",
        skip_serializing_if = "Option::is_none"
    )]
    pub filters: Option<Option<Box<models::Filters>>>,
}

impl FileSearchTool {
    /// A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
    pub fn new(r#type: Type, vector_store_ids: Vec<String>) -> FileSearchTool {
        FileSearchTool {
            r#type,
            vector_store_ids,
            max_num_results: None,
            ranking_options: None,
            filters: None,
        }
    }
}
/// The type of the file search tool. Always `file_search`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "file_search")]
    FileSearch,
}

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

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