diff --git a/config.example.yaml b/config.example.yaml index d040c66..7c87ade 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -23,7 +23,7 @@ function_calling: false # Regex for seletecting dangerous functions. # User confirmation is required when executing these functions. # e.g. 'execute_command|execute_js_code' 'execute_.*' -dangerously_functions: null +dangerously_functions_filter: null bot_prelude: null # Set a session to use when starting a bot. (e.g. temp, default) @@ -32,7 +32,7 @@ bots: model: null temperature: null top_p: null - dangerously_functions: null + dangerously_functions_filter: null # Specifies the embedding model to use embedding_model: null diff --git a/src/config/bot.rs b/src/config/bot.rs index a0ea58a..4823d2e 100644 --- a/src/config/bot.rs +++ b/src/config/bot.rs @@ -141,7 +141,7 @@ impl RoleLike for Bot { self.config.top_p } - fn selected_functions(&self) -> Option { + fn functions_filter(&self) -> Option { if self.functions.is_empty() { None } else { @@ -162,7 +162,7 @@ impl RoleLike for Bot { self.config.top_p = value; } - fn set_selected_functions(&mut self, _value: Option) {} + fn set_functions_filter(&mut self, _value: Option) {} } #[derive(Debug, Clone, Default, Deserialize, Serialize)] @@ -175,7 +175,7 @@ pub struct BotConfig { #[serde(skip_serializing_if = "Option::is_none")] pub top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub dangerously_functions: Option, + pub dangerously_functions_filter: Option, } impl BotConfig { diff --git a/src/config/mod.rs b/src/config/mod.rs index 22eaa2e..e348d85 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -92,7 +92,7 @@ pub struct Config { pub repl_prelude: Option, pub buffer_editor: Option, pub function_calling: bool, - pub dangerously_functions: Option, + pub dangerously_functions_filter: Option, pub bot_prelude: Option, pub bots: Vec, pub embedding_model: Option, @@ -143,7 +143,7 @@ impl Default for Config { repl_prelude: None, buffer_editor: None, function_calling: false, - dangerously_functions: None, + dangerously_functions_filter: None, bot_prelude: None, bots: vec![], embedding_model: None, @@ -962,7 +962,7 @@ impl Config { pub fn select_functions(&self, model: &Model, role: &Role) -> Option> { let mut functions = None; if self.function_calling { - let filter = role.selected_functions(); + let filter = role.functions_filter(); if let Some(filter) = filter { functions = match &self.bot { Some(bot) => bot.functions().select(&filter), @@ -983,11 +983,11 @@ impl Config { if get_env_bool("no_dangerously_functions") { return false; } - let dangerously_functions = match &self.bot { - Some(bot) => bot.config().dangerously_functions.as_ref(), - None => self.dangerously_functions.as_ref(), + let dangerously_functions_filter = match &self.bot { + Some(bot) => bot.config().dangerously_functions_filter.as_ref(), + None => self.dangerously_functions_filter.as_ref(), }; - match dangerously_functions { + match dangerously_functions_filter { None => false, Some(regex) => { let regex = match Regex::new(&format!("^({regex})$")) { diff --git a/src/config/role.rs b/src/config/role.rs index b6b7fc8..5b52587 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -20,11 +20,11 @@ pub trait RoleLike { fn model(&self) -> &Model; fn temperature(&self) -> Option; fn top_p(&self) -> Option; - fn selected_functions(&self) -> Option; + fn functions_filter(&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_selected_functions(&mut self, value: Option); + fn set_functions_filter(&mut self, value: Option); } #[derive(Debug, Clone, Default, Deserialize, Serialize)] @@ -42,7 +42,7 @@ pub struct Role { #[serde(skip_serializing_if = "Option::is_none")] top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - selected_functions: Option, + functions_filter: Option, #[serde(skip)] model: Model, @@ -91,10 +91,10 @@ async function timeout(ms) { ), ] .into_iter() - .map(|(name, prompt, selected_functions)| Self { + .map(|(name, prompt, functions_filter)| Self { name: name.into(), prompt, - selected_functions, + functions_filter, ..Default::default() }) .collect() @@ -110,8 +110,8 @@ async function timeout(ms) { let model = role_like.model(); let temperature = role_like.temperature(); let top_p = role_like.top_p(); - let selected_functions = role_like.selected_functions(); - self.batch_set(model, temperature, top_p, selected_functions); + let functions_filter = role_like.functions_filter(); + self.batch_set(model, temperature, top_p, functions_filter); } pub fn batch_set( @@ -119,7 +119,7 @@ async function timeout(ms) { model: &Model, temperature: Option, top_p: Option, - selected_functions: Option, + functions_filter: Option, ) { self.set_model(model); if temperature.is_some() { @@ -128,8 +128,8 @@ async function timeout(ms) { if top_p.is_some() { self.set_top_p(top_p); } - if selected_functions.is_some() { - self.set_selected_functions(selected_functions); + if functions_filter.is_some() { + self.set_functions_filter(functions_filter); } } @@ -230,8 +230,8 @@ impl RoleLike for Role { self.top_p } - fn selected_functions(&self) -> Option { - self.selected_functions.clone() + fn functions_filter(&self) -> Option { + self.functions_filter.clone() } fn set_model(&mut self, model: &Model) { @@ -247,8 +247,8 @@ impl RoleLike for Role { self.top_p = value; } - fn set_selected_functions(&mut self, value: Option) { - self.selected_functions = value; + fn set_functions_filter(&mut self, value: Option) { + self.functions_filter = value; } } diff --git a/src/config/session.rs b/src/config/session.rs index 62ba93c..ce9dc7b 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -21,7 +21,7 @@ pub struct Session { #[serde(skip_serializing_if = "Option::is_none")] top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - selected_functions: Option, + functions_filter: Option, #[serde(skip_serializing_if = "Option::is_none")] save_session: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -139,8 +139,8 @@ impl Session { if let Some(top_p) = self.top_p() { data["top_p"] = top_p.into(); } - if let Some(selected_functions) = self.selected_functions() { - data["selected_functions"] = selected_functions.into(); + if let Some(functions_filter) = self.functions_filter() { + data["functions_filter"] = functions_filter.into(); } if let Some(save_session) = self.save_session() { data["save_session"] = save_session.into(); @@ -176,8 +176,8 @@ impl Session { items.push(("top_p", top_p.to_string())); } - if let Some(selected_functions) = self.selected_functions() { - items.push(("selected_functions", selected_functions)); + if let Some(functions_filter) = self.functions_filter() { + items.push(("functions_filter", functions_filter)); } if let Some(save_session) = self.save_session() { @@ -251,7 +251,7 @@ impl Session { self.model_id = role.model().id(); self.temperature = role.temperature(); self.top_p = role.top_p(); - self.selected_functions = role.selected_functions(); + self.functions_filter = role.functions_filter(); self.model = role.model().clone(); self.role_name = role.name().to_string(); self.role_prompt = role.prompt().to_string(); @@ -418,8 +418,8 @@ impl RoleLike for Session { self.top_p } - fn selected_functions(&self) -> Option { - self.selected_functions.clone() + fn functions_filter(&self) -> Option { + self.functions_filter.clone() } fn set_model(&mut self, model: &Model) { @@ -444,9 +444,9 @@ impl RoleLike for Session { } } - fn set_selected_functions(&mut self, value: Option) { - if self.selected_functions != value { - self.selected_functions = value; + fn set_functions_filter(&mut self, value: Option) { + if self.functions_filter != value { + self.functions_filter = value; self.dirty = true; } }