MCPcopy
hub / github.com/mudler/LocalAI / Capability

Method Capability

pkg/system/capabilities.go:66–91  ·  view source on GitHub ↗
(capMap map[string]string)

Source from the content-addressed store, hash-verified

64}
65
66func (s *SystemState) Capability(capMap map[string]string) string {
67 reportedCapability := s.getSystemCapabilities()
68
69 // Check if the reported capability is in the map
70 if _, exists := capMap[reportedCapability]; exists {
71 xlog.Debug("Using reported capability", "reportedCapability", reportedCapability, "capMap", capMap)
72 return reportedCapability
73 }
74
75 // Fall back to the explicit "default" catch-all, then to "cpu". The cpu
76 // fallback matters for meta backends that only enumerate GPU variants +
77 // cpu (e.g. vllm maps nvidia/amd/intel/cpu but not default): on a
78 // no-GPU host the reported capability is "default", so without this
79 // we'd filter the meta out and break auto-install by name.
80 if _, exists := capMap[defaultCapability]; exists {
81 xlog.Debug("Capability not in map, falling back to default", "reportedCapability", reportedCapability, "capMap", capMap)
82 return defaultCapability
83 }
84 if _, exists := capMap["cpu"]; exists {
85 xlog.Debug("Capability not in map, falling back to cpu", "reportedCapability", reportedCapability, "capMap", capMap)
86 return "cpu"
87 }
88
89 xlog.Debug("The requested capability was not found, using default capability", "reportedCapability", reportedCapability, "capMap", capMap)
90 return defaultCapability
91}
92
93func (s *SystemState) getSystemCapabilities() string {
94

Callers 2

IsCompatibleWithMethod · 0.80

Calls 1

getSystemCapabilitiesMethod · 0.95

Tested by

no test coverage detected