mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 06:25:00 +00:00
Fix: listmodelservice / welcome endpoint use LOOSE_ONLY (#3791)
* fix list model service and welcome Signed-off-by: Dave Lee <dave@gray101.com> * comment Signed-off-by: Dave Lee <dave@gray101.com> --------- Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
parent
a0f0505f0d
commit
65ca754166
2 changed files with 10 additions and 18 deletions
|
@ -8,10 +8,10 @@ import (
|
|||
type LooseFilePolicy int
|
||||
|
||||
const (
|
||||
SKIP_IF_CONFIGURED LooseFilePolicy = iota
|
||||
LOOSE_ONLY LooseFilePolicy = iota
|
||||
SKIP_IF_CONFIGURED
|
||||
SKIP_ALWAYS
|
||||
ALWAYS_INCLUDE
|
||||
LOOSE_ONLY
|
||||
)
|
||||
|
||||
func ListModels(bcl *config.BackendConfigLoader, ml *model.ModelLoader, filter config.BackendConfigFilterFn, looseFilePolicy LooseFilePolicy) ([]string, error) {
|
||||
|
@ -21,11 +21,13 @@ func ListModels(bcl *config.BackendConfigLoader, ml *model.ModelLoader, filter c
|
|||
dataModels := []string{}
|
||||
|
||||
// Start with known configurations
|
||||
if looseFilePolicy != LOOSE_ONLY {
|
||||
for _, c := range bcl.GetBackendConfigsByFilter(filter) {
|
||||
if looseFilePolicy == SKIP_IF_CONFIGURED {
|
||||
skipMap[c.Model] = nil
|
||||
}
|
||||
|
||||
for _, c := range bcl.GetBackendConfigsByFilter(filter) {
|
||||
// Is this better than looseFilePolicy <= SKIP_IF_CONFIGURED ? less performant but more readable?
|
||||
if (looseFilePolicy == SKIP_IF_CONFIGURED) || (looseFilePolicy == LOOSE_ONLY) {
|
||||
skipMap[c.Model] = nil
|
||||
}
|
||||
if looseFilePolicy != LOOSE_ONLY {
|
||||
dataModels = append(dataModels, c.Name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue