pub struct FunctionInvokingChatClient<C: ChatClient> { /* private fields */ }Expand description
Wraps a ChatClient to automatically execute local tool calls in a loop,
mirroring use_function_invocation.
Implementations§
Source§impl<C: ChatClient> FunctionInvokingChatClient<C>
impl<C: ChatClient> FunctionInvokingChatClient<C>
pub fn new(inner: C) -> Self
Sourcepub fn with_config(self, config: FunctionInvocationConfig) -> Self
pub fn with_config(self, config: FunctionInvocationConfig) -> Self
Override the function-invocation configuration.
Sourcepub fn with_function_middleware(
self,
middleware: Vec<Arc<FunctionMiddleware>>,
) -> Self
pub fn with_function_middleware( self, middleware: Vec<Arc<FunctionMiddleware>>, ) -> Self
Configure the function-invocation middleware pipeline run around every
tool call: middleware may inspect/rewrite
FunctionInvocationContext::arguments, short-circuit execution by
setting FunctionInvocationContext::result (and either not calling
next, or setting terminate = true), or observe a propagated
execution error by matching on the Result returned from their own
next.run(...) call. Replaces any previously configured middleware.
Trait Implementations§
Source§impl<C: ChatClient> ChatClient for FunctionInvokingChatClient<C>
impl<C: ChatClient> ChatClient for FunctionInvokingChatClient<C>
Source§fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a complete (non-streaming) response.
Source§fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a streaming response as a sequence of updates.
Auto Trait Implementations§
impl<C> !RefUnwindSafe for FunctionInvokingChatClient<C>
impl<C> !UnwindSafe for FunctionInvokingChatClient<C>
impl<C> Freeze for FunctionInvokingChatClient<C>where
C: Freeze,
impl<C> Send for FunctionInvokingChatClient<C>
impl<C> Sync for FunctionInvokingChatClient<C>
impl<C> Unpin for FunctionInvokingChatClient<C>where
C: Unpin,
impl<C> UnsafeUnpin for FunctionInvokingChatClient<C>where
C: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more