pub trait StreamingPromptHook<M>:
Clone
+ Send
+ Syncwhere
M: CompletionModel,{
// Provided methods
fn on_completion_call(
&self,
prompt: &Message,
history: &[Message],
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
fn on_text_delta(
&self,
text_delta: &str,
aggregated_text: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
fn on_tool_call_delta(
&self,
tool_call_id: &str,
tool_call_delta: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
fn on_stream_completion_response_finish(
&self,
prompt: &Message,
response: &<M as CompletionModel>::StreamingResponse,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
fn on_tool_call(
&self,
tool_name: &str,
args: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
fn on_tool_result(
&self,
tool_name: &str,
args: &str,
result: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send { ... }
}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 = ()> + Send
fn on_completion_call( &self, prompt: &Message, history: &[Message], cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
Called before the prompt is sent to the model
Sourcefn on_text_delta(
&self,
text_delta: &str,
aggregated_text: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_text_delta( &self, text_delta: &str, aggregated_text: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
Called when receiving a text delta
Sourcefn on_tool_call_delta(
&self,
tool_call_id: &str,
tool_call_delta: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_tool_call_delta( &self, tool_call_id: &str, tool_call_delta: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
Called when receiving a tool call delta
Sourcefn on_stream_completion_response_finish(
&self,
prompt: &Message,
response: &<M as CompletionModel>::StreamingResponse,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_stream_completion_response_finish( &self, prompt: &Message, response: &<M as CompletionModel>::StreamingResponse, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
Called after the model provider has finished streaming a text response from their completion API to the client.
Sourcefn on_tool_call(
&self,
tool_name: &str,
args: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_tool_call( &self, tool_name: &str, args: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
Called before a tool is invoked.
Sourcefn on_tool_result(
&self,
tool_name: &str,
args: &str,
result: &str,
cancel_sig: CancelSignal,
) -> impl Future<Output = ()> + Send
fn on_tool_result( &self, tool_name: &str, args: &str, result: &str, cancel_sig: CancelSignal, ) -> impl Future<Output = ()> + Send
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.