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

/// SessionAgentResource : The effective agent configuration for a session.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct SessionAgentResource {
    /// The ID of the agent.
    #[serde(rename = "id")]
    pub id: String,
    /// The reusable agent's name when the session was created, or null if no name was saved. Later changes to the agent's name do not affect this value.
    #[serde(rename = "name", deserialize_with = "Option::deserialize")]
    pub name: Option<String>,
    /// The model used by the agent.
    #[serde(rename = "model")]
    pub model: String,
    #[serde(rename = "reasoning")]
    pub reasoning: models::ReasoningResource,
    #[serde(rename = "text")]
    pub text: models::TextResource,
    #[serde(rename = "service_tier")]
    pub service_tier: models::ServiceTierResource,
    /// Custom instructions appended to the agent's default base instructions.
    #[serde(rename = "instructions", deserialize_with = "Option::deserialize")]
    pub instructions: Option<String>,
    /// Tools available to the agent.
    #[serde(rename = "tools")]
    pub tools: Vec<models::AgentToolResource>,
    #[serde(rename = "multi_agent")]
    pub multi_agent: models::MultiAgentConfigResource,
}

impl SessionAgentResource {
    /// The effective agent configuration for a session.
    pub fn new(
        id: String,
        name: Option<String>,
        model: String,
        reasoning: models::ReasoningResource,
        text: models::TextResource,
        service_tier: models::ServiceTierResource,
        instructions: Option<String>,
        tools: Vec<models::AgentToolResource>,
        multi_agent: models::MultiAgentConfigResource,
    ) -> SessionAgentResource {
        SessionAgentResource {
            id,
            name,
            model,
            reasoning,
            text,
            service_tier,
            instructions,
            tools,
            multi_agent,
        }
    }
}

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