Class ToolSelectionInterceptor
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
com.alibaba.cloud.ai.graph.agent.interceptor.toolselection.ToolSelectionInterceptor
- All Implemented Interfaces:
Interceptor
Uses an LLM to select relevant tools before calling the main model.
When an agent has many tools available, this interceptor filters them down
to only the most relevant ones for the user's query. This reduces token usage
and helps the main model focus on the right tools.
Example:
ToolSelectionInterceptor interceptor = ToolSelectionInterceptor.builder()
.selectionModel(gpt4oMini)
.maxTools(3)
.build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()getName()interceptModel(ModelRequest request, ModelCallHandler handler) Wrap a model call with custom logic.Methods inherited from class com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
getTools
-
Method Details
-
builder
-
interceptModel
Description copied from class:ModelInterceptorWrap a model call with custom logic. Implementations can: - Modify the request before calling the handler - Call the handler multiple times (retry logic) - Modify the response after handler returns - Handle exceptions and provide fallbacks- Specified by:
interceptModelin classModelInterceptor- Parameters:
request- The model requesthandler- The next handler in the chain (or base handler)- Returns:
- The model response
-
getName
-