From 3f36c5f969a7b46417613c9fd11f1760d841ff76 Mon Sep 17 00:00:00 2001 From: Eden Reich Date: Sun, 9 Feb 2025 12:21:25 +0000 Subject: [PATCH] refactor: Rename parameters to arguments in ToolFunctionResponse and update ToolCallResponse structure Signed-off-by: Eden Reich --- src/lib.rs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ee7a30e..f053e63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,20 +196,24 @@ struct GenerateRequest { tools: Option>, } -/// A tool call in the response -#[derive(Debug, Deserialize, Clone)] -pub struct ToolCallResponse { - /// Function that the LLM wants to call - pub function: ToolFunctionResponse, -} - /// Function details in a tool call response #[derive(Debug, Deserialize, Clone)] pub struct ToolFunctionResponse { /// Name of the function that the LLM wants to call pub name: String, - /// Parameters passed to the function - pub parameters: Value, + /// The arguments that the LLM wants to pass to the function + pub arguments: Value, +} + +/// A tool call in the response +#[derive(Debug, Deserialize, Clone)] +pub struct ToolCallResponse { + /// Unique identifier of the tool call + pub id: String, + /// Type of tool that was called + pub r#type: ToolType, + /// Function that the LLM wants to call + pub function: ToolFunctionResponse, } /// The content of the response @@ -1068,9 +1072,11 @@ mod tests { "content": "Let me check the weather for you.", "tool_calls": [ { + "id": "1234", + "type": "function", "function": { "name": "get_weather", - "parameters": { + "arguments": { "location": "London" } } @@ -1131,7 +1137,7 @@ mod tests { assert_eq!(tool_calls.len(), 1); assert_eq!(tool_calls[0].function.name, "get_weather"); - let params = &tool_calls[0].function.parameters; + let params = &tool_calls[0].function.arguments; assert_eq!(params["location"], "London"); mock.assert(); @@ -1186,9 +1192,11 @@ mod tests { "content": "Let me check the weather for you", "tool_calls": [ { + "id": "1234", + "type": "function", "function": { "name": "get_current_weather", - "parameters": { + "arguments": { "city": "Toronto" } }