Class InterceptorChain
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.InterceptorChain
Utility class for chaining model and tool interceptors.
This implements the Chain of Responsibility pattern.
Interceptors are composed so that the first in the list becomes the outermost layer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ModelCallHandlerchainModelInterceptors(List<ModelInterceptor> interceptors, ModelCallHandler baseHandler) Chain multiple ModelInterceptors into a single handler.static ToolCallHandlerchainToolInterceptors(List<ToolInterceptor> interceptors, ToolCallHandler baseHandler) Chain multiple ToolInterceptors into a single handler.
-
Constructor Details
-
InterceptorChain
public InterceptorChain()
-
-
Method Details
-
chainModelInterceptors
public static ModelCallHandler chainModelInterceptors(List<ModelInterceptor> interceptors, ModelCallHandler baseHandler) Chain multiple ModelInterceptors into a single handler. The first interceptor wraps all others, creating a nested structure: interceptors[0] -> interceptors[1] -> ... -> base handler- Parameters:
interceptors- List of ModelInterceptors to chainbaseHandler- The base handler that executes the actual model call- Returns:
- A composed handler, or the base handler if no interceptors
-
chainToolInterceptors
public static ToolCallHandler chainToolInterceptors(List<ToolInterceptor> interceptors, ToolCallHandler baseHandler) Chain multiple ToolInterceptors into a single handler. The first interceptor wraps all others, creating a nested structure: interceptors[0] -> interceptors[1] -> ... -> base handler- Parameters:
interceptors- List of ToolInterceptors to chainbaseHandler- The base handler that executes the actual tool call- Returns:
- A composed handler, or the base handler if no interceptors
-