Static Selection
Static selection routes requests to a fixed model based on predefined rules. This is the simplest selection method, ideal for deterministic routing needs.
Algorithm Flow
Core Algorithm (Go)
// Select using rule-based matching
func (s *StaticSelector) Select(ctx context.Context, selCtx *SelectionContext) (*SelectionResult, error) {
for _, rule := range s.rules {
if s.matchesRule(rule, selCtx) {
return &SelectionResult{
SelectedModel: rule.Model,
Method: MethodStatic,
Reason: fmt.Sprintf("matched rule: %s", rule.Name),
}, nil
}
}
// No rule matched, use default
return &SelectionResult{
SelectedModel: s.defaultModel,
Method: MethodStatic,
Reason: "default model (no rules matched)",
}, nil
}
func (s *StaticSelector) matchesRule(rule Rule, selCtx *SelectionContext) bool {
if rule.Match.Category != "" && selCtx.Category != rule.Match.Category {
return false
}
if len(rule.Match.Keywords) > 0 && !containsAny(selCtx.Query, rule.Match.Keywords) {
return false
}
if rule.Match.MaxTokensGT > 0 && selCtx.MaxTokens <= rule.Match.MaxTokensGT {
return false
}
return true
}
How It Works
Static selection uses explicit rules to match requests to models:
- Evaluate request against configured rules (in order)
- First matching rule determines the model
- If no rules match, use the default model
Configuration
decision:
algorithm:
type: static
static:
default_model: gpt-3.5-turbo
rules:
- match:
category: coding
model: gpt-4
- match:
category: simple
model: gpt-3.5-turbo
- match:
keywords: ["analyze", "complex", "detailed"]
model: gpt-4
- match:
max_tokens_gt: 2000
model: gpt-4
models:
- name: gpt-4
backend: openai
- name: gpt-3.5-turbo
backend: openai