pub struct ExternalToolset<Deps = ()> { /* private fields */ }Expand description
Toolset for externally-executed tools.
This is used when tools need to be exposed to the model but will be
executed by an external system. When any tool is called, it returns
ToolError::CallDeferred so the agent knows to defer execution.
§Example
ⓘ
use serdes_ai_toolsets::ExternalToolset;
use serdes_ai_tools::ToolDefinition;
let external = ExternalToolset::new()
.with_id("external_api")
.definition(ToolDefinition::new("api_call", "Call external API"));Implementations§
Source§impl<Deps> ExternalToolset<Deps>
impl<Deps> ExternalToolset<Deps>
Sourcepub fn with_max_retries(self, retries: u32) -> Self
pub fn with_max_retries(self, retries: u32) -> Self
Set max retries.
Sourcepub fn definition(self, def: ToolDefinition) -> Self
pub fn definition(self, def: ToolDefinition) -> Self
Add a tool definition.
Sourcepub fn definitions(self, defs: impl IntoIterator<Item = ToolDefinition>) -> Self
pub fn definitions(self, defs: impl IntoIterator<Item = ToolDefinition>) -> Self
Add multiple tool definitions.
Trait Implementations§
Source§impl<Deps: Send + Sync> AbstractToolset<Deps> for ExternalToolset<Deps>
impl<Deps: Send + Sync> AbstractToolset<Deps> for ExternalToolset<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 ExternalToolset<Deps>
impl<Deps> Debug for ExternalToolset<Deps>
Auto Trait Implementations§
impl<Deps> Freeze for ExternalToolset<Deps>
impl<Deps> RefUnwindSafe for ExternalToolset<Deps>
impl<Deps> Send for ExternalToolset<Deps>
impl<Deps> Sync for ExternalToolset<Deps>
impl<Deps> Unpin for ExternalToolset<Deps>
impl<Deps> UnwindSafe for ExternalToolset<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