MCPcopy Index your code
hub / github.com/mudler/LocalAI / BackendPreferenceTokens

Method BackendPreferenceTokens

pkg/system/capabilities.go:189–207  ·  view source on GitHub ↗

BackendPreferenceTokens returns a list of substrings that represent the preferred backend implementation order for the current system capability. Callers can use these tokens to select the most appropriate concrete backend among multiple candidates sharing the same alias (e.g., "llama-cpp").

()

Source from the content-addressed store, hash-verified

187// these tokens to select the most appropriate concrete backend among multiple
188// candidates sharing the same alias (e.g., "llama-cpp").
189func (s *SystemState) BackendPreferenceTokens() []string {
190 capStr := strings.ToLower(s.getSystemCapabilities())
191 switch {
192 case strings.HasPrefix(capStr, Nvidia):
193 return []string{backendTokenCUDA, vulkan, "cpu"}
194 case strings.HasPrefix(capStr, AMD):
195 return []string{backendTokenROCM, backendTokenHIP, vulkan, "cpu"}
196 case strings.HasPrefix(capStr, Intel):
197 return []string{backendTokenSYCL, Intel, "cpu"}
198 case strings.HasPrefix(capStr, metal):
199 return []string{backendTokenMetal, "cpu"}
200 case strings.HasPrefix(capStr, darwinX86):
201 return []string{"darwin-x86", "cpu"}
202 case strings.HasPrefix(capStr, vulkan):
203 return []string{vulkan, "cpu"}
204 default:
205 return []string{"cpu"}
206 }
207}
208
209// DetectedCapability returns the detected system capability string.
210// This can be used by the UI to display what capability was detected.

Callers 2

ListSystemBackendsFunction · 0.80

Calls 1

getSystemCapabilitiesMethod · 0.95

Tested by

no test coverage detected