Skip to main content

before_model

Function
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) -> BeforeModelFn

Parameters

func
BeforeModelFn
required
No description available.

Returns

Returns
BeforeModelFn
The result of the operation.

Usage

@before_model
    def add_context(request):
        request.messages.append({"role": "system", "content": "Extra"})
        return request