forked from QuantumNous/new-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompact_suffix.go
More file actions
34 lines (30 loc) · 854 Bytes
/
Copy pathcompact_suffix.go
File metadata and controls
34 lines (30 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package ratio_setting
import "strings"
const CompactModelSuffix = "-openai-compact"
const CompactWildcardModelKey = "*" + CompactModelSuffix
func WithCompactModelSuffix(modelName string) string {
if strings.HasSuffix(modelName, CompactModelSuffix) {
return modelName
}
return modelName + CompactModelSuffix
}
func WithCompactModelVariants(models []string) []string {
variants := make([]string, 0, len(models)*2)
seen := make(map[string]struct{}, len(models)*2)
for _, model := range models {
if _, ok := seen[model]; ok {
continue
}
seen[model] = struct{}{}
variants = append(variants, model)
}
for _, model := range models {
compactModel := WithCompactModelSuffix(model)
if _, ok := seen[compactModel]; ok {
continue
}
seen[compactModel] = struct{}{}
variants = append(variants, compactModel)
}
return variants
}