Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions core/config/model_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,76 @@ parameters:
Expect(i.HasUsecases(FLAG_COMPLETION)).To(BeTrue())
Expect(i.HasUsecases(FLAG_CHAT)).To(BeTrue())
})

It("Handles multiple configs with same model file but different names", func() {
// Create a temporary directory for test configs
tmpDir, err := os.MkdirTemp("", "config_test_*")
Expect(err).To(BeNil())
defer os.RemoveAll(tmpDir)

// Write first config without MCP
config1Path := tmpDir + "/model-without-mcp.yaml"
err = os.WriteFile(config1Path, []byte(`name: model-without-mcp
backend: llama-cpp
parameters:
model: shared-model.gguf
`), 0644)
Expect(err).To(BeNil())

// Write second config with MCP
config2Path := tmpDir + "/model-with-mcp.yaml"
err = os.WriteFile(config2Path, []byte(`name: model-with-mcp
backend: llama-cpp
parameters:
model: shared-model.gguf
mcp:
stdio: |
mcpServers:
test:
command: echo
args: ["hello"]
`), 0644)
Expect(err).To(BeNil())

// Load all configs
loader := NewModelConfigLoader(tmpDir)
err = loader.LoadModelConfigsFromPath(tmpDir)
Expect(err).To(BeNil())

// Verify both configs are loaded
cfg1, exists1 := loader.GetModelConfig("model-without-mcp")
Expect(exists1).To(BeTrue())
Expect(cfg1.Name).To(Equal("model-without-mcp"))
Expect(cfg1.Model).To(Equal("shared-model.gguf"))
Expect(cfg1.MCP.Stdio).To(Equal(""))
Expect(cfg1.MCP.Servers).To(Equal(""))

cfg2, exists2 := loader.GetModelConfig("model-with-mcp")
Expect(exists2).To(BeTrue())
Expect(cfg2.Name).To(Equal("model-with-mcp"))
Expect(cfg2.Model).To(Equal("shared-model.gguf"))
Expect(cfg2.MCP.Stdio).ToNot(Equal(""))

// Verify both configs are in the list
allConfigs := loader.GetAllModelsConfigs()
Expect(len(allConfigs)).To(Equal(2))

// Find each config in the list
foundWithoutMCP := false
foundWithMCP := false
for _, cfg := range allConfigs {
if cfg.Name == "model-without-mcp" {
foundWithoutMCP = true
Expect(cfg.Model).To(Equal("shared-model.gguf"))
Expect(cfg.MCP.Stdio).To(Equal(""))
}
if cfg.Name == "model-with-mcp" {
foundWithMCP = true
Expect(cfg.Model).To(Equal("shared-model.gguf"))
Expect(cfg.MCP.Stdio).ToNot(Equal(""))
}
}
Expect(foundWithoutMCP).To(BeTrue())
Expect(foundWithMCP).To(BeTrue())
})
})
4 changes: 1 addition & 3 deletions core/http/views/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ <h4 class="text-sm font-semibold text-[#E5E7EB] flex items-center">
</template>

{{ if $model }}
{{ $galleryConfig:= index $allGalleryConfigs $model}}
{{ if $galleryConfig }}
<!-- Check for MCP configuration independently of gallery config -->
{{ $modelConfig := "" }}
{{ range .ModelsConfig }}
{{ if eq .Name $model }}
Expand Down Expand Up @@ -449,7 +448,6 @@ <h4 class="text-sm font-semibold text-[#E5E7EB] flex items-center">
</div>
{{ end }}
{{ end }}
{{ end }}

<button
@click="showPromptForm = !showPromptForm"
Expand Down
5 changes: 0 additions & 5 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
module github.com/mudler/LocalAI/docs

go 1.19

require (
github.com/McShelby/hugo-theme-relearn v0.0.0-20251117214752-f69a085322cc // indirect
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20400 // indirect
)
6 changes: 0 additions & 6 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
github.com/McShelby/hugo-theme-relearn v0.0.0-20251117214752-f69a085322cc h1:8BvuabGtqXqhT4H01SS7s0zXea0B2R5ZOFEcPugMbNg=
github.com/McShelby/hugo-theme-relearn v0.0.0-20251117214752-f69a085322cc/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20400 h1:L6+F22i76xmeWWwrtijAhUbf3BiRLmpO5j34bgl1ggU=
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20400/go.mod h1:uekq1D4ebeXgduLj8VIZy8TgfTjrLdSl6nPtVczso78=
github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2 v2.21100.20000/go.mod h1:mFberT6ZtcchrsDtfvJM7aAH2bDKLdOnruUHl0hlapI=
github.com/twbs/bootstrap v5.3.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ require (
go.opentelemetry.io/otel/metric v1.38.0
go.opentelemetry.io/otel/sdk/metric v1.38.0
google.golang.org/grpc v1.76.0
google.golang.org/protobuf v1.36.10
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
oras.land/oras-go/v2 v2.6.0
Expand All @@ -65,7 +66,6 @@ require (
github.com/stretchr/testify v1.11.1 // indirect
github.com/swaggo/files/v2 v2.0.2 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
google.golang.org/protobuf v1.36.10 // indirect
)

require (
Expand Down
Loading