From 8b0c648a73dc812b0fd22a60a2975de57b7dd02c Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 5 Jul 2024 19:49:08 +0800 Subject: feat: enhenced flexibility for use tools (#688) --- src/config/role.rs | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'src/config/role.rs') diff --git a/src/config/role.rs b/src/config/role.rs index 29d3f3b..3fc7696 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -2,7 +2,6 @@ use super::*; use crate::{ client::{Message, MessageContent, MessageRole, Model}, - function::{FunctionsFilter, SELECTED_ALL_FUNCTIONS}, utils::{detect_os, detect_shell}, }; @@ -21,11 +20,11 @@ pub trait RoleLike { fn model_mut(&mut self) -> &mut Model; fn temperature(&self) -> Option; fn top_p(&self) -> Option; - fn functions_filter(&self) -> Option; + fn use_tools(&self) -> Option; fn set_model(&mut self, model: &Model); fn set_temperature(&mut self, value: Option); fn set_top_p(&mut self, value: Option); - fn set_functions_filter(&mut self, value: Option); + fn set_use_tools(&mut self, value: Option); } #[derive(Debug, Clone, Default, Deserialize, Serialize)] @@ -43,7 +42,7 @@ pub struct Role { #[serde(skip_serializing_if = "Option::is_none")] top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - functions_filter: Option, + use_tools: Option, #[serde(skip)] model: Model, @@ -85,17 +84,13 @@ async function timeout(ms) { .into(), None, ), - ( - "%functions%", - String::new(), - Some(SELECTED_ALL_FUNCTIONS.into()), - ), + ("%functions%", String::new(), Some("all".into())), ] .into_iter() - .map(|(name, prompt, functions_filter)| Self { + .map(|(name, prompt, use_tools)| Self { name: name.into(), prompt, - functions_filter, + use_tools, ..Default::default() }) .collect() @@ -111,8 +106,8 @@ async function timeout(ms) { let model = role_like.model(); let temperature = role_like.temperature(); let top_p = role_like.top_p(); - let functions_filter = role_like.functions_filter(); - self.batch_set(model, temperature, top_p, functions_filter); + let use_tools = role_like.use_tools(); + self.batch_set(model, temperature, top_p, use_tools); } pub fn batch_set( @@ -120,7 +115,7 @@ async function timeout(ms) { model: &Model, temperature: Option, top_p: Option, - functions_filter: Option, + use_tools: Option, ) { self.set_model(model); if temperature.is_some() { @@ -129,8 +124,8 @@ async function timeout(ms) { if top_p.is_some() { self.set_top_p(top_p); } - if functions_filter.is_some() { - self.set_functions_filter(functions_filter); + if use_tools.is_some() { + self.set_use_tools(use_tools); } } @@ -242,8 +237,8 @@ impl RoleLike for Role { self.top_p } - fn functions_filter(&self) -> Option { - self.functions_filter.clone() + fn use_tools(&self) -> Option { + self.use_tools.clone() } fn set_model(&mut self, model: &Model) { @@ -258,8 +253,8 @@ impl RoleLike for Role { self.top_p = value; } - fn set_functions_filter(&mut self, value: Option) { - self.functions_filter = value; + fn set_use_tools(&mut self, value: Option) { + self.use_tools = value; } } -- cgit v1.2.3