mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-30 01:54:31 -04:00
chore: merge master into distributed transport PR
Keep the version-reporting import from master and omit the unused sanitize import after the transport changes. Assisted-by: Codex:GPT-6
This commit is contained in:
commit
4151ceda85
51 files changed
+1785
-72
No files matched your search
@@ -623,9 +623,13 @@ func initDistributed(cfg *config.ApplicationConfig, authDB *gorm.DB, configLoade
|
||||
// All dependencies ready — build SmartRouter with all options at once
|
||||
var conflictResolver nodes.ConcurrencyConflictResolver
|
||||
var pinnedResolver nodes.PinnedModelResolver
|
||||
var modelFiles func(string) []string
|
||||
if configLoader != nil {
|
||||
conflictResolver = configLoader
|
||||
pinnedResolver = configLoader
|
||||
if cfg.SystemState != nil {
|
||||
modelFiles = declaredModelFiles(configLoader, cfg.SystemState.Model.ModelsPath)
|
||||
}
|
||||
}
|
||||
modelCleanup := nodes.NewModelCleanupService(registry, remoteUnloader)
|
||||
// Absence is stamped on by distributedSchedulerOptions rather than written
|
||||
@@ -645,6 +649,7 @@ func initDistributed(cfg *config.ApplicationConfig, authDB *gorm.DB, configLoade
|
||||
DataPath: cfg.DataPath,
|
||||
ConflictResolver: conflictResolver,
|
||||
PinnedResolver: pinnedResolver,
|
||||
ModelFiles: modelFiles,
|
||||
PrefixProvider: prefixProvider,
|
||||
PrefixConfig: prefixCfg,
|
||||
Pressure: pressure,
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mudler/LocalAI/core/config"
|
||||
"github.com/mudler/LocalAI/core/gallery"
|
||||
"github.com/mudler/LocalAI/pkg/utils"
|
||||
)
|
||||
|
||||
// declaredModelFiles resolves the files a model needs on disk beyond the ones
|
||||
// its config names: what its gallery install or import declared under
|
||||
// `files:`, and what the config itself lists under download_files. The
|
||||
// distributed router stages these to workers, which cannot see the frontend's
|
||||
// models directory.
|
||||
func declaredModelFiles(configLoader *config.ModelConfigLoader, modelsPath string) func(modelName string) []string {
|
||||
return func(modelName string) []string {
|
||||
files := gallery.InstalledModelFiles(modelsPath, modelName)
|
||||
if cfg, ok := configLoader.GetModelConfig(modelName); ok {
|
||||
for _, f := range cfg.DownloadFiles {
|
||||
if utils.VerifyPath(f.Filename, modelsPath) != nil {
|
||||
continue
|
||||
}
|
||||
files = append(files, filepath.Join(modelsPath, f.Filename))
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/mudler/LocalAI/core/config"
|
||||
"github.com/mudler/LocalAI/core/gallery"
|
||||
)
|
||||
|
||||
var _ = Describe("declaredModelFiles", func() {
|
||||
It("combines the gallery install's files with the config's download_files", func() {
|
||||
modelsPath := GinkgoT().TempDir()
|
||||
Expect(os.WriteFile(filepath.Join(modelsPath, "big.yaml"), []byte(`
|
||||
name: big
|
||||
backend: llama-cpp
|
||||
parameters:
|
||||
model: big/Big-00001-of-00002.gguf
|
||||
download_files:
|
||||
- filename: big/extra.bin
|
||||
uri: https://example.com/extra.bin
|
||||
`), 0o644)).To(Succeed())
|
||||
Expect(os.WriteFile(filepath.Join(modelsPath, gallery.GalleryFileName("big")), []byte(`
|
||||
files:
|
||||
- filename: big/Big-00001-of-00002.gguf
|
||||
- filename: big/Big-00002-of-00002.gguf
|
||||
`), 0o644)).To(Succeed())
|
||||
|
||||
loader := config.NewModelConfigLoader(modelsPath)
|
||||
Expect(loader.LoadModelConfigsFromPath(modelsPath)).To(Succeed())
|
||||
|
||||
Expect(declaredModelFiles(loader, modelsPath)("big")).To(ConsistOf(
|
||||
filepath.Join(modelsPath, "big/Big-00001-of-00002.gguf"),
|
||||
filepath.Join(modelsPath, "big/Big-00002-of-00002.gguf"),
|
||||
filepath.Join(modelsPath, "big/extra.bin"),
|
||||
))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user