use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaCustomToolCall {
#[serde(
rename = "agent",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub agent: Option<Option<Box<models::BetaAgentTag>>>,
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(
rename = "caller",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub caller: Option<Option<Box<models::BetaToolCallCaller>>>,
#[serde(rename = "namespace", skip_serializing_if = "Option::is_none")]
pub namespace: Option<String>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "input")]
pub input: String,
#[serde(rename = "async", skip_serializing_if = "Option::is_none")]
pub r#async: Option<bool>,
}
impl BetaCustomToolCall {
pub fn new(r#type: Type, call_id: String, name: String, input: String) -> BetaCustomToolCall {
BetaCustomToolCall {
agent: None,
r#type,
id: None,
call_id,
caller: None,
namespace: None,
name,
input,
r#async: None,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "custom_tool_call")]
CustomToolCall,
}
impl Default for Type {
fn default() -> Type {
Self::CustomToolCall
}
}
impl std::fmt::Display for BetaCustomToolCall {
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),
}
}
}