use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Function {
pub name: String,
pub description: Option<String>,
pub parameters: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionCall {
pub name: String,
pub arguments: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tool {
#[serde(rename = "type")]
pub tool_type: String,
pub function: Function,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ToolChoice {
None(String), Auto(String), Required(String), Specific(ToolChoiceFunction),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolChoiceFunction {
#[serde(rename = "type")]
pub tool_type: String,
pub function: ToolChoiceFunctionSpec,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolChoiceFunctionSpec {
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCall {
pub id: String,
#[serde(rename = "type")]
pub tool_type: String,
pub function: FunctionCall,
}
impl From<FunctionCall> for crate::core::types::tools::FunctionCall {
fn from(value: FunctionCall) -> Self {
Self {
name: value.name,
arguments: value.arguments,
}
}
}
impl From<crate::core::types::tools::FunctionCall> for FunctionCall {
fn from(value: crate::core::types::tools::FunctionCall) -> Self {
Self {
name: value.name,
arguments: value.arguments,
}
}
}
impl From<ToolCall> for crate::core::types::tools::ToolCall {
fn from(value: ToolCall) -> Self {
Self {
id: value.id,
tool_type: value.tool_type,
function: value.function.into(),
}
}
}
impl From<crate::core::types::tools::ToolCall> for ToolCall {
fn from(value: crate::core::types::tools::ToolCall) -> Self {
Self {
id: value.id,
tool_type: value.tool_type,
function: value.function.into(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionCallDelta {
pub name: Option<String>,
pub arguments: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolCallDelta {
pub index: u32,
pub id: Option<String>,
#[serde(rename = "type")]
pub tool_type: Option<String>,
pub function: Option<FunctionCallDelta>,
}