mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-16 12:38:01 -04:00
feat(backends): allow backends to not have a metadata file (#5963)
In this case we generate one on the fly and we infer the metadata we can. Obviously this have the side effect of not being able to register potential aliases. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
a35a701052
commit
90f5639639
@@ -250,16 +250,22 @@ func ListSystemBackends(basePath string) (map[string]string, error) {
|
||||
for _, backend := range backends {
|
||||
if backend.IsDir() {
|
||||
runFile := filepath.Join(basePath, backend.Name(), runFile)
|
||||
// Skip if metadata file don't exist
|
||||
|
||||
var metadata *BackendMetadata
|
||||
|
||||
// If metadata file does not exist, we just use the directory name
|
||||
// and we do not fill the other metadata (such as potential backend Aliases)
|
||||
metadataFilePath := filepath.Join(basePath, backend.Name(), metadataFile)
|
||||
if _, err := os.Stat(metadataFilePath); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check for alias in metadata
|
||||
metadata, err := readBackendMetadata(filepath.Join(basePath, backend.Name()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
metadata = &BackendMetadata{
|
||||
Name: backend.Name(),
|
||||
}
|
||||
} else {
|
||||
// Check for alias in metadata
|
||||
metadata, err = readBackendMetadata(filepath.Join(basePath, backend.Name()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if metadata == nil {
|
||||
|
||||
Reference in New Issue
Block a user