feat: classifier bucket mapping + dispatcher seed group
Classifier: When complexity_threshold is set (e.g. 10), uses it as the rating scale and maps ratings proportionally to target buckets instead of 1:1. Formula: idx = rating * len(targets) / (threshold + 1). With threshold=10 and 3 targets: 1-3→target[0], 4-7→target[1], 8-10→target[2]. Seed: Added 'dispatcher' group (classifier, threshold=10, selector=deepseek-v4-flash) that auto-routes to fast-flow/standard-pro/heavy-logic by complexity score. Combined with hierarchical routing, this enables two-level dispatch: dispatcher scores 1-10 → routes to tier group → tier picks concrete model.
This commit is contained in:
@@ -16,11 +16,19 @@ const classifierSystemPrompt = `You are a task complexity classifier. Rate the f
|
||||
Reply with ONLY the number. No explanation.`
|
||||
|
||||
func routeClassifier(ctx context.Context, classify ClassifierFunc, group db.ModelGroup, targets []string, userMessage string) (*Decision, error) {
|
||||
// Determine the rating scale
|
||||
maxRating := len(targets)
|
||||
if maxRating < 2 {
|
||||
maxRating = 2
|
||||
}
|
||||
|
||||
// When complexity_threshold is set, use it as a wider scale (e.g., 1-10)
|
||||
// and map ratings proportionally to target buckets.
|
||||
bucketMode := group.ComplexityThreshold != nil && *group.ComplexityThreshold > 0
|
||||
if bucketMode {
|
||||
maxRating = *group.ComplexityThreshold
|
||||
}
|
||||
|
||||
prompt := fmt.Sprintf(classifierSystemPrompt, maxRating, maxRating)
|
||||
ratingStr, err := classify(ctx, getSelectorModel(group, targets), prompt, userMessage)
|
||||
if err != nil {
|
||||
@@ -36,7 +44,18 @@ func routeClassifier(ctx context.Context, classify ClassifierFunc, group db.Mode
|
||||
rating = maxRating
|
||||
}
|
||||
|
||||
idx := rating - 1 // 0-based index into targets
|
||||
var idx int
|
||||
if bucketMode {
|
||||
// Proportional mapping: wider scale → N target buckets
|
||||
// e.g., threshold=10, 3 targets: 1-3→0, 4-7→1, 8-10→2
|
||||
idx = rating * len(targets) / (maxRating + 1)
|
||||
if idx >= len(targets) {
|
||||
idx = len(targets) - 1
|
||||
}
|
||||
} else {
|
||||
idx = rating - 1 // 1:1 mapping
|
||||
}
|
||||
|
||||
return &Decision{
|
||||
SelectedModel: targets[idx],
|
||||
Strategy: "classifier",
|
||||
|
||||
Reference in New Issue
Block a user