Before Model • AI Agent SDK
before_model: Decorator to mark a function as a before_model hook.
before_model
Function
</div>
This function is defined in the middleware module.
Decorator to mark a function as a before_model hook.
The function receives a ModelRequest and should return a (possibly modified) ModelRequest.
Signature
def before_model(func: BeforeModelFn) -> BeforeModelFnParameters
ParamField
BeforeModelFnNo description available.
Returns
ResponseField
BeforeModelFnThe result of the operation.
Usage
@before_model
def add_context(request):
request.messages.append({"role": "system", "content": "Extra"})
return requestSource
View on GitHubpraisonaiagents/hooks/middleware.py at line 198