PromptHook

Trait PromptHook 

Source
pub trait PromptHook<M>:
    Clone
    + WasmCompatSend
    + WasmCompatSync
where M: CompletionModel,
{ // Provided methods fn on_completion_call( &self, prompt: &Message, history: &[Message], cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend { ... } fn on_completion_response( &self, prompt: &Message, response: &CompletionResponse<M::Response>, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend { ... } fn on_tool_call( &self, tool_name: &str, args: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend { ... } fn on_tool_result( &self, tool_name: &str, args: &str, result: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend { ... } }
Expand description

Trait for per-request hooks to observe tool call events.

Provided Methods§

Source

fn on_completion_call( &self, prompt: &Message, history: &[Message], cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend

Called before the prompt is sent to the model

Source

fn on_completion_response( &self, prompt: &Message, response: &CompletionResponse<M::Response>, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend

Called after the prompt is sent to the model and a response is received.

Source

fn on_tool_call( &self, tool_name: &str, args: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend

Called before a tool is invoked.

Source

fn on_tool_result( &self, tool_name: &str, args: &str, result: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend

Called after a tool is invoked (and a result has been returned).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<M> PromptHook<M> for ()
where M: CompletionModel,

Implementors§