AgentTool

Trait AgentTool 

Source
pub trait AgentTool<TCtx>: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn description(&self) -> String;
    fn parameters(&self) -> JSONSchema;
    fn execute<'a>(
        &'a self,
        args: Value,
        context: &'a TCtx,
        state: &'a RunState,
    ) -> BoxFuture<'a, Result<AgentToolResult, Box<dyn Error + Send + Sync>>>;
}
Expand description

Agent tool that can be used by the agent to perform specific tasks. Any type that implements the AgentTool trait can be used as a tool.

Required Methods§

Source

fn name(&self) -> String

Name of the tool.

Source

fn description(&self) -> String

A description of the tool to instruct the model how and when to use it.

Source

fn parameters(&self) -> JSONSchema

The JSON schema of the parameters that the tool accepts. The type must be “object”.

Source

fn execute<'a>( &'a self, args: Value, context: &'a TCtx, state: &'a RunState, ) -> BoxFuture<'a, Result<AgentToolResult, Box<dyn Error + Send + Sync>>>

The function that will be called to execute the tool with given parameters and context.

If the tool throws an error, the agent will be interrupted and the error will be propagated. To avoid interrupting the agent, the tool must return an AgentToolResult with is_error set to true.

Trait Implementations§

Source§

impl<TCtx> Debug for dyn AgentTool<TCtx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<TCtx> From<&dyn AgentTool<TCtx>> for Tool

Source§

fn from(agent_tool: &dyn AgentTool<TCtx>) -> Self

Converts to this type from the input type.

Implementors§