Package com.tnsai.llm.fallback
Interface FallbackCondition
- All Known Implementing Classes:
FallbackCondition.Always,FallbackCondition.Composite,FallbackCondition.OnErrorType,FallbackCondition.OnHttpStatus,FallbackCondition.OnProviderCode
public sealed interface FallbackCondition
permits FallbackCondition.OnErrorType, FallbackCondition.OnHttpStatus, FallbackCondition.OnProviderCode, FallbackCondition.Always, FallbackCondition.Composite
Sealed predicate over an
LLMException describing when a
LLMFallbackRule should fire (issue #89).
Conditions key on classified error types (LLMException.ErrorType),
upstream HTTP status, or provider-native error codes (surfaced through the
ProviderDetails envelope added in issue #87).
Composing with FallbackCondition.Composite lets consumers express AND/OR rules without
a custom predicate class.
Out of scope for this slice (see #79, #82): conditions that read live cost / budget / token-usage state. Those land in a follow-up that wires them to the cost-tracking subsystem.
- Since:
- 0.5.0 (issue #89)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAlways matches — the catch-all "last resort" condition.static final recordLogical AND/OR over child conditions.static final recordMatch when the failure's classifiedLLMException.ErrorTypeis in the configured set.static final recordMatch when the upstream HTTP status (fromProviderDetails) is in the configured set.static final recordMatch when the failure originated from the named provider AND its native error code (from theProviderDetailsenvelope) is in the configured set. -
Method Summary
Modifier and TypeMethodDescriptionstatic FallbackConditionalways()static FallbackConditionand(FallbackCondition... conditions) booleanmatches(com.tnsai.exceptions.LLMException error) Returnstrueif this condition matches the given primary failure — i.e. the framework should try the rule's fallback target.static FallbackConditiononErrorType(com.tnsai.exceptions.LLMException.ErrorType... types) static FallbackConditiononHttpStatus(Integer... statuses) static FallbackConditiononProviderCode(String provider, String... codes) static FallbackConditionor(FallbackCondition... conditions)
-
Method Details
-
matches
boolean matches(com.tnsai.exceptions.LLMException error) Returnstrueif this condition matches the given primary failure — i.e. the framework should try the rule's fallback target. -
onErrorType
-
onHttpStatus
-
onProviderCode
-
always
-
or
-
and
-