From 638bf3276613265da761b4d74f269fa77c8f4bb1 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 17 Jun 2024 09:14:54 +0800 Subject: refactor: improve code quatity (#604) --- src/function.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/function.rs') diff --git a/src/function.rs b/src/function.rs index b2833e8..bab8ca9 100644 --- a/src/function.rs +++ b/src/function.rs @@ -16,13 +16,10 @@ use std::{ }; pub const SELECTED_ALL_FUNCTIONS: &str = ".*"; -pub type ToolResults = (Vec, String); +pub type ToolResults = (Vec, String); pub type FunctionsFilter = String; -pub fn eval_tool_calls( - config: &GlobalConfig, - mut calls: Vec, -) -> Result> { +pub fn eval_tool_calls(config: &GlobalConfig, mut calls: Vec) -> Result> { let mut output = vec![]; if calls.is_empty() { return Ok(output); @@ -33,22 +30,22 @@ pub fn eval_tool_calls( } for call in calls { let result = call.eval(config)?; - output.push(ToolCallResult::new(call, result)); + output.push(ToolResult::new(call, result)); } Ok(output) } -pub fn need_send_call_results(arr: &[ToolCallResult]) -> bool { +pub fn need_send_tool_results(arr: &[ToolResult]) -> bool { arr.iter().any(|v| !v.output.is_null()) } #[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ToolCallResult { +pub struct ToolResult { pub call: ToolCall, pub output: Value, } -impl ToolCallResult { +impl ToolResult { pub fn new(call: ToolCall, output: Value) -> Self { Self { call, output } } -- cgit v1.2.3