From 79ec0024b8ccb26b45f92a1225e566dae63678eb Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 20 Jun 2026 10:09:17 +0000 Subject: [PATCH] feat(config-meta): expose alias as a model-select field Add an 'alias' section to DefaultSections() and an 'alias' field override in DefaultRegistry() so the schema-driven React editor renders the new top-level ModelConfig.Alias field as a model picker in its own section. Assisted-by: Claude:opus-4.8 [Claude Code] Signed-off-by: Ettore Di Giacinto --- core/config/meta/registry.go | 9 +++++++++ core/config/meta/registry_test.go | 28 ++++++++++++++++++++++++++++ core/config/meta/types.go | 1 + 3 files changed, 38 insertions(+) create mode 100644 core/config/meta/registry_test.go diff --git a/core/config/meta/registry.go b/core/config/meta/registry.go index ca10f604c..84fc9afda 100644 --- a/core/config/meta/registry.go +++ b/core/config/meta/registry.go @@ -286,6 +286,15 @@ func DefaultRegistry() map[string]FieldMetaOverride { Order: 45, }, + // --- Alias --- + "alias": { + Section: "alias", + Label: "Alias target", + Description: "Redirect all traffic for this model to another configured model. When set, every other field on this config is ignored and requests are served by the target model.", + Component: "model-select", + Order: 0, + }, + // --- Pipeline --- "pipeline.llm": { Section: "pipeline", diff --git a/core/config/meta/registry_test.go b/core/config/meta/registry_test.go new file mode 100644 index 000000000..e9d998609 --- /dev/null +++ b/core/config/meta/registry_test.go @@ -0,0 +1,28 @@ +package meta_test + +import ( + "github.com/mudler/LocalAI/core/config/meta" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("alias field metadata", func() { + It("registers the alias field as a model-select in the alias section", func() { + reg := meta.DefaultRegistry() + f, ok := reg["alias"] + Expect(ok).To(BeTrue(), "alias field should have a registry override") + Expect(f.Section).To(Equal("alias")) + Expect(f.Component).To(Equal("model-select")) + }) + + It("defines an alias section", func() { + var found bool + for _, s := range meta.DefaultSections() { + if s.ID == "alias" { + found = true + } + } + Expect(found).To(BeTrue(), "DefaultSections should include an alias section") + }) +}) diff --git a/core/config/meta/types.go b/core/config/meta/types.go index a86b8bb69..a29e66967 100644 --- a/core/config/meta/types.go +++ b/core/config/meta/types.go @@ -69,6 +69,7 @@ type FieldMetaOverride struct { func DefaultSections() []Section { return []Section{ {ID: "general", Label: "General", Icon: "settings", Order: 0}, + {ID: "alias", Label: "Alias", Icon: "git-merge", Order: 5}, {ID: "llm", Label: "LLM", Icon: "cpu", Order: 10}, {ID: "parameters", Label: "Parameters", Icon: "sliders", Order: 20}, {ID: "templates", Label: "Templates", Icon: "file-text", Order: 30},