pub struct FunctionToolset<Deps = ()> { /* private fields */ }Expand description
A toolset backed by function-based tools.
This wraps a ToolRegistry and provides the AbstractToolset interface.
§Example
ⓘ
use serdes_ai_toolsets::FunctionToolset;
use serdes_ai_tools::{SyncFunctionTool, ObjectJsonSchema};
let toolset = FunctionToolset::new()
.with_id("my_tools")
.tool(my_tool)
.tool(another_tool);Implementations§
Source§impl<Deps> FunctionToolset<Deps>
impl<Deps> FunctionToolset<Deps>
Sourcepub fn with_max_retries(self, retries: u32) -> Self
pub fn with_max_retries(self, retries: u32) -> Self
Set the default max retries for tools.
Sourcepub fn tools<I, T>(self, tools: I) -> Selfwhere
I: IntoIterator<Item = T>,
T: Tool<Deps> + 'static,
pub fn tools<I, T>(self, tools: I) -> Selfwhere
I: IntoIterator<Item = T>,
T: Tool<Deps> + 'static,
Add multiple tools to the toolset.
Sourcepub fn registry(&self) -> &ToolRegistry<Deps>
pub fn registry(&self) -> &ToolRegistry<Deps>
Get the underlying registry.
Sourcepub fn registry_mut(&mut self) -> &mut ToolRegistry<Deps>
pub fn registry_mut(&mut self) -> &mut ToolRegistry<Deps>
Get mutable access to the registry.
Trait Implementations§
Source§impl<Deps: Send + Sync + 'static> AbstractToolset<Deps> for FunctionToolset<Deps>
impl<Deps: Send + Sync + 'static> AbstractToolset<Deps> for FunctionToolset<Deps>
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 tool_name_conflict_hint(&self) -> String
fn tool_name_conflict_hint(&self) -> String
Hint for resolving name conflicts.
Source§impl<Deps> Debug for FunctionToolset<Deps>
impl<Deps> Debug for FunctionToolset<Deps>
Auto Trait Implementations§
impl<Deps> Freeze for FunctionToolset<Deps>
impl<Deps = ()> !RefUnwindSafe for FunctionToolset<Deps>
impl<Deps> Send for FunctionToolset<Deps>
impl<Deps> Sync for FunctionToolset<Deps>
impl<Deps> Unpin for FunctionToolset<Deps>
impl<Deps = ()> !UnwindSafe for FunctionToolset<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