Execute Model Call • AI Agent SDK

execute_model_call: Execute a model call with all hooks and middleware.

execute_model_call

Method

</div>

This is a method of the MiddlewareManager class in the middleware module.

Execute a model call with all hooks and middleware.

Order:

  1. before_model hooks (in order)
  2. wrap_model_call middleware chain
  3. actual model call
  4. after_model hooks (in reverse order)

Signature

python
def execute_model_call(request: ModelRequest, model_fn: Callable[[ModelRequest], ModelResponse]) -> ModelResponse

Parameters

ParamField ModelRequest

No description available.

ParamField Callable

No description available.

Returns

ResponseField ModelResponse

The result of the operation.

Uses

  • model_fn
  • run_before_model
  • run_after_model
  • execute

Source

View on GitHub

praisonaiagents/hooks/middleware.py at line 469