MCPcopy
hub / github.com/mudler/LocalAI / newScoreRouterModel

Function newScoreRouterModel

core/http/middleware/route_model_test.go:395–415  ·  view source on GitHub ↗

newScoreRouterModel builds a smart-router config with 3 policies and 2 candidates (small with one label, bigger with all three). Admins are expected to order candidates small → large; the middleware picks the first whose labels are a superset of the active set.

(modelDir, name string)

Source from the content-addressed store, hash-verified

393// middleware picks the first whose labels are a superset of the
394// active set.
395func newScoreRouterModel(modelDir, name string) *config.ModelConfig {
396 cfg := &config.ModelConfig{
397 Name: name,
398 Router: config.RouterConfig{
399 Classifier: "score",
400 ClassifierModel: "arch-router",
401 Fallback: "qwen3-0.6b",
402 Policies: []config.RouterPolicy{
403 {Label: "code-generation", Description: "writing or debugging code"},
404 {Label: "casual-chat", Description: "small talk"},
405 {Label: "math-reasoning", Description: "arithmetic and word problems"},
406 },
407 Candidates: []config.RouterCandidate{
408 {Model: "small-model", Labels: []string{"casual-chat"}},
409 {Model: "big-model", Labels: []string{"code-generation", "casual-chat", "math-reasoning"}},
410 },
411 },
412 }
413 Expect(os.WriteFile(filepath.Join(modelDir, name+".yaml"), []byte(toYAML(cfg)), 0o644)).To(Succeed())
414 return cfg
415}
416
417func writeCandidate(modelDir, name string) {
418 body := "name: " + name + "\nbackend: mock-backend\n"

Callers 1

Calls 1

toYAMLFunction · 0.85

Tested by

no test coverage detected