models: a name is given only to a model its provider has — magpie model name deepseek/nope X was kept and never shown; and the level none reads 不思考 in Chinese, as the other levels are named. Issue #92
This commit is contained in:
@@ -84,6 +84,7 @@ const I18N = {
|
||||
"agent default": "Agent 默认值",
|
||||
"default": "默认",
|
||||
"off": "关闭",
|
||||
"none": "不思考",
|
||||
"minimal": "最低",
|
||||
"low": "低",
|
||||
"medium": "中",
|
||||
|
||||
@@ -65,6 +65,9 @@ func SetModelName(ref, name string) error {
|
||||
if len([]rune(name)) > 80 {
|
||||
return errors.New("a model's name is at most 80 characters")
|
||||
}
|
||||
if name != "" && !p.serves(model) {
|
||||
return fmt.Errorf("%s has no model %s (magpie provider %s lists them)", p.ID, model, p.ID)
|
||||
}
|
||||
s := settings.Load()
|
||||
key := p.ID + "/" + model
|
||||
if s.ModelNames[key] == name {
|
||||
@@ -209,3 +212,10 @@ func (p Provider) ModelNames() map[string]string {
|
||||
// EffortsOf is the reasoning levels one of a provider's listed models has,
|
||||
// before any the user left out.
|
||||
func EffortsOf(m catalog.Model) []string { return effortsOf(m) }
|
||||
|
||||
// serves reports whether model is one of the provider's, listed or exposed:
|
||||
// a name given to a model it doesn't have would never be shown.
|
||||
func (p Provider) serves(model string) bool {
|
||||
has := func(m catalog.Model) bool { return m.ID == model }
|
||||
return slices.ContainsFunc(p.Available(), has) || slices.ContainsFunc(p.Exposed(), has)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func TestModelName(t *testing.T) {
|
||||
if _, ok := settings.Load().ModelNames["a/sol"]; ok {
|
||||
t.Fatal("a reset name is still kept")
|
||||
}
|
||||
for _, bad := range []string{"sol", "nobody/sol", "group/auto-sol", "a/"} {
|
||||
for _, bad := range []string{"sol", "nobody/sol", "group/auto-sol", "a/", "a/no-such-model"} {
|
||||
if err := SetModelName(bad, "x"); err == nil {
|
||||
t.Errorf("%s was named", bad)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user