mirror of
https://github.com/mudler/LocalAI.git
synced 2024-06-07 19:40:48 +00:00
c89271b2e4
* feat(llama.cpp): support distributed llama.cpp Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * feat: let tweak how chat messages are merged together Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * refactor Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Makefile: register to ALL_GRPC_BACKENDS Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * refactoring, allow disable auto-detection of backends Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * minor fixups Signed-off-by: mudler <mudler@localai.io> * feat: add cmd to start rpc-server from llama.cpp Signed-off-by: mudler <mudler@localai.io> * ci: add ccache Signed-off-by: mudler <mudler@localai.io> --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Signed-off-by: mudler <mudler@localai.io>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package assets
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func ResolvePath(dir string, paths ...string) string {
|
|
return filepath.Join(append([]string{dir, "backend-assets"}, paths...)...)
|
|
}
|
|
|
|
func ExtractFiles(content embed.FS, extractDir string) error {
|
|
// Create the target directory if it doesn't exist
|
|
err := os.MkdirAll(extractDir, 0750)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to create directory: %v", err)
|
|
}
|
|
|
|
// Walk through the embedded FS and extract files
|
|
err = fs.WalkDir(content, ".", func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Reconstruct the directory structure in the target directory
|
|
targetFile := filepath.Join(extractDir, path)
|
|
if d.IsDir() {
|
|
// Create the directory in the target directory
|
|
err := os.MkdirAll(targetFile, 0750)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to create directory: %v", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Read the file from the embedded FS
|
|
fileData, err := content.ReadFile(path)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to read file: %v", err)
|
|
}
|
|
|
|
// Create the file in the target directory
|
|
err = os.WriteFile(targetFile, fileData, 0700)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to write file: %v", err)
|
|
}
|
|
|
|
return nil
|
|
})
|
|
|
|
return err
|
|
}
|