Skip to content

Commit d3b0752

Browse files
committed
fix: give priority between the listed backends
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent a76e4d0 commit d3b0752

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

pkg/model/initializers.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9+
"slices"
910
"strings"
1011
"time"
1112

@@ -22,8 +23,11 @@ var Aliases map[string]string = map[string]string{
2223
}
2324

2425
const (
25-
LlamaGGML = "llama-ggml"
26-
LLamaCPP = "llama-cpp"
26+
LlamaGGML = "llama-ggml"
27+
LLamaCPP = "llama-cpp"
28+
29+
LLamaCPPFallback = "llama-fallback"
30+
2731
Gpt4AllLlamaBackend = "gpt4all-llama"
2832
Gpt4AllMptBackend = "gpt4all-mpt"
2933
Gpt4AllJBackend = "gpt4all-j"
@@ -62,6 +66,22 @@ ENTRY:
6266
backends = append(backends, e.Name())
6367
}
6468
}
69+
70+
priorityList := []string{
71+
// First llama.cpp and llama-ggml
72+
LLamaCPP, LLamaCPPFallback, LlamaGGML, Gpt4All,
73+
}
74+
slices.Reverse(priorityList)
75+
// order certain backends first
76+
for _, b := range priorityList {
77+
for i, be := range backends {
78+
if be == b {
79+
backends = append([]string{be}, append(backends[:i], backends[i+1:]...)...)
80+
break
81+
}
82+
}
83+
}
84+
6585
return backends, nil
6686
}
6787

0 commit comments

Comments
 (0)