Skip to main content

Tool

Trait Tool 

Source
pub trait Tool:
    Send
    + Sync
    + 'static {
    type Arguments: JsonSchema + DeserializeOwned + LLMSafe + Send + Sync + 'static;

    const NAME: &'static str;
    const DESCRIPTION: &'static str;

    // Required method
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx_request: &'life1 ContextRequest,
        args: Self::Arguments,
    ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn is_available<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx_request: &'life1 ContextRequest,
        _compiled_context: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}

Required Associated Constants§

Source

const NAME: &'static str

Source

const DESCRIPTION: &'static str

Required Associated Types§

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx_request: &'life1 ContextRequest, args: Self::Arguments, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes the tool. The result is serialized and fed back to the LLM.

Provided Methods§

Source

fn is_available<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx_request: &'life1 ContextRequest, _compiled_context: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<bool, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Evaluated dynamically every turn AFTER the ContextProviders have compiled the World State. compiled_context is the JSON value generated by all ContextProviders that the LLM is about to see.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§