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

/// TaskItem : Task emitted by the workflow to show progress and status updates.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TaskItem {
    /// 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.task`.
    #[serde(rename = "type")]
    pub r#type: Type,
    #[serde(rename = "task_type")]
    pub task_type: models::TaskType,
    /// Optional heading for the task. Defaults to null when not provided.
    #[serde(rename = "heading", deserialize_with = "Option::deserialize")]
    pub heading: Option<String>,
    /// Optional summary that describes the task. Defaults to null when omitted.
    #[serde(rename = "summary", deserialize_with = "Option::deserialize")]
    pub summary: Option<String>,
}

impl TaskItem {
    /// Task emitted by the workflow to show progress and status updates.
    pub fn new(
        id: String,
        object: Object,
        created_at: i32,
        thread_id: String,
        r#type: Type,
        task_type: models::TaskType,
        heading: Option<String>,
        summary: Option<String>,
    ) -> TaskItem {
        TaskItem {
            id,
            object,
            created_at,
            thread_id,
            r#type,
            task_type,
            heading,
            summary,
        }
    }
}
/// 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.task`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
    #[serde(rename = "chatkit.task")]
    ChatkitTask,
}

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

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