Class ModelFallbackInterceptor
java.lang.Object
com.alibaba.cloud.ai.graph.agent.interceptor.ModelInterceptor
com.alibaba.cloud.ai.graph.agent.interceptor.modelfallback.ModelFallbackInterceptor
- All Implemented Interfaces:
Interceptor
Automatic fallback to alternative models on errors.
Retries failed model calls with alternative models in sequence until
success or all models exhausted.
Example:
ModelFallbackInterceptor interceptor = ModelFallbackInterceptor.builder()
.addFallbackModel(gpt4oMiniModel)
.addFallbackModel(claude35SonnetModel)
.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
-