redis_openai_agents.middleware.SemanticRouterMiddleware#
- class SemanticRouterMiddleware(router, *, responses=None, response_factory=None, auto_wrap=False)[source]#
Short-circuit the LLM call when the input matches a known intent.
- Parameters:
router (SemanticRouter) – A
SemanticRouterconfigured with the intents to recognize.responses (Mapping[str, Any] | None) – Optional mapping from route name to canned response. Used when
response_factoryis not provided.response_factory (ResponseFactory | None) – Optional callable that receives the
RouteMatchand returns the response. Takes precedence overresponseswhen supplied.auto_wrap (bool)
Either
responsesorresponse_factorymust yield a value for the short-circuit to trigger. If neither produces a response (for instance, an unmapped route name), the request delegates to the inner model.- __init__(router, *, responses=None, response_factory=None, auto_wrap=False)[source]#
- Parameters:
router (SemanticRouter)
responses (Mapping[str, Any] | None)
response_factory (ResponseFactory | None)
auto_wrap (bool)
- Return type:
None
Methods
__init__(router, *[, responses, ...])awrap_model_call(request, handler)