Agent

Trait Agent 

Source
pub trait Agent: Send + Sync {
    // Required method
    fn name(&self) -> String;

    // Provided methods
    fn on_start<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn on_message<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _msg: Message,
        _ctx: &'life1 mut AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn on_generic_message<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        msg: GenericMessage,
        _ctx: &'life1 mut AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<GenericResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn on_stop<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn tool_invoker(&self) -> Option<&ToolInvoker> { ... }
    fn tool_invoker_mut(&mut self) -> Option<&mut ToolInvoker> { ... }
}

Required Methods§

Source

fn name(&self) -> String

Provided Methods§

Source

fn on_start<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut AgentContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn on_message<'life0, 'life1, 'async_trait>( &'life0 mut self, _msg: Message, _ctx: &'life1 mut AgentContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn on_generic_message<'life0, 'life1, 'async_trait>( &'life0 mut self, msg: GenericMessage, _ctx: &'life1 mut AgentContext, ) -> Pin<Box<dyn Future<Output = Result<GenericResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a generic string message and return a generic response. Default implementation returns an echo response.

Source

fn on_stop<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut AgentContext, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn tool_invoker(&self) -> Option<&ToolInvoker>

Get the tool invoker for this agent (if it has actions)

Source

fn tool_invoker_mut(&mut self) -> Option<&mut ToolInvoker>

Get mutable tool invoker for registration

Implementors§