pub trait PromptHook<M>:
Clone
+ WasmCompatSend
+ WasmCompatSyncwhere
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§
Sourcefn on_completion_call(
&self,
prompt: &Message,
history: &[Message],
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + WasmCompatSend
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
Sourcefn on_completion_response(
&self,
prompt: &Message,
response: &CompletionResponse<M::Response>,
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
Called after the prompt is sent to the model and a response is received.
Sourcefn on_tool_call(
&self,
tool_name: &str,
args: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + WasmCompatSend
fn on_tool_call( &self, tool_name: &str, args: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + WasmCompatSend
Called before a tool is invoked.
Sourcefn on_tool_result(
&self,
tool_name: &str,
args: &str,
result: &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
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.