Parlevent_ on X: Gemini served through magpie from Vertex AI was listed
as taking text and images only, never audio. Vertex AI's models, and a
relay's, come from a list that says nothing of what a model takes, so
the entry had no input kinds and every agent's fallback said
text+image (provider.Entry.Modalities' Images branch).
catalog.InputsOf is now what most of models.dev's providers list a
model with, by bare id, as SeesImages, ContextOf and the others are
voted. provider.InputsOf uses it when the model's own source said
nothing of input (InputModalities and ImageInput both nil); a source's
own word, a plugin's included, still stands, and the image kind still
follows Images (the user's override included). The GUI's model row and
every agent's list read it through the Entry. OpenCode is now told
audio, video and pdf where the model takes them (its modalities enum
holds all five), not text+image only.
So Vertex AI's gemini-3.5-flash is text, image, audio, video, pdf;
gpt-oss-120b-maas there is text; a relay's bare gemini-3.5-flash is the
same as Vertex AI's. A model models.dev doesn't know stays unknown.
Also: a video sent to a bare-listed model models.dev lists without
video is now refused at magpie ("does not support video input") as it
is for a model whose own list says so, where it went upstream before.
Run (mica, mica-run):
- the new tests: TestGeminiTakesAudioWhereverServed (provider),
TestInputsOf (catalog), TestOpenCodeInputs (agent): green; red on
e9fcc6229 with the old code (vx/gemini-3.5-flash takes [text image],
OpenCode told [text image])
- go test -count=1 -timeout 45m ./... at e9fcc6229 + this change:
98 ok; red in . (TestNoEagerPackageRegexps, chatpage.go: #6689),
internal/cli (/api/providers/delete, fixed in 4c86b0ab4) and
internal/gateway (TestKeySlotEveryRoute and LazyCat manifest, the
/deepseek-chat routes, fixed in cd030691a), none in code this touches
- again at 677034e1a + both commits: internal/cli, gateway, catalog,
provider, agent, gui ok; . red only on #6689
- go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok; gofmt -l clean
Not tried: a real Vertex AI account; Codex, Pi, dsh and omp still take
text and image only, as their configs have no other kinds.
101 lines
4.2 KiB
Go
101 lines
4.2 KiB
Go
package provider
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/catalog"
|
|
"github.com/yetone/magpie/internal/settings"
|
|
)
|
|
|
|
// geminiKindsCatalog is models.dev's rows for the models below, as
|
|
// models.dev gives them (the bundled copy, 2026-11-15): Vertex AI's Gemini
|
|
// 3.5 Flash with its audio, video and pdf, one relay that lists it with
|
|
// text and image alone, and Vertex AI's text-only GPT OSS.
|
|
const geminiKindsCatalog = `{
|
|
"google-vertex":{"id":"google-vertex","name":"Vertex","models":{
|
|
"gemini-3.5-flash":{"id":"gemini-3.5-flash","name":"Gemini 3.5 Flash","attachment":true,"reasoning":true,"tool_call":true,"release_date":"2026-05-19","modalities":{"input":["text","image","video","audio","pdf"],"output":["text"]},"limit":{"context":1048576,"output":65536}},
|
|
"openai/gpt-oss-120b-maas":{"id":"openai/gpt-oss-120b-maas","name":"GPT OSS 120B","attachment":false,"reasoning":true,"tool_call":true,"release_date":"2025-08-05","modalities":{"input":["text"],"output":["text"]},"limit":{"context":131072,"output":131072}}}},
|
|
"google":{"id":"google","name":"Google","models":{
|
|
"gemini-3.5-flash":{"id":"gemini-3.5-flash","name":"Gemini 3.5 Flash","attachment":true,"reasoning":true,"tool_call":true,"release_date":"2026-05-19","modalities":{"input":["text","image","video","audio","pdf"],"output":["text"]},"limit":{"context":1048576,"output":65536}}}},
|
|
"somerelay":{"id":"somerelay","name":"Some relay","models":{
|
|
"google/gemini-3.5-flash":{"id":"google/gemini-3.5-flash","name":"Gemini 3.5 Flash","attachment":true,"tool_call":true,"release_date":"2026-05-19","modalities":{"input":["text","image"],"output":["text"]},"limit":{"context":1048576,"output":65536}}}}
|
|
}`
|
|
|
|
func geminiKinds(t *testing.T) {
|
|
t.Helper()
|
|
if err := os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(catalog.CachePath(), []byte(geminiKindsCatalog), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
catalog.Reset()
|
|
t.Cleanup(catalog.Reset)
|
|
}
|
|
|
|
// A Gemini model a list gives bare — Vertex AI's, which magpie names
|
|
// itself, or a relay's — is said to take what models.dev says it takes
|
|
// wherever it is served: audio, video and pdf beside text and image. It
|
|
// was said to take text and image alone, as agents guess for a model they
|
|
// are told nothing of (Parlevent_ on X, Gemini on Vertex AI). A text-only
|
|
// model stays text-only, and one whose list said what it takes keeps that.
|
|
func TestGeminiTakesAudioWhereverServed(t *testing.T) {
|
|
vertexHome(t)
|
|
geminiKinds(t)
|
|
if err := Save(Provider{ID: "vx", Name: "vx", Preset: VertexPreset, Vertex: &Vertex{Project: "acme"}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := Save(Provider{ID: "relay", Name: "Relay", Gemini: "https://relay.example/v1beta", Key: "k"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := catalog.SaveLive("relay", "https://relay.example/v1beta", []catalog.Model{
|
|
{ID: "gemini-3.5-flash", Name: "gemini-3.5-flash"},
|
|
{ID: "said", InputModalities: []string{"text", "image"}, ImageInput: ptrBool(true)},
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s := settings.Load()
|
|
entry := func(pid, model string) Entry {
|
|
t.Helper()
|
|
p, err := Find(pid)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, m := range p.Exposed() {
|
|
if m.ID == model {
|
|
return entryFor(*p, m, s)
|
|
}
|
|
}
|
|
t.Fatalf("%s doesn't list %s", pid, model)
|
|
return Entry{}
|
|
}
|
|
all := []string{"text", "image", "audio", "video", "pdf"}
|
|
for _, c := range []struct {
|
|
pid, model string
|
|
in []string
|
|
}{
|
|
{"vx", "gemini-3.5-flash", all},
|
|
{"vx", "openai/gpt-oss-120b-maas", []string{"text"}},
|
|
{"relay", "gemini-3.5-flash", all},
|
|
{"relay", "said", []string{"text", "image"}},
|
|
} {
|
|
e := entry(c.pid, c.model)
|
|
if in, _ := e.Modalities(); !slices.Equal(in, c.in) {
|
|
t.Errorf("%s/%s takes %v, want %v", c.pid, c.model, in, c.in)
|
|
}
|
|
}
|
|
// the user's word on images still decides image, and the rest stays
|
|
if err := SetModelImage("vx/gemini-3.5-flash", ptrBool(false)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
s = settings.Load()
|
|
if in, _ := entry("vx", "gemini-3.5-flash").Modalities(); !slices.Equal(in, []string{"text", "audio", "video", "pdf"}) {
|
|
t.Errorf("images turned off: %v", in)
|
|
}
|
|
}
|
|
|
|
func ptrBool(v bool) *bool { return &v }
|