pub struct FilteredToolset<T, F, Deps = ()> { /* private fields */ }Expand description
Filters tools from a toolset based on a predicate.
Only tools where the filter function returns true will be available.
§Example
ⓘ
use serdes_ai_toolsets::{FilteredToolset, FunctionToolset};
let toolset = FunctionToolset::new()
.tool(tool_a)
.tool(dangerous_tool);
// Only allow non-dangerous tools
let filtered = FilteredToolset::new(toolset, |_ctx, def| {
!def.name.contains("dangerous")
});Implementations§
Source§impl<T, F, Deps> FilteredToolset<T, F, Deps>
impl<T, F, Deps> FilteredToolset<T, F, Deps>
Trait Implementations§
Source§impl<T, F, Deps> AbstractToolset<Deps> for FilteredToolset<T, F, Deps>where
T: AbstractToolset<Deps>,
F: Fn(&RunContext<Deps>, &ToolDefinition) -> bool + Send + Sync,
Deps: Send + Sync,
impl<T, F, Deps> AbstractToolset<Deps> for FilteredToolset<T, F, Deps>where
T: AbstractToolset<Deps>,
F: Fn(&RunContext<Deps>, &ToolDefinition) -> bool + Send + Sync,
Deps: Send + Sync,
Source§fn get_tools<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 RunContext<Deps>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, ToolsetTool>, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tools<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 RunContext<Deps>,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, ToolsetTool>, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all available tools. Read more
Source§fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: JsonValue,
ctx: &'life2 RunContext<Deps>,
tool: &'life3 ToolsetTool,
) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: JsonValue,
ctx: &'life2 RunContext<Deps>,
tool: &'life3 ToolsetTool,
) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Call a tool by name.
Source§fn enter<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn enter<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Enter context (for resource setup). Read more
Source§fn exit<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exit<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Exit context (for cleanup). Read more
Source§fn tool_name_conflict_hint(&self) -> String
fn tool_name_conflict_hint(&self) -> String
Hint for resolving name conflicts.
Auto Trait Implementations§
impl<T, F, Deps> Freeze for FilteredToolset<T, F, Deps>
impl<T, F, Deps> RefUnwindSafe for FilteredToolset<T, F, Deps>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F, Deps> Send for FilteredToolset<T, F, Deps>
impl<T, F, Deps> Sync for FilteredToolset<T, F, Deps>
impl<T, F, Deps> Unpin for FilteredToolset<T, F, Deps>
impl<T, F, Deps> UnwindSafe for FilteredToolset<T, F, Deps>where
T: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more