diff options
| author | sigoden <sigoden@gmail.com> | 2024-11-13 18:24:43 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-13 18:24:43 +0800 |
| commit | ff0ea19b48a18e9a1849bd2a653173a3ed4e4560 (patch) | |
| tree | b8a8b9d15639649f2fa6e7dc72adcfae770bfc4e /src/function.rs | |
| parent | 163ab626cd2b8875161b2598e9400df201eacaa8 (diff) | |
| download | aichat-ff0ea19b48a18e9a1849bd2a653173a3ed4e4560.tar.gz | |
fix: invalid request on qianwen multi tool-calls (#993)
Diffstat (limited to 'src/function.rs')
| -rw-r--r-- | src/function.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/function.rs b/src/function.rs index 517b9eb..f77467b 100644 --- a/src/function.rs +++ b/src/function.rs @@ -13,8 +13,6 @@ use std::{ path::{Path, PathBuf}, }; -pub type ToolResults = (Vec<ToolResult>, String); - #[cfg(windows)] const PATH_SEP: &str = ";"; #[cfg(not(windows))] @@ -268,6 +266,29 @@ impl ToolCall { } } +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ToolResults { + pub tool_results: Vec<ToolResult>, + pub text: String, + pub sequence: bool, +} + +impl ToolResults { + pub fn new(tool_results: Vec<ToolResult>, text: String) -> Self { + Self { + tool_results, + text, + sequence: false, + } + } + + pub fn extend(&mut self, tool_results: Vec<ToolResult>, _text: String) { + self.tool_results.extend(tool_results); + self.text.clear(); + self.sequence = true; + } +} + #[cfg(windows)] fn polyfill_cmd_name<T: AsRef<Path>>(cmd_name: &str, bin_dir: &[T]) -> String { let cmd_name = cmd_name.to_string(); |
