Skip to main content

AsyncFunctionRegistry

Trait AsyncFunctionRegistry 

Source
pub trait AsyncFunctionRegistry: Send + Sync {
    type Function: Send + Sync;
    type CallResult: Send + Sync;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn register<'life0, 'async_trait>(
        &'life0 mut self,
        name: String,
        function: Self::Function,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Self::CallResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list_functions<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn has_function<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_function_info<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<FunctionInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn call_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        calls: &'life1 [(&'life2 str, &'life3 str)],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::CallResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn validate_args<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Async function calling abstraction for non-blocking tool usage

§Async Version

This trait provides async operations for function calling with better concurrency for tool usage.

Required Associated Types§

Source

type Function: Send + Sync

The function type this registry handles

Source

type CallResult: Send + Sync

The result type returned by function calls

Source

type Error: Error + Send + Sync + 'static

The error type returned by function operations

Required Methods§

Source

fn register<'life0, 'async_trait>( &'life0 mut self, name: String, function: Self::Function, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Register a new function

Source

fn call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, args: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Self::CallResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Call a function by name with arguments

Source

fn list_functions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List available functions

Source

fn has_function<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a function exists

Source

fn get_function_info<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FunctionInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get function metadata

Provided Methods§

Source

fn call_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, calls: &'life1 [(&'life2 str, &'life3 str)], ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::CallResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Call multiple functions concurrently

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Health check for function registry

Source

fn validate_args<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, args: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Validate function arguments before calling

Implementors§