pub struct CombinedToolset<Deps = ()> { /* private fields */ }Expand description
Combines multiple toolsets into one.
This allows treating multiple toolsets as a single collection. It handles name conflicts by returning an error with helpful hints.
§Example
ⓘ
use serdes_ai_toolsets::{CombinedToolset, FunctionToolset};
let toolset1 = FunctionToolset::with_id("tools1").tool(tool_a);
let toolset2 = FunctionToolset::with_id("tools2").tool(tool_b);
let combined = CombinedToolset::new()
.with_toolset(toolset1)
.with_toolset(toolset2);Implementations§
Source§impl<Deps> CombinedToolset<Deps>
impl<Deps> CombinedToolset<Deps>
Sourcepub fn new() -> CombinedToolset<Deps>
pub fn new() -> CombinedToolset<Deps>
Create a new empty combined toolset.
Sourcepub fn with_id(id: impl Into<String>) -> CombinedToolset<Deps>
pub fn with_id(id: impl Into<String>) -> CombinedToolset<Deps>
Create a combined toolset with an ID.
Sourcepub fn with_toolset<T>(self, toolset: T) -> CombinedToolset<Deps>where
T: AbstractToolset<Deps> + 'static,
pub fn with_toolset<T>(self, toolset: T) -> CombinedToolset<Deps>where
T: AbstractToolset<Deps> + 'static,
Add a toolset.
Sourcepub fn add_boxed(
self,
toolset: Box<dyn AbstractToolset<Deps>>,
) -> CombinedToolset<Deps>
pub fn add_boxed( self, toolset: Box<dyn AbstractToolset<Deps>>, ) -> CombinedToolset<Deps>
Add a boxed toolset.
Sourcepub fn toolsets<I, T>(self, toolsets: I) -> CombinedToolset<Deps>where
I: IntoIterator<Item = T>,
T: AbstractToolset<Deps> + 'static,
pub fn toolsets<I, T>(self, toolsets: I) -> CombinedToolset<Deps>where
I: IntoIterator<Item = T>,
T: AbstractToolset<Deps> + 'static,
Add multiple toolsets.
Sourcepub fn toolset_count(&self) -> usize
pub fn toolset_count(&self) -> usize
Get the number of contained toolsets.
Trait Implementations§
Source§impl<Deps> AbstractToolset<Deps> for CombinedToolset<Deps>
impl<Deps> AbstractToolset<Deps> for CombinedToolset<Deps>
Source§fn tool_name_conflict_hint(&self) -> String
fn tool_name_conflict_hint(&self) -> String
Hint for resolving name conflicts.
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
'life0: 'async_trait,
'life1: 'async_trait,
CombinedToolset<Deps>: '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
'life0: 'async_trait,
'life1: 'async_trait,
CombinedToolset<Deps>: 'async_trait,
Get all available tools. Read more
Source§fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: Value,
ctx: &'life2 RunContext<Deps>,
tool: &'life3 ToolsetTool,
) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
CombinedToolset<Deps>: 'async_trait,
fn call_tool<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
name: &'life1 str,
args: Value,
ctx: &'life2 RunContext<Deps>,
tool: &'life3 ToolsetTool,
) -> Pin<Box<dyn Future<Output = Result<ToolReturn, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
CombinedToolset<Deps>: '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
'life0: 'async_trait,
CombinedToolset<Deps>: 'async_trait,
fn enter<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
CombinedToolset<Deps>: 'async_trait,
Enter context (for resource setup). Read more
Source§impl<Deps> Debug for CombinedToolset<Deps>
impl<Deps> Debug for CombinedToolset<Deps>
Source§impl<Deps> Default for CombinedToolset<Deps>
impl<Deps> Default for CombinedToolset<Deps>
Source§fn default() -> CombinedToolset<Deps>
fn default() -> CombinedToolset<Deps>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<Deps> Freeze for CombinedToolset<Deps>
impl<Deps = ()> !RefUnwindSafe for CombinedToolset<Deps>
impl<Deps> Send for CombinedToolset<Deps>
impl<Deps> Sync for CombinedToolset<Deps>
impl<Deps> Unpin for CombinedToolset<Deps>
impl<Deps = ()> !UnwindSafe for CombinedToolset<Deps>
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