use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct FunctionCallOutputItemResource {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "turn_id")]
pub turn_id: String,
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "status")]
pub status: models::FunctionCallStatusResource,
#[serde(rename = "output", deserialize_with = "Option::deserialize")]
pub output: Option<Box<models::FunctionCallOutputResource>>,
#[serde(rename = "error", deserialize_with = "Option::deserialize")]
pub error: Option<String>,
}
impl FunctionCallOutputItemResource {
pub fn new(
id: String,
turn_id: String,
r#type: Type,
call_id: String,
status: models::FunctionCallStatusResource,
output: Option<models::FunctionCallOutputResource>,
error: Option<String>,
) -> FunctionCallOutputItemResource {
FunctionCallOutputItemResource {
id,
turn_id,
r#type,
call_id,
status,
output: output.map(Box::new),
error,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "function_call_output")]
FunctionCallOutput,
}
impl Default for Type {
fn default() -> Type {
Self::FunctionCallOutput
}
}
impl std::fmt::Display for FunctionCallOutputItemResource {
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),
}
}
}