pub trait PromptHook<M>:
Clone
+ WasmCompatSend
+ WasmCompatSyncwhere
M: CompletionModel,{
// Provided methods
fn on_completion_call(
&self,
_prompt: &Message,
_history: &[Message],
) -> impl Future<Output = HookAction> + WasmCompatSend { ... }
fn on_completion_response(
&self,
_prompt: &Message,
_response: &CompletionResponse<M::Response>,
) -> impl Future<Output = HookAction> + WasmCompatSend { ... }
fn on_tool_call(
&self,
_tool_name: &str,
_tool_call_id: Option<String>,
_internal_call_id: &str,
_args: &str,
) -> impl Future<Output = ToolCallHookAction> + WasmCompatSend { ... }
fn on_tool_result(
&self,
_tool_name: &str,
_tool_call_id: Option<String>,
_internal_call_id: &str,
_args: &str,
_result: &str,
) -> impl Future<Output = HookAction> + WasmCompatSend { ... }
}Expand description
Trait for per-request hooks to observe tool call events.
Provided Methods§
Sourcefn on_completion_call(
&self,
_prompt: &Message,
_history: &[Message],
) -> impl Future<Output = HookAction> + WasmCompatSend
fn on_completion_call( &self, _prompt: &Message, _history: &[Message], ) -> impl Future<Output = HookAction> + WasmCompatSend
Called before the prompt is sent to the model
Sourcefn on_completion_response(
&self,
_prompt: &Message,
_response: &CompletionResponse<M::Response>,
) -> impl Future<Output = HookAction> + WasmCompatSend
fn on_completion_response( &self, _prompt: &Message, _response: &CompletionResponse<M::Response>, ) -> impl Future<Output = HookAction> + WasmCompatSend
Called after the prompt is sent to the model and a response is received.
Sourcefn on_tool_call(
&self,
_tool_name: &str,
_tool_call_id: Option<String>,
_internal_call_id: &str,
_args: &str,
) -> impl Future<Output = ToolCallHookAction> + WasmCompatSend
fn on_tool_call( &self, _tool_name: &str, _tool_call_id: Option<String>, _internal_call_id: &str, _args: &str, ) -> impl Future<Output = ToolCallHookAction> + WasmCompatSend
Called before a tool is invoked.
§Returns
ToolCallHookAction::Continue- Allow tool execution to proceedToolCallHookAction::Skip { reason }- Reject tool execution;reasonwill be returned to the LLM as the tool result
Sourcefn on_tool_result(
&self,
_tool_name: &str,
_tool_call_id: Option<String>,
_internal_call_id: &str,
_args: &str,
_result: &str,
) -> impl Future<Output = HookAction> + WasmCompatSend
fn on_tool_result( &self, _tool_name: &str, _tool_call_id: Option<String>, _internal_call_id: &str, _args: &str, _result: &str, ) -> impl Future<Output = HookAction> + 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.