Skip to main content

AfterModelCallback

Type Alias AfterModelCallback 

Source
pub type AfterModelCallback = Arc<dyn Fn(Context, LlmResponse, Option<Arc<ModelError>>) -> BoxFuture<'static, (LlmResponse, Result<Option<LlmResponse>, AgentError>)> + Send + Sync>;
Expand description

Called after receiving a response from the model. If it returns Some response or an error, the actual model response/error is replaced with the returned response/error.

The response (possibly edited) is always handed back, mirroring BeforeModelCallback: an in-place edit made by a callback that returns Ok(None) reaches the later callbacks and the rest of the flow. Return the received response unchanged when there is nothing to edit.

Aliased Typeยง

pub struct AfterModelCallback { /* private fields */ }