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

/// AgentResource : A reusable agent scoped to the caller's project.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct AgentResource {
    /// The ID of the reusable agent.
    #[serde(rename = "id")]
    pub id: String,
    /// The object type. Always `agent`.
    #[serde(rename = "object")]
    pub object: Object,
    /// The Unix timestamp, in seconds, when the agent was created.
    #[serde(rename = "created_at")]
    pub created_at: i64,
    /// The Unix timestamp, in seconds, when the agent was last updated.
    #[serde(rename = "updated_at")]
    pub updated_at: i64,
    /// A human-readable name for the agent, or null if it is unnamed.
    #[serde(rename = "name", deserialize_with = "Option::deserialize")]
    pub name: Option<String>,
    /// Custom string key-value pairs attached to the agent.
    #[serde(rename = "metadata")]
    pub metadata: std::collections::HashMap<String, String>,
    /// The requested model name used for inference.
    #[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::PersistedAgentToolResource>,
    #[serde(rename = "multi_agent")]
    pub multi_agent: models::MultiAgentConfigResource,
}

impl AgentResource {
    /// A reusable agent scoped to the caller's project.
    pub fn new(
        id: String,
        object: Object,
        created_at: i64,
        updated_at: i64,
        name: Option<String>,
        metadata: std::collections::HashMap<String, String>,
        model: String,
        reasoning: models::ReasoningResource,
        text: models::TextResource,
        service_tier: models::ServiceTierResource,
        instructions: Option<String>,
        tools: Vec<models::PersistedAgentToolResource>,
        multi_agent: models::MultiAgentConfigResource,
    ) -> AgentResource {
        AgentResource {
            id,
            object,
            created_at,
            updated_at,
            name,
            metadata,
            model,
            reasoning,
            text,
            service_tier,
            instructions,
            tools,
            multi_agent,
        }
    }
}
/// The object type. Always `agent`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "agent")]
    Agent,
}

impl Default for Object {
    fn default() -> Object {
        Self::Agent
    }
}

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