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

/// VectorStoreSearchRequestRankingOptions : Ranking options for search.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct VectorStoreSearchRequestRankingOptions {
    /// Enable re-ranking; set to `none` to disable, which can help reduce latency.
    #[serde(rename = "ranker", skip_serializing_if = "Option::is_none")]
    pub ranker: Option<Ranker>,
    #[serde(rename = "score_threshold", skip_serializing_if = "Option::is_none")]
    pub score_threshold: Option<f64>,
}

impl VectorStoreSearchRequestRankingOptions {
    /// Ranking options for search.
    pub fn new() -> VectorStoreSearchRequestRankingOptions {
        VectorStoreSearchRequestRankingOptions {
            ranker: None,
            score_threshold: None,
        }
    }
}
/// Enable re-ranking; set to `none` to disable, which can help reduce latency.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Ranker {
    #[serde(rename = "none")]
    None,
    #[serde(rename = "auto")]
    Auto,
    #[serde(rename = "default-2024-11-15")]
    Default20241115,
}

impl Default for Ranker {
    fn default() -> Ranker {
        Self::None
    }
}

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