pub struct Tool {
pub name: String,
pub path: PathBuf,
pub language: ToolLanguage,
pub definition: ToolDefinition,
pub declaration: FunctionDeclaration,
}Expand description
Represents a single, executable tool that can be called by an LLM or user.
A Tool is loaded from a script file (e.g., Bash, Python, JavaScript) and
contains its definition, which is parsed from comments in the source code.
Fields§
§name: StringThe name of the tool, derived from its filename.
path: PathBufThe path to the tool’s source file.
language: ToolLanguageThe programming language of the tool’s script.
definition: ToolDefinitionThe detailed definition of the tool, parsed from its source code.
declaration: FunctionDeclarationThe function declaration for the LLM, generated from the ToolDefinition.
Implementations§
Source§impl Tool
impl Tool
Sourcepub async fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Loads a tool from a source file.
This function reads a file, determines its language, parses the tool
definition from its comments, and creates a Tool instance.
Sourcepub fn get_command(&self) -> Vec<String>
pub fn get_command(&self) -> Vec<String>
Returns the command and arguments needed to execute the tool.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tool
impl RefUnwindSafe for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnwindSafe for Tool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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