Skip to main content

ScopedCollection

Struct ScopedCollection 

Source
pub struct ScopedCollection<M, F> { /* private fields */ }
Expand description

A ToolCollection<M> paired with a user-defined strategy closure.

Boxed into dyn TypedCollection when handed to the chat builder — the generic M and F disappear at that boundary.

Implementations§

Source§

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

Source

pub fn new(tools: ToolCollection<M>, strategy: F) -> ScopedCollection<M, F>

Wrap a typed tool collection with a decision strategy.

Source§

impl ScopedCollection<NoMeta, fn(&FunctionCall, &NoMeta) -> Action>

Source

pub fn auto_execute( tools: ToolCollection, ) -> ScopedCollection<NoMeta, fn(&FunctionCall, &NoMeta) -> Action>

Shortcut for the common case: wrap an unmetadata’d collection with an always-execute strategy. Replaces the old ChatBuilder::with_tools(collection) convenience path.

Trait Implementations§

Source§

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

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).

Auto Trait Implementations§

§

impl<M, F> Freeze for ScopedCollection<M, F>
where F: Freeze,

§

impl<M, F> !RefUnwindSafe for ScopedCollection<M, F>

§

impl<M, F> Send for ScopedCollection<M, F>
where F: Send, M: Send,

§

impl<M, F> Sync for ScopedCollection<M, F>
where F: Sync, M: Sync,

§

impl<M, F> Unpin for ScopedCollection<M, F>
where F: Unpin, M: Unpin,

§

impl<M, F> UnsafeUnpin for ScopedCollection<M, F>
where F: UnsafeUnpin,

§

impl<M, F> !UnwindSafe for ScopedCollection<M, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<M> MetaArg<M> for M

Source§

fn into_meta(self) -> M

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.