pub struct ToolSet { /* private fields */ }Expand description
A struct that holds a set of tools.
Tools are stored in an IndexMap keyed by name, so iteration
(definitions, documents, schemas) follows registration order and the tool
list sent to providers is deterministic across processes. Re-registering an
existing name replaces the implementation but keeps its original position.
Implementations§
Source§impl ToolSet
impl ToolSet
Sourcepub fn from_tools(tools: Vec<impl ToolDyn + 'static>) -> Self
pub fn from_tools(tools: Vec<impl ToolDyn + 'static>) -> Self
Create a new ToolSet from a list of tools
Sourcepub fn from_tools_boxed(tools: Vec<Box<dyn ToolDyn + 'static>>) -> Self
pub fn from_tools_boxed(tools: Vec<Box<dyn ToolDyn + 'static>>) -> Self
Create a new ToolSet from boxed dynamically-dispatched tools.
Sourcepub fn builder() -> ToolSetBuilder
pub fn builder() -> ToolSetBuilder
Create a toolset builder
Sourcepub fn contains(&self, toolname: &str) -> bool
pub fn contains(&self, toolname: &str) -> bool
Check if the toolset contains a tool with the given name
Sourcepub fn add_tool_boxed(&mut self, tool: Box<dyn ToolDyn>)
pub fn add_tool_boxed(&mut self, tool: Box<dyn ToolDyn>)
Adds a boxed tool to the toolset. Useful for situations when dynamic dispatch is required.
Sourcepub fn delete_tool(&mut self, tool_name: &str)
pub fn delete_tool(&mut self, tool_name: &str)
Remove a tool by name. Missing tools are ignored.
Sourcepub fn add_tools(&mut self, toolset: ToolSet)
pub fn add_tools(&mut self, toolset: ToolSet)
Merge another toolset into this one. Tools keep toolset’s
registration order; names that already exist are replaced in place.
Sourcepub async fn get_tool_definitions(
&self,
) -> Result<Vec<ToolDefinition>, ToolSetError>
pub async fn get_tool_definitions( &self, ) -> Result<Vec<ToolDefinition>, ToolSetError>
Return definitions for all tools currently registered in the set, in registration order.
Sourcepub async fn call(
&self,
toolname: &str,
args: String,
) -> Result<String, ToolSetError>
pub async fn call( &self, toolname: &str, args: String, ) -> Result<String, ToolSetError>
Call a tool with the given name and arguments
Sourcepub async fn documents(&self) -> Result<Vec<Document>, ToolSetError>
pub async fn documents(&self) -> Result<Vec<Document>, ToolSetError>
Get the documents of all the tools in the toolset
Sourcepub fn schemas(&self) -> Result<Vec<ToolSchema>, EmbedError>
pub fn schemas(&self) -> Result<Vec<ToolSchema>, EmbedError>
Convert tools in self to objects of type ToolSchema. This is necessary because when adding tools to the EmbeddingBuilder because all documents added to the builder must all be of the same type.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToolSet
impl !UnwindSafe for ToolSet
impl Freeze for ToolSet
impl Send for ToolSet
impl Sync for ToolSet
impl Unpin for ToolSet
impl UnsafeUnpin for ToolSet
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more