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/agent.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/config/agent.rs') diff --git a/src/config/agent.rs b/src/config/agent.rs index c7ff9ad..a6257ca 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -1,9 +1,6 @@ use super::*; -use crate::{ - client::Model, - function::{Functions, FunctionsFilter, SELECTED_ALL_FUNCTIONS}, -}; +use crate::{client::Model, function::Functions}; use anyhow::{Context, Result}; use std::{fs::read_to_string, path::Path}; @@ -150,11 +147,12 @@ impl RoleLike for Agent { self.config.top_p } - fn functions_filter(&self) -> Option { - if self.functions.is_empty() { + fn use_tools(&self) -> Option { + let common_tools = &self.definition.common_tools; + if common_tools.is_empty() { None } else { - Some(SELECTED_ALL_FUNCTIONS.into()) + Some(common_tools.join(",")) } } @@ -171,7 +169,7 @@ impl RoleLike for Agent { self.config.top_p = value; } - fn set_functions_filter(&mut self, _value: Option) {} + fn set_use_tools(&mut self, _value: Option) {} } #[derive(Debug, Clone, Default, Deserialize, Serialize)] @@ -184,7 +182,7 @@ pub struct AgentConfig { #[serde(skip_serializing_if = "Option::is_none")] pub top_p: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub dangerously_functions_filter: Option, + pub dangerously_functions_filter: Option, } impl AgentConfig { @@ -208,6 +206,8 @@ pub struct AgentDefinition { pub conversation_starters: Vec, #[serde(default)] pub documents: Vec, + #[serde(default)] + pub common_tools: Vec, } impl AgentDefinition { -- cgit v1.2.3