use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct CodeInterpreterToolCall {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "status")]
pub status: Status,
#[serde(rename = "container_id")]
pub container_id: String,
#[serde(rename = "code", deserialize_with = "Option::deserialize")]
pub code: Option<String>,
#[serde(rename = "outputs", deserialize_with = "Option::deserialize")]
pub outputs: Option<Vec<models::CodeInterpreterToolCallOutputsInner>>,
}
impl CodeInterpreterToolCall {
pub fn new(
r#type: Type,
id: String,
status: Status,
container_id: String,
code: Option<String>,
outputs: Option<Vec<models::CodeInterpreterToolCallOutputsInner>>,
) -> CodeInterpreterToolCall {
CodeInterpreterToolCall {
r#type,
id,
status,
container_id,
code,
outputs,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "code_interpreter_call")]
CodeInterpreterCall,
}
impl Default for Type {
fn default() -> Type {
Self::CodeInterpreterCall
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "incomplete")]
Incomplete,
#[serde(rename = "interpreting")]
Interpreting,
#[serde(rename = "failed")]
Failed,
}
impl Default for Status {
fn default() -> Status {
Self::InProgress
}
}
impl std::fmt::Display for CodeInterpreterToolCall {
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),
}
}
}