wrap_model_call(
self,
request: ModelRequest[ContextT],
handler: Callable[[ModelRequest[| Name | Type | Description |
|---|---|---|
request* | ModelRequest[ContextT] | Model request to execute (includes state and runtime). |
handler* | Callable[[ModelRequest[ContextT]], ModelResponse[ResponseT]] |
Intercept and control model execution via handler callback.
Async version is awrap_model_call
The handler callback executes the model request and returns a ModelResponse.
Middleware can call the handler multiple times for retry logic, skip calling
it to short-circuit, or modify the request/response. Multiple middleware
compose with first in list as outermost layer.
Callback that executes the model request and returns
ModelResponse.
Call this to execute the model.
Can be called multiple times for retry logic.
Can skip calling it to short-circuit.