diff --git a/pkg/system/capabilities.go b/pkg/system/capabilities.go index 9e74a2e8b..9d0d3c3c4 100644 --- a/pkg/system/capabilities.go +++ b/pkg/system/capabilities.go @@ -63,17 +63,6 @@ func (s *SystemState) CapabilityFilterDisabled() bool { return s.getSystemCapabilities() == disableCapability } -// ReportedCapability returns the raw detected capability string (e.g. "metal", -// "nvidia-cuda-12", "default") with no map-membership fallback applied. -// -// Why this exists alongside Capability: Capability resolves against a caller -// supplied map and falls back to "default" then "cpu" when the detected value -// is absent. Model meta entries express fallback through candidate ordering -// instead, so they need the undecorated value. -func (s *SystemState) ReportedCapability() string { - return s.getSystemCapabilities() -} - func (s *SystemState) Capability(capMap map[string]string) string { reportedCapability := s.getSystemCapabilities() @@ -217,8 +206,14 @@ func (s *SystemState) BackendPreferenceTokens() []string { } } -// DetectedCapability returns the detected system capability string. +// DetectedCapability returns the raw detected capability string (e.g. "metal", +// "nvidia-cuda-12", "default") with no map-membership fallback applied. // This can be used by the UI to display what capability was detected. +// +// Why this exists alongside Capability: Capability resolves against a caller +// supplied map and falls back to "default" then "cpu" when the detected value +// is absent from that map. Callers that express fallback themselves, such as +// model meta entries ordering their own candidates, need the undecorated value. func (s *SystemState) DetectedCapability() string { return s.getSystemCapabilities() } diff --git a/pkg/system/capabilities_test.go b/pkg/system/capabilities_test.go index 117e3ffdb..4701bbca0 100644 --- a/pkg/system/capabilities_test.go +++ b/pkg/system/capabilities_test.go @@ -165,7 +165,7 @@ var _ = Describe("CapabilityFilterDisabled", func() { }) }) -var _ = Describe("ReportedCapability", func() { +var _ = Describe("DetectedCapability", func() { var previous string BeforeEach(func() { @@ -179,13 +179,13 @@ var _ = Describe("ReportedCapability", func() { It("returns the forced capability verbatim without map fallback", func() { Expect(os.Setenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY", "nvidia-cuda-12")).To(Succeed()) state := &SystemState{} - Expect(state.ReportedCapability()).To(Equal("nvidia-cuda-12")) + Expect(state.DetectedCapability()).To(Equal("nvidia-cuda-12")) }) It("does not fall back to default when the capability is unusual", func() { Expect(os.Setenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY", "metal")).To(Succeed()) state := &SystemState{} - Expect(state.ReportedCapability()).To(Equal("metal")) - Expect(state.ReportedCapability()).NotTo(Equal("default")) + Expect(state.DetectedCapability()).To(Equal("metal")) + Expect(state.DetectedCapability()).NotTo(Equal("default")) }) })