feat(backend gallery): add meta packages

So we can have meta packages such as "vllm" that automatically installs
the corresponding package depending on the GPU that is being currently
detected in the system.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2025-06-20 19:16:53 +02:00
parent be3ff482d0
commit 9a34fc8c66
4 changed files with 346 additions and 13 deletions

View file

@ -0,0 +1,40 @@
package system
import (
"strings"
"github.com/mudler/LocalAI/pkg/xsysinfo"
)
type SystemState struct {
GPUVendor string
}
func GetSystemState() (*SystemState, error) {
gpuVendor, err := detectGPUVendor()
if err != nil {
return nil, err
}
return &SystemState{GPUVendor: gpuVendor}, nil
}
func detectGPUVendor() (string, error) {
gpus, err := xsysinfo.GPUs()
if err != nil {
return "", err
}
for _, gpu := range gpus {
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "NVIDIA" {
return "nvidia", nil
}
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "AMD" {
return "amd", nil
}
if strings.ToUpper(gpu.DeviceInfo.Vendor.Name) == "INTEL" {
return "intel", nil
}
}
return "", nil
}