You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: dynamic model switching — /model <name> for any configured provider
- Router refactored to use providers map[string]Provider
- /model list shows all available models
- /model <name> switches to any configured model (validated)
- /model reset clears override back to auto-routing
- Added qwen_122b (qwen3.5-122b-a10b) and qwen_max (qwen3-max)
- Routing roles (multimodal, reasoner) now configurable in config.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: internal/llm/router.go
+90-42Lines changed: 90 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ import (
4
4
"context"
5
5
"errors"
6
6
"log/slog"
7
+
"sort"
7
8
"strings"
8
9
"sync"
9
10
@@ -12,97 +13,144 @@ import (
12
13
13
14
constclassifierPrompt=`Does this message require deep step-by-step reasoning, mathematical proof, or complex multi-step analysis? Reply with only 'yes' or 'no'.`
14
15
16
+
// RouterConfig holds the keys into the providers map for special roles.
17
+
typeRouterConfigstruct {
18
+
Primarystring
19
+
Fallbackstring
20
+
Multimodalstring
21
+
Reasonerstring
22
+
Classifierstring// provider used for reasoning classification; falls back to Primary if empty
23
+
ClassifierMinLenint// min rune length to run classifier; 0 = disabled
24
+
}
25
+
15
26
// Router selects the appropriate LLM provider based on context.
16
-
// Primary → Fallback on 5xx/network error.
17
-
// Reasoner → selected by LLM classifier or explicit /model command.
18
-
// Multimodal → selected when message contains image parts.
27
+
// All providers are stored by name; special roles reference names from RouterConfig.
19
28
typeRouterstruct {
20
-
primaryProvider
21
-
fallbackProvider// used if primary is unavailable
22
-
reasonerProvider// used for complex reasoning
23
-
multimodalProvider// used when message contains images
24
-
25
-
classifierMinLenint// min message length to run classifier; 0 = disabled
29
+
providersmap[string]Provider
30
+
cfgRouterConfig
26
31
27
32
mu sync.RWMutex
28
-
overridestring// "reasoner" or "" (primary)
33
+
overridestring// set via SetOverride; any key in providers, or "" for auto
29
34
30
-
OnFallbackfunc(from, tostring) // optional: called when fallback is triggered
0 commit comments