use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionCallItemResource {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "turn_id")]
pub turn_id: String,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "arguments", deserialize_with = "Option::deserialize")]
pub arguments: Option<serde_json::Value>,
#[serde(rename = "status")]
pub status: models::FunctionCallStatusResource,
}
impl FunctionCallItemResource {
pub fn new(
r#type: Type,
id: String,
turn_id: String,
call_id: String,
name: String,
arguments: Option<serde_json::Value>,
status: models::FunctionCallStatusResource,
) -> FunctionCallItemResource {
FunctionCallItemResource {
r#type,
id,
turn_id,
call_id,
name,
arguments,
status,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "function_call")]
FunctionCall,
}
impl Default for Type {
fn default() -> Type {
Self::FunctionCall
}
}
impl std::fmt::Display for FunctionCallItemResource {
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),
}
}
}