Skip to main content

TypedCollection

Trait TypedCollection 

Source
pub trait TypedCollection: Send + Sync {
    // Required methods
    fn names(&self) -> Vec<&'static str>;
    fn declarations(&self) -> Result<Value, ToolError>;
    fn decide(&self, call: &FunctionCall) -> Action;
    fn call<'a>(
        &'a self,
        call: FunctionCall,
    ) -> Pin<Box<dyn Future<Output = Result<FunctionResponse, ToolError>> + Send + 'a>>;
}
Expand description

Type-erased view of a tool collection used by the chat loop.

Implementations wrap a typed ToolCollection<M> + a decision strategy. The M disappears behind the trait object; the chat loop works uniformly over any collection that speaks this interface.

Required Methods§

Source

fn names(&self) -> Vec<&'static str>

Every tool name this collection owns. Used at builder time to populate the routing table and detect collisions with other collections.

Source

fn declarations(&self) -> Result<Value, ToolError>

Tool declarations as the providers need them, in the same shape ToolCollection::json returns today.

Source

fn decide(&self, call: &FunctionCall) -> Action

Ask the strategy what to do with this call. Pure decision — no side effects.

Source

fn call<'a>( &'a self, call: FunctionCall, ) -> Pin<Box<dyn Future<Output = Result<FunctionResponse, ToolError>> + Send + 'a>>

Actually execute the call. Called by the executor once a tool has been approved (auto or manually).

Implementors§

Source§

impl<M, F> TypedCollection for ScopedCollection<M, F>
where M: Send + Sync + 'static, F: Fn(&FunctionCall, &M) -> Action + Send + Sync + 'static,