Skip to main content

ToolDispatch

Trait ToolDispatch 

Source
pub trait ToolDispatch: Send + Sync {
    // Required methods
    fn callable(&self) -> Vec<CallableTool>;
    fn concurrency_safe(&self, name: &str, input: &Value) -> bool;
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        input: Value,
        cancel: CancellationToken,
    ) -> Pin<Box<dyn Future<Output = Result<SubCallAnswer, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn for_command(&self, _scope: CommandScope) -> Option<Arc<dyn ToolDispatch>> { ... }
}

Required Methods§

Source

fn callable(&self) -> Vec<CallableTool>

The tools a sub-call may name.

Source

fn concurrency_safe(&self, name: &str, input: &Value) -> bool

Whether this call may run beside others of its kind.

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, input: Value, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<SubCallAnswer, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run one sub-call. A call that would need a person’s approval is refused rather than asked, except one of a plugin command that the model or a person ran in a session someone attends.

Provided Methods§

Source

fn for_command(&self, _scope: CommandScope) -> Option<Arc<dyn ToolDispatch>>

The same dispatch for one plugin command’s sub-calls. None where this dispatch cannot run a command’s calls.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§