diff --git a/core/config/model_config_test.go b/core/config/model_config_test.go index 342b10c47f8b..b731f7e6089a 100644 --- a/core/config/model_config_test.go +++ b/core/config/model_config_test.go @@ -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()) + }) }) diff --git a/core/http/views/chat.html b/core/http/views/chat.html index dd917612adc0..7dce5ba66a5e 100644 --- a/core/http/views/chat.html +++ b/core/http/views/chat.html @@ -419,8 +419,7 @@