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

/// ClientToolCallItem : Record of a client side tool invocation initiated by the assistant.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ClientToolCallItem {
    /// Identifier of the thread item.
    #[serde(rename = "id")]
    pub id: String,
    /// Type discriminator that is always `chatkit.thread_item`.
    #[serde(rename = "object")]
    pub object: Object,
    /// Unix timestamp (in seconds) for when the item was created.
    #[serde(rename = "created_at")]
    pub created_at: i32,
    /// Identifier of the parent thread.
    #[serde(rename = "thread_id")]
    pub thread_id: String,
    /// Type discriminator that is always `chatkit.client_tool_call`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "status")]
    pub status: models::ClientToolCallStatus,
    /// Identifier for the client tool call.
    #[serde(rename = "call_id")]
    pub call_id: String,
    /// Tool name that was invoked.
    #[serde(rename = "name")]
    pub name: String,
    /// JSON-encoded arguments that were sent to the tool.
    #[serde(rename = "arguments")]
    pub arguments: String,
    /// JSON-encoded output captured from the tool. Defaults to null while execution is in progress.
    #[serde(rename = "output", deserialize_with = "Option::deserialize")]
    pub output: Option<String>,
}

impl ClientToolCallItem {
    /// Record of a client side tool invocation initiated by the assistant.
    pub fn new(
        id: String,
        object: Object,
        created_at: i32,
        thread_id: String,
        r#type: Type,
        status: models::ClientToolCallStatus,
        call_id: String,
        name: String,
        arguments: String,
        output: Option<String>,
    ) -> ClientToolCallItem {
        ClientToolCallItem {
            id,
            object,
            created_at,
            thread_id,
            r#type,
            status,
            call_id,
            name,
            arguments,
            output,
        }
    }
}
/// Type discriminator that is always `chatkit.thread_item`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Object {
    #[serde(rename = "chatkit.thread_item")]
    ChatkitThreadItem,
}

impl Default for Object {
    fn default() -> Object {
        Self::ChatkitThreadItem
    }
}
/// Type discriminator that is always `chatkit.client_tool_call`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "chatkit.client_tool_call")]
    ChatkitClientToolCall,
}

impl Default for Type {
    fn default() -> Type {
        Self::ChatkitClientToolCall
    }
}

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