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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct RankingOptions {
    #[serde(rename = "ranker", skip_serializing_if = "Option::is_none")]
    pub ranker: Option<models::RankerVersionType>,
    /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results.
    #[serde(rename = "score_threshold", skip_serializing_if = "Option::is_none")]
    pub score_threshold: Option<f64>,
    #[serde(rename = "hybrid_search", skip_serializing_if = "Option::is_none")]
    pub hybrid_search: Option<Box<models::HybridSearchOptions>>,
}

impl RankingOptions {
    pub fn new() -> RankingOptions {
        RankingOptions {
            ranker: None,
            score_threshold: None,
            hybrid_search: None,
        }
    }
}

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