mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-30 18:09:05 -04:00
feat(system): expose raw detected capability for model meta resolution
Model meta gallery entries express hardware fallback through candidate ordering rather than a capability map, so they need the undecorated detected capability string without Capability's default/cpu fallback chain. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -63,6 +63,17 @@ 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()
|
||||
|
||||
|
||||
@@ -164,3 +164,28 @@ var _ = Describe("CapabilityFilterDisabled", func() {
|
||||
Expect(s.IsBackendCompatible("cpu-whisperx", "quay.io/cpu")).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("ReportedCapability", func() {
|
||||
var previous string
|
||||
|
||||
BeforeEach(func() {
|
||||
previous = os.Getenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY")
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
Expect(os.Setenv("LOCALAI_FORCE_META_BACKEND_CAPABILITY", previous)).To(Succeed())
|
||||
})
|
||||
|
||||
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"))
|
||||
})
|
||||
|
||||
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"))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user