openai-client-base 0.16.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 DecisionRequest {
    /// The model to use. Only `gpt-6-luna` is supported.
    #[serde(rename = "model")]
    pub model: String,
    #[serde(rename = "input")]
    pub input: Box<models::DecisionInput>,
    /// Ask 1–200 questions about the input. Each question can be a predicate, choice, or score. Answers come back in the same order.
    #[serde(rename = "questions")]
    pub questions: Vec<models::QuestionParam>,
    /// Opaque caller-provided end-user identifier, scoped by the verified org. Match Responses' limit; this is never the authenticated user identity.
    #[serde(rename = "safety_identifier", skip_serializing_if = "Option::is_none")]
    pub safety_identifier: Option<String>,
    /// Partition prompt cache reuse by caller-provided key.
    #[serde(rename = "prompt_cache_key", skip_serializing_if = "Option::is_none")]
    pub prompt_cache_key: Option<String>,
    #[serde(
        rename = "prompt_cache_options",
        skip_serializing_if = "Option::is_none"
    )]
    pub prompt_cache_options: Option<models::DecisionRequestPromptCacheOptions>,
}

impl DecisionRequest {
    pub fn new(
        model: String,
        input: models::DecisionInput,
        questions: Vec<models::QuestionParam>,
    ) -> DecisionRequest {
        DecisionRequest {
            model,
            input: Box::new(input),
            questions,
            safety_identifier: None,
            prompt_cache_key: None,
            prompt_cache_options: None,
        }
    }
}

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