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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct ChatCompletionRequestToolMessage {
    /// The role of the messages author, in this case `tool`.
    #[serde(rename = "role")]
    pub role: Role,
    #[serde(rename = "content")]
    pub content: Box<models::ChatCompletionRequestToolMessageContent>,
    /// Tool call that this message is responding to.
    #[serde(rename = "tool_call_id")]
    pub tool_call_id: String,
}

impl ChatCompletionRequestToolMessage {
    pub fn new(
        role: Role,
        content: models::ChatCompletionRequestToolMessageContent,
        tool_call_id: String,
    ) -> ChatCompletionRequestToolMessage {
        ChatCompletionRequestToolMessage {
            role,
            content: Box::new(content),
            tool_call_id,
        }
    }
}
/// The role of the messages author, in this case `tool`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Role {
    #[serde(rename = "tool")]
    Tool,
}

impl Default for Role {
    fn default() -> Role {
        Self::Tool
    }
}

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