The Gateway page's model list showed each model's reasoning levels,
images and context, but not video or audio input, which the catalog often
knows (a model list's input_modalities, a plugin's capabilities,
models.dev).
/api/providers now carries `inputs` (video, audio, in that order) on each
model, from catalog.Model.InputModalities, and on each routing group,
from its entry's Inputs (any one of its models'). gatewayModels passes it
on, and the gateway plugin's mediaInfo adds a video and an audio glyph
chip after modelInfo's image one, with "Accepts video" / "Accepts audio"
in the tooltip ("(one of its models does)" for a group). The chips live
in the plugin, not in app.js's modelInfo, so the core scripts stay under
TestCoreScriptBudget (they were 553 bytes over in app.js). Strings in
zh, zh-TW, ja and de.
Run: at origin/main 54b6d4d39 + these three commits (c63a6d674, mica):
gofmt -l clean; go vet ./internal/{codexcat,gui,agent,gateway,provider,
catalog,usage} on darwin, GOOS=linux -tags nogui and GOOS=windows ok;
go test -count=1 of those seven packages: all ok (gui's
TestCoreScriptBudget included).
Rebased onto origin/main 21ed46106 after that run (main's gateway,
provider and i18n.js changes): provider, gui, codexcat and
gateway-model-info, i18n-keys, gui-zh-tw run again there (mica): Go all ok, GUI 8 of 9; i18n-keys is red on
"No folder" from 72facf72e on main (#6423), not this change.
The full suite runs after the tag.
GUI: gateway-model-info, gateway-model-chip-height, gateway-decide-info,
gateway-model-reasonless, group-member-info, gateway-models-open-steady,
i18n-keys, i18n-en-no-cjk, gui-de, gui-ja, gui-zh-tw, dates-gui-lang in
chromium and webkit (mote): 83 pass, 2 red, gui-de and gui-ja on the
"{agent} isn't installed here" string from fe20e4dbd, which this change
doesn't touch (#6234, already filed).
Broken by hand: mediaInputs returning nil turns TestMediaInputs and
TestGatewayListSaysVideoAndAudio red; mediaInfo returning modelInfo's box
alone turns gateway-model-info red in chromium and webkit.
Not tried: the real app with a provider whose list names video or audio.
model-chip-steady (the provider editor's chips, not this list) is red
40 of 60 here and the same 40 at origin/main 54b6d4d39 alone (#4388).
75 lines
2.4 KiB
Go
75 lines
2.4 KiB
Go
package gui
|
|
|
|
import (
|
|
"os"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// The Gateway list shows video and audio beside images when a model's
|
|
// source listed them (pingqipai3 on X): only those two, in that order,
|
|
// whatever form its list wrote them in.
|
|
func TestMediaInputs(t *testing.T) {
|
|
for _, c := range []struct {
|
|
in []string
|
|
want []string
|
|
}{
|
|
{nil, nil},
|
|
{[]string{"text", "image", "pdf"}, nil},
|
|
{[]string{"audio", "text", "video"}, []string{"video", "audio"}},
|
|
{[]string{"Video/MP4", "audio/wav"}, []string{"video", "audio"}},
|
|
{[]string{"image", "audio"}, []string{"audio"}},
|
|
} {
|
|
if got := mediaInputs(c.in); !slices.Equal(got, c.want) {
|
|
t.Errorf("mediaInputs(%q) = %q, want %q", c.in, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// What the provider's model list says it takes reaches the Gateway list:
|
|
// each model's video and audio, and a group's from any one of its models.
|
|
func TestGatewayListSaysVideoAndAudio(t *testing.T) {
|
|
t.Setenv("HOME", t.TempDir())
|
|
t.Setenv("USERPROFILE", os.Getenv("HOME"))
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
|
if err := provider.Save(provider.Provider{ID: "p", Name: "P", Key: "k", Chat: "http://127.0.0.1:1/v1",
|
|
Models: []string{"omni", "ear", "text"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := catalog.SaveLive("p", "http://127.0.0.1:1/v1", []catalog.Model{
|
|
{ID: "omni", InputModalities: []string{"text", "image", "video", "audio"}},
|
|
{ID: "ear", InputModalities: []string{"text", "audio"}},
|
|
{ID: "text", InputModalities: []string{"text"}},
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := provider.SaveGroup(provider.Group{ID: "g", Name: "G", Members: []string{"p/ear", "p/text"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := providersState()
|
|
got := map[string][]string{}
|
|
for _, p := range s.Providers {
|
|
if p.ID == "p" {
|
|
for _, m := range p.Models {
|
|
got[m.ID] = m.Inputs
|
|
}
|
|
}
|
|
}
|
|
for id, want := range map[string][]string{"omni": {"video", "audio"}, "ear": {"audio"}, "text": nil} {
|
|
if !slices.Equal(got[id], want) {
|
|
t.Errorf("%s says %q, want %q", id, got[id], want)
|
|
}
|
|
}
|
|
i := slices.IndexFunc(s.Gateway.Groups, func(g gwGroupJSON) bool { return g.ID == "group/g" })
|
|
if i < 0 {
|
|
t.Fatal("group/g isn't listed")
|
|
}
|
|
if g := s.Gateway.Groups[i]; !slices.Equal(g.Inputs, []string{"audio"}) {
|
|
t.Errorf("group/g says %q, want audio (one of its models takes it)", g.Inputs)
|
|
}
|
|
}
|