mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-09 20:10:37 +00:00
* fix(i18n): clarify Go regex and field passthrough copy
* feat(channel): support Codex upstream model discovery
* Revert "fix(i18n): clarify Go regex and field passthrough copy"
This reverts commit d63d7975db.
35 lines
854 B
Go
35 lines
854 B
Go
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
|
|
}
|