pub struct ToolSet { /* private fields */ }Expand description
Insertion-ordered named tool registrations and their advertisement policy. Direct execution is inline; hosts may install the registrations in a table.
Implementations§
Source§impl ToolSet
impl ToolSet
Sourcepub fn from_tools<T>(tools: Vec<T>) -> Selfwhere
T: Tool + 'static,
pub fn from_tools<T>(tools: Vec<T>) -> Selfwhere
T: Tool + 'static,
A set from typed tools.
Sourcepub fn add_tool<T>(&mut self, tool: T) -> Stringwhere
T: Tool + 'static,
pub fn add_tool<T>(&mut self, tool: T) -> Stringwhere
T: Tool + 'static,
Register a typed tool; returns its name.
Sourcepub fn add_dynamic_tool(&mut self, tool: DynamicTool) -> String
pub fn add_dynamic_tool(&mut self, tool: DynamicTool) -> String
Register a runtime-defined tool; returns its name.
Sourcepub fn add_retrieved_tool<T>(&mut self, tool: T) -> Result<String, Error>where
T: ToolEmbedding + 'static,
pub fn add_retrieved_tool<T>(&mut self, tool: T) -> Result<String, Error>where
T: ToolEmbedding + 'static,
Register a retrievable tool; returns its name. A context that does not serialize is the error, and nothing is registered.
Sourcepub fn add_registered_tool(&mut self, tool: RegisteredTool) -> String
pub fn add_registered_tool(&mut self, tool: RegisteredTool) -> String
Register an already-built registration; returns its name.
Sourcepub fn remove_tool(&mut self, name: &str)
pub fn remove_tool(&mut self, name: &str)
Remove the tool named name.
Sourcepub fn add_retrievable_tools(&mut self, set: ToolSet)
pub fn add_retrievable_tools(&mut self, set: ToolSet)
Merge set’s registrations as retrieval-only (not always exposed).
Sourcepub fn get(&self, name: &str) -> Option<&RegisteredTool>
pub fn get(&self, name: &str) -> Option<&RegisteredTool>
The registration named name.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &RegisteredTool)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &RegisteredTool)>
Every registration, in insertion order.
Sourcepub fn always_exposed_names(&self) -> impl Iterator<Item = &str>
pub fn always_exposed_names(&self) -> impl Iterator<Item = &str>
Names advertised on every request.
Sourcepub fn catalog(&self) -> ToolCatalog
pub fn catalog(&self) -> ToolCatalog
The always-exposed registrations as a catalog.
Sourcepub fn tool_definitions(&self) -> Vec<Arc<ToolDefinition>>
pub fn tool_definitions(&self) -> Vec<Arc<ToolDefinition>>
Every definition, in insertion order.
Sourcepub async fn execute(
&self,
name: &str,
args: impl Into<String>,
context: &mut ToolContext,
) -> ToolResult
pub async fn execute( &self, name: &str, args: impl Into<String>, context: &mut ToolContext, ) -> ToolResult
Run the tool named name inline (RegisteredTool::execute),
publishing its result metadata into context; a name nothing is
registered under is a not_found failure, with no metadata.
Sourcepub fn schemas(&self) -> Result<Vec<ToolSchema>, EmbedError>
pub fn schemas(&self) -> Result<Vec<ToolSchema>, EmbedError>
The embedding schemas of the retrievable registrations.