litellm_rs/core/models/openai/
tools.rs1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct Function {
11 pub name: String,
13 pub description: Option<String>,
15 pub parameters: Option<serde_json::Value>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct FunctionCall {
22 pub name: String,
24 pub arguments: String,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct Tool {
31 #[serde(rename = "type")]
33 pub tool_type: String,
34 pub function: Function,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum ToolChoice {
42 None(String), Auto(String), Required(String), Specific(ToolChoiceFunction),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct ToolChoiceFunction {
55 #[serde(rename = "type")]
57 pub tool_type: String,
58 pub function: ToolChoiceFunctionSpec,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct ToolChoiceFunctionSpec {
65 pub name: String,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct ToolCall {
72 pub id: String,
74 #[serde(rename = "type")]
76 pub tool_type: String,
77 pub function: FunctionCall,
79}
80
81impl From<FunctionCall> for crate::core::types::tools::FunctionCall {
82 fn from(value: FunctionCall) -> Self {
83 Self {
84 name: value.name,
85 arguments: value.arguments,
86 }
87 }
88}
89
90impl From<crate::core::types::tools::FunctionCall> for FunctionCall {
91 fn from(value: crate::core::types::tools::FunctionCall) -> Self {
92 Self {
93 name: value.name,
94 arguments: value.arguments,
95 }
96 }
97}
98
99impl From<ToolCall> for crate::core::types::tools::ToolCall {
100 fn from(value: ToolCall) -> Self {
101 Self {
102 id: value.id,
103 tool_type: value.tool_type,
104 function: value.function.into(),
105 }
106 }
107}
108
109impl From<crate::core::types::tools::ToolCall> for ToolCall {
110 fn from(value: crate::core::types::tools::ToolCall) -> Self {
111 Self {
112 id: value.id,
113 tool_type: value.tool_type,
114 function: value.function.into(),
115 }
116 }
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct FunctionCallDelta {
122 pub name: Option<String>,
124 pub arguments: Option<String>,
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130pub struct ToolCallDelta {
131 pub index: u32,
133 pub id: Option<String>,
135 #[serde(rename = "type")]
137 pub tool_type: Option<String>,
138 pub function: Option<FunctionCallDelta>,
140}