providers: an Ark key's Seedance models are under Video models in its editor, each to tick
axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没 有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor listed its Seedream models under Image models, to tick, and had its Seedance models among the chat models or nowhere. Cause, two parts: - The editor had no video section at all: video models had no list and no hidden set (gateway-routing.md said "Video models aren't listed in the editor, so there is nothing to hide there"). - catalog's live parse read only "kind" and modalities.input/output. Ark's /api/v3/models marks no kind: it says domain "VideoGeneration" / "ImageGeneration" and modalities.input_modalities/output_modalities. So Seedance came back as a chat model, and 3D models (output 3d, no text) as chat models too. Change: - catalog: a live row with no kind is a video model when its domain is VideoGeneration or it outputs video without text, an image model for ImageGeneration or image without text; Ark's input_modalities / output_modalities are read when input/output aren't there, so a model that gives no text (Ark's 3D) is left out of the chat list. TestFetchArkMarksVideoModels runs on a captured Ark list (testdata/volcengine-ark-models-2026-11-03.json, fetched read-only with GET /api/v3/models, no key in it). - provider: HiddenVideomakers beside HiddenDrawers, VideomakerHidden. - gateway: VideomakersOf (Videomakers on a given list, for the editor), OfferedVideomakers = Videomakers less the unticked ones, read by AutoVideomaker, videomakerObjects (another magpie's list) and mediaModels(true) (generate_video). A hidden one still makes its video when named: bareVideomaker, videosCreate and arkFilms read Videomakers. - gui: the editor's Video models section (renderVideomakers), filmIds and hiddenVideomakers on /api/providers, kept on save as hiddenDrawers is; i18n for every language. app.js comments cut to stay under TestCoreScriptBudget, which this change reached; no raise. - docs: gateway-routing.md's Hidden image models section. Old data: an Ark list fetched before keeps Seedance among its chat models until its list is fetched again; customVideomakers already counts any Seedance id an Ark key lists or picks as a video model, so it makes videos and shows under Video models now. Run on mote, this change and the next (/v1/models ?kind=, gateway and docs only) rebased on f4c664a09; this commit's own tree, on17f2387e1, gave the same Go results with Linux and Windows vet of ./internal/... clean: - go test -count=1 -timeout 45m ./internal/catalog ./internal/provider ./internal/gateway ./internal/gui: catalog, provider and gateway ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, red on main). - GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: nothing. - GUI (at the next commit's tree, which adds no GUI file or script): the 51 provider-*, drawers, image-models, i18n and video-models-hide files, both engines, every language, wide and narrow: 1161 of 1188 ok. The 27 reds are 5 files that are red the same 27 at origin/maind1cdce130run alone: provider-fetch-again (#3292/#5057), provider-models-rest (#4396), provider-picks-stay (#4397), provider-levels-scroll (#4395), provider-typed (#4673). video-models-hide: 22 of 22 ok. - The whole GUI suite (all files) ran earlier at this change on8af751987, 347 of 19153 red at load 100 to 200; the 66 files with a red, run again alone, are red in the same tests at origin/main17f2387e1(all filed: #4388, #4391, #4398, #4320, #4541/#5013, #2564, #4244, #4304 and the above). Rebased again ontod1cdce130(sessions, Cursor mover, library and routing plugins, group-unlists; nothing this change touches but gateway.go, which merged clean) and run there: TestCoreScriptBudget and internal/gui's new tests, the gateway's ?kind= and video tests, internal/provider and internal/catalog, video-models-hide 22 of 22: ok. Broken by hand, each red, then put back: - the domain/output check in catalog's live parse: TestFetchArkMarksVideoModels red - OfferedVideomakers returning Videomakers whole: TestHiddenVideomakerLeavesListsButStillFilms red - the editor's filmIds left empty: TestVideoModelsHidden red - a save without hiddenVideomakers dropping the old ones: TestVideoModelsHidden red - renderVideomakers' call in the editor left out: video-models-hide 22 of 22 red - a chip's click not changing the draft: video-models-hide 22 of 22 red Not tried: no real Ark video was made (no money spent); the list parse was checked on a real Ark list fetched read-only. The editor was not opened in the real app, only in the GUI tests' fake API. Credit: axelburks on Discord.
This commit is contained in:
@@ -718,7 +718,9 @@ order, prompt masking (fails closed), and usage records.
|
||||
|
||||
A custom provider (no account, no preset plan's videos) makes videos the
|
||||
same OpenAI way (#1446, `customVideomakers`), but only with the models its
|
||||
own fetched list marks `"kind": "video"` (`catalog.LiveVideomakers`) or the
|
||||
own fetched list marks `"kind": "video"`, or, with no `kind`, `domain`
|
||||
`VideoGeneration` or video out without text in `output_modalities`, as
|
||||
Volcengine Ark's list does (`catalog.LiveVideomakers`), or the
|
||||
user marks a video model (settings' `ModelKinds`, `provider.SetModelKind`,
|
||||
a model chip's right-click *Makes…* in the editor, #1399); a name alone
|
||||
never makes a model a video maker. A plugin's provider makes videos with the
|
||||
@@ -1739,7 +1741,8 @@ project. Settings › Models shows the address (`#imageMcpRow`, below
|
||||
Discord), in [`image_mcp_models.go`](../../internal/gateway/image_mcp_models.go).
|
||||
`mediaModels` lists what may be asked, as provider/model: Settings' default
|
||||
first (`Drawer`, `videomaker`), then each provider's `OfferedDrawers` (a
|
||||
model the user unticked is left out) or `Videomakers`, from providers that
|
||||
model the user unticked is left out) or `OfferedVideomakers` (likewise),
|
||||
from providers that
|
||||
are on and not decide-only. `mediaModelsFor` keeps only those the calling
|
||||
key may use (`refAllowed`: `allows`, or `groupAllowed` for a group ref). The
|
||||
schema's `model` is an `enum` of them, or, past 40 (`mediaEnumMost`), a
|
||||
@@ -1848,11 +1851,31 @@ and `drawingModel` read `Drawers`, so a request that names one, or a
|
||||
Settings › Images pick made before it was hidden, draws as before. That
|
||||
pick stays listed as picked, and `imageGenHidden` puts a line under the
|
||||
row that it is unticked and leaves the list once another is picked.
|
||||
Refusing a model outright is Disabled models, below. Video models aren't
|
||||
listed in the editor, so there is nothing to hide there.
|
||||
Refusing a model outright is Disabled models, below.
|
||||
|
||||
Video models are listed the same way, under Video models (axelburks on
|
||||
Discord: an Ark key's Seedance had nowhere to be ticked). The editor's
|
||||
`filmIds` are `gateway.VideomakersOf` the listing it already has, and an
|
||||
unticked one is saved in `provider.HiddenVideomakers`, kept and cleared as
|
||||
`hiddenDrawers` is. `gateway.OfferedVideomakers` is `Videomakers` less the
|
||||
hidden ones, read by `AutoVideomaker`, `videomakerObjects` and
|
||||
`mediaModels(true)`. A hidden one still makes its video when named:
|
||||
`bareVideomaker`, `videosCreate` and `arkFilms` read `Videomakers`.
|
||||
|
||||
An Ark key's list marks its video and image models by `domain`
|
||||
(`VideoGeneration`, `ImageGeneration`) and
|
||||
`modalities.output_modalities`, with no `kind`; `catalog`'s live parse
|
||||
reads both, so Seedance is a video model there and no longer a chat
|
||||
model, and 3D, embedding and other models that give no text are left out
|
||||
(`TestFetchArkMarksVideoModels`, on a captured list). An Ark list fetched
|
||||
before has Seedance among its chat models until the next fetch;
|
||||
`customVideomakers` still counts any Seedance id an Ark key lists or
|
||||
picks as a video model.
|
||||
|
||||
Covered by `TestHiddenDrawerLeavesListsButStillDraws`,
|
||||
`TestImageModelsHidden` and `internal/gui/tests/image-models-hide.test.cjs`.
|
||||
`TestImageModelsHidden`, `internal/gui/tests/image-models-hide.test.cjs`,
|
||||
`TestHiddenVideomakerLeavesListsButStillFilms`, `TestVideoModelsHidden`
|
||||
and `internal/gui/tests/video-models-hide.test.cjs`.
|
||||
|
||||
## Disabled models
|
||||
|
||||
|
||||
@@ -637,9 +637,24 @@ func fetchPage(ctx context.Context, url, key string, anthropic bool, headers map
|
||||
// its retrieval models too; a vendor's general list still leaves
|
||||
// out models agents can't chat with.
|
||||
decision := r.Kind == "decision"
|
||||
films := r.Kind == "video"
|
||||
drawer := !films && !decision && (DrawsID(id) && !strings.Contains(strings.ToLower(id), "deep-research") || r.Kind == "image")
|
||||
if !drawer && !films && !decision && headers["X-Magpie-Drawers"] == "" && !textModel(mdModel{ID: id}) {
|
||||
ins, outs := Kinds(r.Modalities.Input), Kinds(r.Modalities.Output)
|
||||
if ins == nil && outs == nil {
|
||||
// Volcengine Ark's names: {"input_modalities": […],
|
||||
// "output_modalities": ["video"]}
|
||||
ins, outs = Kinds(r.Modalities.InputModalities), Kinds(r.Modalities.OutputModalities)
|
||||
}
|
||||
// a model the list says makes videos: another magpie's kind, or,
|
||||
// where the list marks no kind, Ark's domain "VideoGeneration" or
|
||||
// an output of video without text (doubao-seedance-*, wan2-1-*),
|
||||
// which is no model to chat with (axelburks on Discord: Ark's
|
||||
// Seedance sat among its chat models, not under Video models)
|
||||
films := r.Kind == "video" || r.Kind == "" && (r.Domain == "VideoGeneration" || slices.Contains(outs, "video") && !slices.Contains(outs, "text"))
|
||||
drawer := !films && !decision && (DrawsID(id) && !strings.Contains(strings.ToLower(id), "deep-research") || r.Kind == "image" ||
|
||||
r.Kind == "" && (r.Domain == "ImageGeneration" || slices.Contains(outs, "image") && !slices.Contains(outs, "text")))
|
||||
// and none the list says answers without text (Ark's 3D models)
|
||||
md := mdModel{ID: id}
|
||||
md.Modalities.Output = outs
|
||||
if !drawer && !films && !decision && headers["X-Magpie-Drawers"] == "" && !textModel(md) {
|
||||
continue
|
||||
}
|
||||
name, plain := r.DisplayName, ""
|
||||
@@ -657,7 +672,6 @@ func fetchPage(ctx context.Context, url, key string, anthropic bool, headers map
|
||||
if name == "" {
|
||||
name = id
|
||||
}
|
||||
ins, outs := Kinds(r.Modalities.Input), Kinds(r.Modalities.Output)
|
||||
input := imageInput(ins)
|
||||
apis := EndpointAPIs(r.Endpoints)
|
||||
if native := EndpointAPIs(r.Native); len(native) > 0 {
|
||||
@@ -729,7 +743,13 @@ type liveModel struct {
|
||||
Modalities struct {
|
||||
Input []string `json:"input"`
|
||||
Output []string `json:"output"`
|
||||
// Volcengine Ark's
|
||||
InputModalities []string `json:"input_modalities"`
|
||||
OutputModalities []string `json:"output_modalities"`
|
||||
} `json:"modalities"`
|
||||
// what Volcengine Ark's list says a model is for: "LLM",
|
||||
// "VideoGeneration", "ImageGeneration"…
|
||||
Domain string `json:"domain"`
|
||||
// the paths the model is served on, where the vendor says: Command
|
||||
// Code's Claude models on /messages alone, its open ones on
|
||||
// /chat/completions and /responses
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package catalog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Volcengine Ark's own /api/v3/models, rows of a pay-as-you-go key's real
|
||||
// reply (2026-11-03): it marks no "kind", but says each model's domain and
|
||||
// its output_modalities. A Seedance (domain VideoGeneration, output video)
|
||||
// and a wan2-1 (no domain, output video) are video models, out of the chat
|
||||
// list and in LiveVideomakers (axelburks on Discord: Ark's Seedance sat
|
||||
// among the chat models, and the editor had no Video models to tick);
|
||||
// Seedream draws, the one listed with no modalities too; a 3D model
|
||||
// (output three_d) is no chat model; the text models stay.
|
||||
func TestFetchArkMarksVideoModels(t *testing.T) {
|
||||
body, err := os.ReadFile("testdata/volcengine-ark-models-2026-11-03.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(body)
|
||||
}))
|
||||
defer srv.Close()
|
||||
ms, _, err := FetchAt(context.Background(), srv.URL+"/api/v3", "k", false, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var films, draws, chat []string
|
||||
for _, m := range ms {
|
||||
switch {
|
||||
case m.Films:
|
||||
films = append(films, m.ID)
|
||||
case m.Draws:
|
||||
draws = append(draws, m.ID)
|
||||
default:
|
||||
chat = append(chat, m.ID)
|
||||
}
|
||||
}
|
||||
slices.Sort(films)
|
||||
slices.Sort(draws)
|
||||
slices.Sort(chat)
|
||||
if want := []string{"doubao-seedance-1-0-pro-250528", "doubao-seedance-1-0-pro-fast-251015", "doubao-seedance-2-0-260128", "wan2-1-14b-t2v-250225"}; !slices.Equal(films, want) {
|
||||
t.Errorf("video models %v, want %v", films, want)
|
||||
}
|
||||
if want := []string{"doubao-seedream-5-0-flash-260915", "doubao-seedream-5-0-pro-260628"}; !slices.Equal(draws, want) {
|
||||
t.Errorf("image models %v, want %v", draws, want)
|
||||
}
|
||||
if want := []string{"doubao-seed-2-1-pro-260915", "doubao-seed-translation-250915", "kimi-k3-1-pro-261024"}; !slices.Equal(chat, want) {
|
||||
t.Errorf("chat models %v, want %v", chat, want)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
{
|
||||
"object": "list",
|
||||
"data": [
|
||||
{
|
||||
"created": 1744343828,
|
||||
"domain": "",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "wan2-1-14b-t2v-250225",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text"
|
||||
],
|
||||
"output_modalities": [
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"name": "wan2-1-14b",
|
||||
"object": "model",
|
||||
"status": "Shutdown",
|
||||
"task_type": [
|
||||
"TextToVideo"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "t2v-250225"
|
||||
},
|
||||
{
|
||||
"created": 1749465881,
|
||||
"domain": "VideoGeneration",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seedance-1-0-pro-250528",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"first_frame",
|
||||
"first_last_frame"
|
||||
],
|
||||
"output_modalities": [
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seedance-1-0-pro",
|
||||
"object": "model",
|
||||
"status": "Retiring",
|
||||
"task_type": [
|
||||
"ImageToVideo",
|
||||
"TextToVideo"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "250528"
|
||||
},
|
||||
{
|
||||
"created": 1760414492,
|
||||
"domain": "VideoGeneration",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seedance-1-0-pro-fast-251015",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image"
|
||||
],
|
||||
"output_modalities": [
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seedance-1-0-pro-fast",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"ImageToVideo",
|
||||
"TextToVideo"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "251015"
|
||||
},
|
||||
{
|
||||
"created": 1764645281,
|
||||
"domain": "",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-embedding-vision-251215",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image",
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"name": "doubao-embedding-vision",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"ImageEmbedding"
|
||||
],
|
||||
"token_limits": {
|
||||
"context_window": 131072,
|
||||
"max_input_token_length": 131072
|
||||
},
|
||||
"version": "251215"
|
||||
},
|
||||
{
|
||||
"created": 1770189126,
|
||||
"domain": "VideoGeneration",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seedance-2-0-260128",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image",
|
||||
"video",
|
||||
"audio"
|
||||
],
|
||||
"output_modalities": [
|
||||
"video"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seedance-2-0",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"MultimodalToVideo",
|
||||
"VideoExtension",
|
||||
"VideoEditing"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "260128"
|
||||
},
|
||||
{
|
||||
"created": 1775281921,
|
||||
"domain": "3DGeneration",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seed3d-2-0-260328",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"image"
|
||||
],
|
||||
"output_modalities": [
|
||||
"three_d"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seed3d-2-0",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"ImageTo3D"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "260328"
|
||||
},
|
||||
{
|
||||
"created": 1782821774,
|
||||
"domain": "ImageGeneration",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seedream-5-0-pro-260628",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image"
|
||||
],
|
||||
"output_modalities": [
|
||||
"image"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seedream-5-0-pro",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"ImageToImage",
|
||||
"TextToImage"
|
||||
],
|
||||
"token_limits": {},
|
||||
"version": "260628"
|
||||
},
|
||||
{
|
||||
"created": 1789472816,
|
||||
"domain": "VLM",
|
||||
"features": {
|
||||
"batch": {
|
||||
"batch_chat": false,
|
||||
"batch_job": false
|
||||
},
|
||||
"cache": {
|
||||
"prefix_cache": false,
|
||||
"session_cache": false
|
||||
},
|
||||
"structured_outputs": {
|
||||
"json_object": true,
|
||||
"json_schema": true
|
||||
},
|
||||
"tools": {
|
||||
"function_calling": true
|
||||
}
|
||||
},
|
||||
"id": "doubao-seed-2-1-pro-260915",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image",
|
||||
"video"
|
||||
],
|
||||
"output_modalities": [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seed-2-1-pro",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"VisualQuestionAnswering",
|
||||
"TextGeneration"
|
||||
],
|
||||
"token_limits": {
|
||||
"context_window": 1048576,
|
||||
"max_input_token_length": 1048576,
|
||||
"max_output_token_length": 262144,
|
||||
"max_reasoning_token_length": 262144
|
||||
},
|
||||
"version": "260915"
|
||||
},
|
||||
{
|
||||
"created": 1789531767,
|
||||
"domain": "ImageGeneration",
|
||||
"features": {
|
||||
"tools": {
|
||||
"function_calling": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seedream-5-0-flash-260915",
|
||||
"name": "doubao-seedream-5-0-flash",
|
||||
"object": "model",
|
||||
"version": "260915"
|
||||
},
|
||||
{
|
||||
"created": 1792808954,
|
||||
"domain": "LLM",
|
||||
"features": {
|
||||
"batch": {
|
||||
"batch_chat": false,
|
||||
"batch_job": false
|
||||
},
|
||||
"cache": {
|
||||
"prefix_cache": true,
|
||||
"session_cache": true
|
||||
},
|
||||
"structured_outputs": {
|
||||
"json_object": true,
|
||||
"json_schema": true
|
||||
},
|
||||
"tools": {
|
||||
"function_calling": true
|
||||
}
|
||||
},
|
||||
"id": "kimi-k3-1-pro-261024",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text",
|
||||
"image",
|
||||
"video"
|
||||
],
|
||||
"output_modalities": [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"name": "kimi-k3-1-pro",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"TextGeneration"
|
||||
],
|
||||
"token_limits": {
|
||||
"context_window": 1048576,
|
||||
"max_input_token_length": 1048576,
|
||||
"max_output_token_length": 131072,
|
||||
"max_reasoning_token_length": 131072
|
||||
},
|
||||
"version": "261024"
|
||||
},
|
||||
{
|
||||
"created": 1758007209,
|
||||
"domain": "LLM",
|
||||
"features": {
|
||||
"structured_outputs": {
|
||||
"json_object": false,
|
||||
"json_schema": false
|
||||
},
|
||||
"tools": {
|
||||
"function_calling": false
|
||||
}
|
||||
},
|
||||
"id": "doubao-seed-translation-250915",
|
||||
"modalities": {
|
||||
"input_modalities": [
|
||||
"text"
|
||||
],
|
||||
"output_modalities": [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"name": "doubao-seed-translation",
|
||||
"object": "model",
|
||||
"task_type": [
|
||||
"TextGeneration"
|
||||
],
|
||||
"token_limits": {
|
||||
"context_window": 4096,
|
||||
"max_input_token_length": 1024,
|
||||
"max_output_token_length": 3072
|
||||
},
|
||||
"version": "250915"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1423,7 +1423,7 @@ func videomakerObjects(r *http.Request) []map[string]any {
|
||||
if !p.On() || p.DecideOnly() {
|
||||
continue
|
||||
}
|
||||
for _, m := range Videomakers(p) {
|
||||
for _, m := range OfferedVideomakers(p) {
|
||||
if held && (!modelAllowed(who, p, m.ID) || !accountServes(who, p, m.ID)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ const mediaEnumMost = 40
|
||||
// first, and the default itself: "" when image generation is off or
|
||||
// nothing makes them. Image models are each provider's OfferedDrawers (one
|
||||
// the user unticked is left out, as Automatic leaves it), videos its
|
||||
// Videomakers.
|
||||
// OfferedVideomakers (one unticked left out the same way).
|
||||
func mediaModels(video bool) (all []string, def string) {
|
||||
if video {
|
||||
def, _ = videomaker()
|
||||
@@ -52,7 +52,7 @@ func mediaModels(video bool) (all []string, def string) {
|
||||
if !p.On() || p.DecideOnly() {
|
||||
continue
|
||||
}
|
||||
ms := Videomakers(p)
|
||||
ms := OfferedVideomakers(p)
|
||||
if !video {
|
||||
ms = OfferedDrawers(p)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,12 @@ const videoTimeout = 5 * time.Minute
|
||||
// implements that vendor's video API, a MiniMax API key's H3 models
|
||||
// (video_minimax.go), and those a provider's own model list marks as video
|
||||
// models (customVideomakers).
|
||||
func Videomakers(p provider.Provider) []catalog.Model {
|
||||
func Videomakers(p provider.Provider) []catalog.Model { return VideomakersOf(p, p.Available) }
|
||||
|
||||
// VideomakersOf is Videomakers with p's model list from avail, called only
|
||||
// when it is wanted, as DrawersOf is: the Providers page has each
|
||||
// provider's list at hand. What avail gives is only read.
|
||||
func VideomakersOf(p provider.Provider, avail func() []catalog.Model) []catalog.Model {
|
||||
if p.IsRemoteMagpie() {
|
||||
out := catalog.LiveVideomakers(p.ID)
|
||||
for i := range out {
|
||||
@@ -83,7 +88,7 @@ func Videomakers(p provider.Provider) []catalog.Model {
|
||||
return minimaxVideomakers(p)
|
||||
}
|
||||
if !drawsGrok(p) {
|
||||
return customVideomakers(p)
|
||||
return customVideomakersOf(p, avail)
|
||||
}
|
||||
out := slices.Clone(grokVideoModels)
|
||||
for i := range out {
|
||||
@@ -92,6 +97,19 @@ func Videomakers(p provider.Provider) []catalog.Model {
|
||||
return out
|
||||
}
|
||||
|
||||
// OfferedVideomakers are Videomakers less those the user unticked in p's
|
||||
// editor (provider.HiddenVideomakers, axelburks on Discord), as
|
||||
// OfferedDrawers are of its image models: the video models a list offers to
|
||||
// pick from and Automatic picks among. A request that names a hidden one
|
||||
// still makes its video (bareVideomaker and videosCreate read Videomakers).
|
||||
func OfferedVideomakers(p provider.Provider) []catalog.Model {
|
||||
ms := Videomakers(p)
|
||||
if len(p.HiddenVideomakers) == 0 {
|
||||
return ms
|
||||
}
|
||||
return slices.DeleteFunc(slices.Clone(ms), func(m catalog.Model) bool { return p.VideomakerHidden(m.ID) })
|
||||
}
|
||||
|
||||
// customVideomakers are the video models of a provider set up with a base
|
||||
// URL — not a subscription's account, not another magpie, not a preset plan
|
||||
// whose own video API magpie speaks — that its fetched model list marks
|
||||
@@ -103,9 +121,13 @@ func Videomakers(p provider.Provider) []catalog.Model {
|
||||
// are the models it says give video (capabilities.output.video), asked
|
||||
// through its fetch on the account (XYenon's Google AI Studio plugin, Veo).
|
||||
func customVideomakers(p provider.Provider) []catalog.Model {
|
||||
return customVideomakersOf(p, p.Available)
|
||||
}
|
||||
|
||||
func customVideomakersOf(p provider.Provider, avail func() []catalog.Model) []catalog.Model {
|
||||
if p.IsPlugin() && !drawsGrok(p) {
|
||||
var out []catalog.Model
|
||||
for _, m := range p.Available() {
|
||||
for _, m := range avail() {
|
||||
if slices.Contains(m.OutputModalities, "video") {
|
||||
m.Provider = p.ID
|
||||
out = append(out, m)
|
||||
@@ -123,9 +145,12 @@ func customVideomakers(p provider.Provider) []catalog.Model {
|
||||
if isArk(p) {
|
||||
// a Volcengine Ark key's Seedance models (pay-as-you-go, or one
|
||||
// added by hand), those its list has and those the user picked, as
|
||||
// Drawers takes a Seedream: its list marks no kind, and Ark makes
|
||||
// them at its own content-generation tasks (arkFilms)
|
||||
ms := p.Available()
|
||||
// Drawers takes a Seedream; Ark makes them at its own
|
||||
// content-generation tasks (arkFilms). A list fetched now has them
|
||||
// as LiveVideomakers already (its domain VideoGeneration); one
|
||||
// fetched before has them among its chat models, until the next
|
||||
// fetch
|
||||
ms := slices.Clone(avail())
|
||||
for _, id := range p.Models {
|
||||
ms = append(ms, catalog.Model{ID: id, Name: id})
|
||||
}
|
||||
@@ -255,7 +280,7 @@ func AutoVideomaker() string {
|
||||
if !p.On() || p.DecideOnly() {
|
||||
continue
|
||||
}
|
||||
if ms := Videomakers(p); len(ms) > 0 {
|
||||
if ms := OfferedVideomakers(p); len(ms) > 0 {
|
||||
if filmsMiniMax(p) {
|
||||
if paid == "" {
|
||||
paid = p.ID + "/" + ms[0].ID
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// axelburks on Discord: a Volcengine Ark key's Seedance models are ticked
|
||||
// in its editor as its Seedream ones are. One unticked there
|
||||
// (HiddenVideomakers) leaves generate_video's list, another magpie's list
|
||||
// and Automatic, and still makes its video when named; its image models
|
||||
// are left as they were.
|
||||
func TestHiddenVideomakerLeavesListsButStillFilms(t *testing.T) {
|
||||
fresh(t)
|
||||
was := isArk
|
||||
isArk = func(p provider.Provider) bool { return p.ID == "ark" }
|
||||
t.Cleanup(func() { isArk = was })
|
||||
if err := provider.Save(provider.Provider{ID: "ark", Name: "Volcengine Ark", Chat: "https://ark.example/api/v3", Key: "key",
|
||||
Models: []string{"doubao-seed-2-1-pro-260915"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// the list as Ark gives it now: Seedance marked as video models, no
|
||||
// longer among the chat ones (catalog's TestFetchArkMarksVideoModels)
|
||||
if err := catalog.SaveLive("ark", "https://ark.example/api/v3", []catalog.Model{
|
||||
{ID: "doubao-seed-2-1-pro-260915"},
|
||||
{ID: "doubao-seedance-2-0-260128", Films: true},
|
||||
{ID: "doubao-seedance-2-0-fast-260128", Films: true},
|
||||
{ID: "doubao-seedream-5-0-pro-260628", Draws: true},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
set := func(hidden []string) provider.Provider {
|
||||
t.Helper()
|
||||
found, err := provider.Find("ark")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p := *found
|
||||
p.HiddenVideomakers = hidden
|
||||
if err := provider.Save(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
found, _ = provider.Find("ark")
|
||||
return *found
|
||||
}
|
||||
ids := func(ms []catalog.Model) (out []string) {
|
||||
for _, m := range ms {
|
||||
out = append(out, m.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
p := set(nil)
|
||||
if got := ids(OfferedVideomakers(p)); !slices.Equal(got, []string{"doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128"}) {
|
||||
t.Fatalf("offered with none hidden %v", got)
|
||||
}
|
||||
|
||||
p = set([]string{"doubao-seedance-2-0-260128"})
|
||||
if !slices.Equal(p.HiddenVideomakers, []string{"doubao-seedance-2-0-260128"}) {
|
||||
t.Fatalf("saved %v", p.HiddenVideomakers)
|
||||
}
|
||||
if got := ids(OfferedVideomakers(p)); !slices.Equal(got, []string{"doubao-seedance-2-0-fast-260128"}) {
|
||||
t.Fatalf("offered %v", got)
|
||||
}
|
||||
if got := ids(Videomakers(p)); !slices.Contains(got, "doubao-seedance-2-0-260128") {
|
||||
t.Fatalf("videomakers lost the hidden one: %v", got)
|
||||
}
|
||||
if got := ids(OfferedDrawers(p)); !slices.Equal(got, []string{"doubao-seedream-5-0-pro-260628"}) {
|
||||
t.Fatalf("a hidden video model changed the image models: %v", got)
|
||||
}
|
||||
var listed []string
|
||||
for _, o := range videomakerObjects(httptest.NewRequest(http.MethodGet, "/v1/models", nil)) {
|
||||
listed = append(listed, o["id"].(string))
|
||||
}
|
||||
if !slices.Equal(listed, []string{"ark/doubao-seedance-2-0-fast-260128"}) {
|
||||
t.Fatalf("video objects %v", listed)
|
||||
}
|
||||
if a := AutoVideomaker(); a != "ark/doubao-seedance-2-0-fast-260128" {
|
||||
t.Fatalf("automatic %q", a)
|
||||
}
|
||||
if all, def := mediaModels(true); !slices.Equal(all, []string{"ark/doubao-seedance-2-0-fast-260128"}) || def != all[0] {
|
||||
t.Fatalf("generate_video's list %v %q", all, def)
|
||||
}
|
||||
// named, it still makes its video, at Ark's tasks
|
||||
if q, id, ok := bareVideomaker("doubao-seedance-2-0-260128"); !ok || q.ID != "ark" || id != "doubao-seedance-2-0-260128" {
|
||||
t.Fatalf("bare hidden: %v %q %v", q.ID, id, ok)
|
||||
}
|
||||
if !arkFilms(p, "doubao-seedance-2-0-260128") {
|
||||
t.Fatal("a hidden Seedance isn't made at Ark's tasks")
|
||||
}
|
||||
|
||||
p = set([]string{"doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128"})
|
||||
if a := AutoVideomaker(); a != "" {
|
||||
t.Fatalf("automatic with every model hidden: %q", a)
|
||||
}
|
||||
}
|
||||
+24
-27
@@ -9006,11 +9006,7 @@ const modelAPIs = (p) => {
|
||||
return urls.length < 2 ? [] : PROTOS.filter(([k]) => urls.includes(k));
|
||||
};
|
||||
|
||||
// pickedOf: the models the user picked for p, as its editor starts them.
|
||||
// Only the picks: with none, agents are served the vendor's list (its
|
||||
// first 24), which the models list marks on too; taking those as picks
|
||||
// drew them ticked on opening and the next Save wrote them as picks, so
|
||||
// Select none and Save came back as 24 ticked (#614).
|
||||
// pickedOf: the models the user picked for p, only the picks (#614).
|
||||
function pickedOf(p) {
|
||||
const on = p.models.filter((m) => m.on);
|
||||
if (!Array.isArray(p.chosen)) return on.map((m) => m.id); // no picks said: those served, as before
|
||||
@@ -9020,11 +9016,7 @@ function pickedOf(p) {
|
||||
return p.models.filter((m) => (m.on || m.noAPI) && picks.has(m.id)).map((m) => m.id);
|
||||
}
|
||||
|
||||
// baseAPIOf is the API a saved provider's Base URL is shown as: the one the
|
||||
// user picked and saved (baseAPI), while it has a URL, else the first that
|
||||
// has one. Without the pick, a provider with a chat URL beside its Responses
|
||||
// one came back as OpenAI compatible after Responses was picked and saved
|
||||
// (01huadalang).
|
||||
// baseAPIOf: the API a saved Base URL is shown as, the saved pick first (01huadalang).
|
||||
function baseAPIOf(p) {
|
||||
const picked = p.baseAPI === "chat" ? "openai" : p.baseAPI;
|
||||
if (picked && p[apiField[picked]]) return picked;
|
||||
@@ -9033,13 +9025,10 @@ function baseAPIOf(p) {
|
||||
|
||||
// draftOf is a saved provider as its editor's form holds it.
|
||||
function draftOf(p) {
|
||||
return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, insecureTLS: !!p.insecureTLS, limitRestOff: !!p.limitRestOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: !!p.passUserAgent, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) };
|
||||
return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], hiddenVideomakers: [...(p.hiddenVideomakers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, insecureTLS: !!p.insecureTLS, limitRestOff: !!p.limitRestOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: !!p.passUserAgent, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) };
|
||||
}
|
||||
|
||||
// duplicateProvider opens the Add form on a copy of p (#268): its URLs,
|
||||
// headers, models, balance and proxy, under a name of its own. The key is
|
||||
// p's unless another is pasted: the Add takes it from p, with its other
|
||||
// keys (copyOf). A signed-in account has no copy.
|
||||
// duplicateProvider opens the Add form on a copy of p, its key p's unless another is pasted (#268).
|
||||
function duplicateProvider(p) {
|
||||
const name = t("{name} copy", { name: p.name });
|
||||
editing = p.preset && providers.presets.some((x) => x.id === p.preset) ? { preset: p.preset } : { custom: true };
|
||||
@@ -9336,6 +9325,7 @@ function drawEditor(p, presetID) {
|
||||
}
|
||||
ed.append(...field(t("Models"), renderModels(p), pluginFilterNote(subOf(a.agent))));
|
||||
if (p.drawIds?.length) ed.append(...renderDrawers(p));
|
||||
if (p.filmIds?.length) ed.append(...renderVideomakers(p));
|
||||
// a subscription's window too: Codex's backend says 272K for models
|
||||
// that take 872K (#120)
|
||||
const cx = input(draft.contexts || "", t("e.g. 128k · or gpt-6=1m, comma separated"));
|
||||
@@ -9397,7 +9387,7 @@ function drawEditor(p, presetID) {
|
||||
if (priceTypedError(ed)) return;
|
||||
const picked = accountModelsDraft(p);
|
||||
if (picked === false) return pickError();
|
||||
const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), bestInFamily: bestChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, maxAccounts, ...queue, priceRate, rateWindows, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, unredacted: !!draft.unredacted, countFree: !!draft.countFree, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
|
||||
const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), bestInFamily: bestChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, hiddenVideomakers: draft.hiddenVideomakers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, maxAccounts, ...queue, priceRate, rateWindows, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, unredacted: !!draft.unredacted, countFree: !!draft.countFree, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
|
||||
saving(saveBtn, t("Saving…"));
|
||||
saveAccountModelsDraft(picked).then(() => savePluginOptions(subOf(a.agent))).then(() => providerAction("save", body, t("{name} saved", { name: p.name })), (e) => { doneSaving(saveBtn); editorError(e.message || String(e)); }); };
|
||||
bar.append(cancel, saveBtn);
|
||||
@@ -9782,6 +9772,7 @@ function drawEditor(p, presetID) {
|
||||
// add page for one where they must type them
|
||||
else if (pr?.id === "azure") ed.append(...field(t("Models"), el("div", "hint azure-models", t("No need to type them: once added, magpie lists the deployments this key can call. Type a deployment's name as a model id only if that list can't be fetched.")), ""));
|
||||
if (p?.drawIds?.length) ed.append(...renderDrawers(p));
|
||||
if (p?.filmIds?.length) ed.append(...renderVideomakers(p));
|
||||
{
|
||||
// the window agents are told a model has, over what the vendor or
|
||||
// models.dev says: one for all of them, and model=size for one
|
||||
@@ -9990,7 +9981,7 @@ function drawEditor(p, presetID) {
|
||||
body.baseAPI = draft.api === "openai" ? "chat" : draft.api;
|
||||
}
|
||||
if (custom) { body.icon = draft.icon || "generic"; body.iconFrom = draft.iconFrom || ""; body.balanceURL = (draft.balanceURL || "").trim(); body.balancePath = (draft.balancePath || "").trim(); body.balanceMethod = draft.balanceMethod || ""; body.modelsURL = (draft.modelsURL || "").trim(); }
|
||||
if (p) { body.fallback = draft.fallback; body.unlisted = draft.unlisted; body.hiddenDrawers = draft.hiddenDrawers; body.noModels = noneChosen(); body.bestInFamily = bestChosen(); body.modelPrefs = modelPrefsOfDraft(); Object.assign(body, routingOfDraft(p)); }
|
||||
if (p) { body.fallback = draft.fallback; body.unlisted = draft.unlisted; body.hiddenDrawers = draft.hiddenDrawers; body.hiddenVideomakers = draft.hiddenVideomakers; body.noModels = noneChosen(); body.bestInFamily = bestChosen(); body.modelPrefs = modelPrefsOfDraft(); Object.assign(body, routingOfDraft(p)); }
|
||||
body.searches = !!draft.searches && searchable();
|
||||
body.pinUpstream = !!draft.pinUpstream;
|
||||
if (twoKeyHeaders()) body.authHeader = draft.authHeader || "";
|
||||
@@ -11835,26 +11826,32 @@ function renderModels(p) {
|
||||
return box;
|
||||
}
|
||||
|
||||
// renderDrawers: the provider's image models. Agents don't chat with them,
|
||||
// so they aren't among its Models; one is picked in Settings → Images,
|
||||
// which lists the ticked ones. A click unticks one there, staged in the
|
||||
// draft until Save as a model's tick is (321sssrt on X: OpenAI's dozen).
|
||||
// renderDrawers: its image models, ticked for Settings → Images (321sssrt on X)
|
||||
function renderDrawers(p) {
|
||||
const chips = el("div", "mchips drawers");
|
||||
draft.hiddenDrawers ||= [...(p.hiddenDrawers || [])];
|
||||
for (const id of p.drawIds) {
|
||||
return field(t("Image models"), mediaChips("mchips drawers", p.drawIds, "hiddenDrawers", p), t("Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models."));
|
||||
}
|
||||
|
||||
// renderVideomakers: its video models, ticked to be offered (axelburks on Discord)
|
||||
function renderVideomakers(p) {
|
||||
return field(t("Video models"), mediaChips("mchips videomakers", p.filmIds, "hiddenVideomakers", p), t("Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models."));
|
||||
}
|
||||
|
||||
function mediaChips(cls, ids, key, p) {
|
||||
const chips = el("div", cls);
|
||||
draft[key] ||= [...(p[key] || [])];
|
||||
for (const id of ids) {
|
||||
const c = el("button", "mchip pick");
|
||||
c.type = "button";
|
||||
c.append(el("span", "", id));
|
||||
const show = () => { const on = !draft.hiddenDrawers.includes(id); c.classList.toggle("on", on); c.setAttribute("aria-pressed", on); };
|
||||
const show = () => { const on = !draft[key].includes(id); c.classList.toggle("on", on); c.setAttribute("aria-pressed", on); };
|
||||
c.onclick = () => {
|
||||
draft.hiddenDrawers = draft.hiddenDrawers.includes(id) ? draft.hiddenDrawers.filter((x) => x !== id) : [...draft.hiddenDrawers, id];
|
||||
draft[key] = draft[key].includes(id) ? draft[key].filter((x) => x !== id) : [...draft[key], id];
|
||||
show();
|
||||
};
|
||||
show();
|
||||
chips.append(c);
|
||||
}
|
||||
return field(t("Image models"), chips, t("Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models."));
|
||||
return chips;
|
||||
}
|
||||
|
||||
// renderRouting: how the gateway spreads requests over the keys or
|
||||
|
||||
@@ -1614,6 +1614,8 @@ const I18N = {
|
||||
"{n} image models": "{n} 个图像模型",
|
||||
"Image models": "图像模型",
|
||||
"Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "设置 → 图像 只列出已勾选的。Agent 不与它们对话,故不在模型列表中。",
|
||||
"Video models": "视频模型",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "生成视频时只提供已勾选的。Agent 不与它们对话,故不在模型列表中。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model} 是此处选中的,但在其供应商的“图像模型”中未勾选:它仍用于生图,改选其他模型后便不再列在这里。在那里勾选它即可留在列表中。",
|
||||
"no models exposed": "未暴露模型",
|
||||
"signed in as {user}": "已登录 {user}",
|
||||
@@ -6161,6 +6163,8 @@ const I18N = {
|
||||
"{n} image models": "{n} 個影像模型",
|
||||
"Image models": "影像模型",
|
||||
"Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "設定 → 影像 只列出已勾選的。Agent 不與它們對話,故不在模型列表中。",
|
||||
"Video models": "影片模型",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "生成影片時只提供已勾選的。Agent 不與它們對話,故不在模型列表中。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model} 是此處選取的,但在其供應商的「影像模型」中未勾選:它仍用於生圖,改選其他模型後便不再列在這裡。在那裡勾選它即可留在列表中。",
|
||||
"no models exposed": "未暴露模型",
|
||||
"signed in as {user}": "已登入 {user}",
|
||||
@@ -10682,6 +10686,8 @@ const I18N = {
|
||||
"{n} image models": "{n} 件の画像モデル",
|
||||
"Image models": "画像モデル",
|
||||
"Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "設定 → 画像 にはチェックしたものだけが表示されます。エージェントはこれらと会話しないため、モデル一覧には含まれません。",
|
||||
"Video models": "動画モデル",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "動画を作るときは、チェックしたものだけが候補になります。エージェントはこれらと会話しないため、モデル一覧には含まれません。",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "ここで選んだ {model} は、プロバイダの「画像モデル」でチェックが外されています。描画には引き続き使われますが、別のモデルを選ぶとこの一覧から消えます。一覧に残すには、そちらでチェックしてください。",
|
||||
"no models exposed": "公開されているモデルなし",
|
||||
"signed in as {user}": "{user} としてサインイン中",
|
||||
@@ -15234,6 +15240,8 @@ const I18N = {
|
||||
"{n} image models": "{n} Bildmodelle",
|
||||
"Image models": "Bildmodelle",
|
||||
"Settings → Images lists the ticked ones. Agents don't chat with these, so they aren't among its models.": "Einstellungen → Bilder listet die angehakten. Agenten chatten nicht mit diesen Modellen, daher stehen sie nicht bei seinen Modellen.",
|
||||
"Video models": "Videomodelle",
|
||||
"Only the ticked ones are offered when making a video. Agents don't chat with these, so they aren't among its models.": "Beim Erstellen eines Videos werden nur die angehakten angeboten. Agenten chatten nicht mit diesen Modellen, daher stehen sie nicht bei seinen Modellen.",
|
||||
"{model}, picked here, is unticked in its provider's Image models: it still draws, but leaves this list once another is picked. Tick it there to keep it listed.": "{model}, hier gewählt, ist bei den Bildmodellen seines Anbieters abgehakt: Es zeichnet weiter, verschwindet aber aus dieser Liste, sobald ein anderes gewählt ist. Haken Sie es dort an, damit es gelistet bleibt.",
|
||||
"no models exposed": "keine Modelle freigegeben",
|
||||
"signed in as {user}": "angemeldet als {user}",
|
||||
|
||||
@@ -293,8 +293,13 @@ type providerJSON struct {
|
||||
DrawIDs []string `json:"drawIds,omitempty"` // those models' ids, listed apart in its editor
|
||||
// those of them unticked in its editor (provider.HiddenDrawers)
|
||||
HiddenDrawers []string `json:"hiddenDrawers,omitempty"`
|
||||
Unlisted bool `json:"unlisted"` // its models serve only through routing groups
|
||||
NoModels bool `json:"noModels"` // Select none: none of its models served (#1818)
|
||||
// its video models (gateway.Videomakers), listed apart in its editor
|
||||
// as its image models are, and those unticked there
|
||||
// (provider.HiddenVideomakers)
|
||||
FilmIDs []string `json:"filmIds,omitempty"`
|
||||
HiddenVideomakers []string `json:"hiddenVideomakers,omitempty"`
|
||||
Unlisted bool `json:"unlisted"` // its models serve only through routing groups
|
||||
NoModels bool `json:"noModels"` // Select none: none of its models served (#1818)
|
||||
// Best in family: with nothing picked, only the newest model of each
|
||||
// family it lists is served (provider.Provider.BestInFamily)
|
||||
BestInFamily bool `json:"bestInFamily"`
|
||||
@@ -1001,6 +1006,14 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
|
||||
out.HiddenDrawers = append(out.HiddenDrawers, id)
|
||||
}
|
||||
}
|
||||
// its video models likewise (axelburks on Discord: an Ark key's
|
||||
// Seedance had nowhere to be ticked)
|
||||
for _, m := range gateway.VideomakersOf(p, func() []catalog.Model { return ls.Available }) {
|
||||
out.FilmIDs = append(out.FilmIDs, m.ID)
|
||||
if p.VideomakerHidden(m.ID) {
|
||||
out.HiddenVideomakers = append(out.HiddenVideomakers, m.ID)
|
||||
}
|
||||
}
|
||||
if t, ok := p.Listed(); ok {
|
||||
out.Fetched = &t
|
||||
}
|
||||
@@ -1663,6 +1676,7 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
pr.Routing, pr.Affinity, pr.Sink = in.Routing, in.Affinity, in.Sink
|
||||
pr.Unlisted = in.Unlisted
|
||||
pr.HiddenDrawers = in.HiddenDrawers
|
||||
pr.HiddenVideomakers = in.HiddenVideomakers
|
||||
pr.AccountProxies = in.AccountProxies
|
||||
if in.Name != "" {
|
||||
pr.Name = in.Name
|
||||
@@ -1905,6 +1919,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
if in.HiddenDrawers == nil && old != nil {
|
||||
in.HiddenDrawers = old.HiddenDrawers
|
||||
}
|
||||
if in.HiddenVideomakers == nil && old != nil {
|
||||
in.HiddenVideomakers = old.HiddenVideomakers
|
||||
}
|
||||
// a Zhipu key's team likewise: {} clears it
|
||||
if in.ZhipuTeam == nil && old != nil {
|
||||
in.ZhipuTeam = old.ZhipuTeam
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没
|
||||
// 有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor had its
|
||||
// Seedream models under Image models, to tick, and its Seedance models
|
||||
// nowhere. Now they are under Video models, each ticked, a click unticks it
|
||||
// (and ticks it back), and Save writes the unticked ones as
|
||||
// hiddenVideomakers, beside hiddenDrawers, neither one touching the other.
|
||||
// Every language, wide and at a phone's width; the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const fetched = new Date(Date.now() - 3600e3).toISOString();
|
||||
const drawIds = ["doubao-seedream-5-0-pro-260628", "doubao-seedream-5-0-flash-260915"];
|
||||
const filmIds = ["doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128", "doubao-seedance-1-0-pro-fast-251015"];
|
||||
|
||||
function providerFor(hidden, hiddenDraw) {
|
||||
return {
|
||||
id: "volcengine-2", name: "Volcengine Ark", icon: "volcengine", preset: "volcengine", host: "", chat: "https://ark.cn-beijing.volces.com/api/v3", responses: "", anthropic: "", catalog: "",
|
||||
models: [{ id: "doubao-seed-2-1-pro-260915", name: "Doubao Seed 2.1 Pro", on: true }], chosen: [], fetched, agents: [], fallback: [], headers: {},
|
||||
key: { set: true, masked: "ark-…one", optional: false }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", ready: true,
|
||||
draws: drawIds.length, drawIds, hiddenDrawers: hiddenDraw, filmIds, hiddenVideomakers: hidden,
|
||||
};
|
||||
}
|
||||
|
||||
function serve(lang, saves) {
|
||||
let hidden = ["doubao-seedance-1-0-pro-fast-251015"], hiddenDraw = ["doubao-seedream-5-0-flash-260915"];
|
||||
const providers = () => ({ providers: [providerFor(hidden, hiddenDraw)], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true,textSize:100};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 } });
|
||||
if (url.pathname === "/api/settings") return json({ lang, theme: "light", textSize: 100, fx: { rate: 7.2, at: new Date().toISOString(), stale: false } });
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/providers") return json(providers());
|
||||
if (url.pathname === "/api/provider/save") {
|
||||
const body = req.postDataJSON();
|
||||
saves.push({ videos: body.hiddenVideomakers, images: body.hiddenDrawers });
|
||||
if (body.hiddenVideomakers) hidden = body.hiddenVideomakers;
|
||||
if (body.hiddenDrawers) hiddenDraw = body.hiddenDrawers;
|
||||
return json(providers());
|
||||
}
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], pools: [], models: [] });
|
||||
if (url.pathname === "/api/gateway/trace") return json({ routes: [] });
|
||||
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
const body = await fs.readFile(file).catch(() => null);
|
||||
await (body ? route.fulfill({ body, contentType }) : route.fulfill({ status: 404, body: "" }));
|
||||
};
|
||||
}
|
||||
|
||||
const words = {
|
||||
en: { save: "Save", field: "Video models", hint: /Only the ticked ones are offered when making a video/ },
|
||||
zh: { save: "保存", field: "视频模型", hint: /生成视频时只提供已勾选的/ },
|
||||
"zh-TW": { save: "儲存", field: "影片模型", hint: /生成影片時只提供已勾選的/ },
|
||||
ja: { save: "保存", field: "動画モデル", hint: /動画を作るときは、チェックしたものだけが候補になります/ },
|
||||
de: { save: "Speichern", field: "Videomodelle", hint: /Beim Erstellen eines Videos werden nur die angehakten angeboten/ },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": a provider's video models can be unticked, apart from its image models", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const lang of Object.keys(words)) {
|
||||
const w = words[lang];
|
||||
for (const width of [1000, 360]) {
|
||||
await t.test(`${lang} at ${width}px: the editor unticks and ticks back a video model`, async () => {
|
||||
const saves = [];
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, saves));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
const editor = page.locator("#modal:not([hidden]) .editor");
|
||||
const openEditor = async () => {
|
||||
await page.locator(".row.provider", { hasText: "Volcengine Ark" }).first().click();
|
||||
await editor.locator(".mchips.videomakers .mchip").first().waitFor();
|
||||
};
|
||||
const ticked = (cls) => editor.locator(`.mchips.${cls} .mchip.on`).evaluateAll((cs) => cs.map((c) => c.textContent));
|
||||
const chip = (id) => editor.locator(".mchips.videomakers .mchip", { has: page.locator(`span:text-is("${id}")`) });
|
||||
await openEditor();
|
||||
await editor.getByText(w.field, { exact: true }).first().waitFor();
|
||||
await editor.getByText(w.hint).waitFor();
|
||||
assert.equal(await editor.locator(".mchips.videomakers .mchip").count(), 3);
|
||||
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128"], "the saved hidden one opens unticked");
|
||||
assert.deepEqual(await ticked("drawers"), ["doubao-seedream-5-0-pro-260628"], "image models are their own");
|
||||
assert.equal(await editor.locator(".mchips.drawers .mchip", { hasText: "seedance" }).count(), 0);
|
||||
assert.equal(await chip("doubao-seedance-1-0-pro-fast-251015").getAttribute("aria-pressed"), "false");
|
||||
await chip("doubao-seedance-2-0-fast-260128").click();
|
||||
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128"]);
|
||||
await chip("doubao-seedance-1-0-pro-fast-251015").click();
|
||||
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-1-0-pro-fast-251015"]);
|
||||
assert.deepEqual(await ticked("drawers"), ["doubao-seedream-5-0-pro-260628"], "a video tick leaves the image models be");
|
||||
// the section and its chips fit the editor at a phone's width
|
||||
const fit = await editor.locator(".mchips.videomakers").evaluate((box) => {
|
||||
const ed = box.closest(".editor").getBoundingClientRect();
|
||||
return [...box.querySelectorAll(".mchip")].every((c) => { const r = c.getBoundingClientRect(); return r.left >= ed.left - 1 && r.right <= ed.right + 1; });
|
||||
});
|
||||
assert.equal(fit, true, "a chip runs out of the editor");
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), 0);
|
||||
await editor.getByRole("button", { name: w.save, exact: true }).click();
|
||||
await editor.waitFor({ state: "detached" });
|
||||
assert.deepEqual(saves.at(-1), { videos: ["doubao-seedance-2-0-fast-260128"], images: ["doubao-seedream-5-0-flash-260915"] });
|
||||
await openEditor();
|
||||
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-1-0-pro-fast-251015"], "reopened as saved");
|
||||
assert.equal(await page.locator("select").count(), 0);
|
||||
assert.deepEqual(errors, []);
|
||||
await page.context().close();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// axelburks on Discord: a provider's editor has its video models apart
|
||||
// (filmIds), as its image models are; those unticked there are saved as
|
||||
// HiddenVideomakers, kept by a Save that leaves them out and cleared by [],
|
||||
// and a save of one leaves the other's alone.
|
||||
func TestVideoModelsHidden(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())
|
||||
mux := http.NewServeMux()
|
||||
providerRoutes(mux, nil)
|
||||
post := func(body string) {
|
||||
t.Helper()
|
||||
w := httptest.NewRecorder()
|
||||
mux.ServeHTTP(w, httptest.NewRequest("POST", "/api/provider/save", strings.NewReader(body)))
|
||||
if w.Code != 200 {
|
||||
t.Fatalf("%d %s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
const base = `"id":"films","name":"Films","key":"sk-f","chat":"https://films.example/v1","icon":"generic"`
|
||||
post(`{` + base + `,"new":true}`)
|
||||
if err := catalog.SaveLive("films", "https://films.example/v1", []catalog.Model{{ID: "text"}, {ID: "img-a", Draws: true}, {ID: "vid-a", Films: true}, {ID: "vid-b", Films: true}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info := func() providerJSON {
|
||||
t.Helper()
|
||||
p, err := provider.Find("films")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := providerInfo(*p, nil)
|
||||
if !slices.Equal(out.HiddenVideomakers, p.HiddenVideomakers) {
|
||||
t.Fatalf("the editor is shown %v, saved %v", out.HiddenVideomakers, p.HiddenVideomakers)
|
||||
}
|
||||
return out
|
||||
}
|
||||
if got := info(); !slices.Equal(got.FilmIDs, []string{"vid-a", "vid-b"}) || !slices.Equal(got.DrawIDs, []string{"img-a"}) {
|
||||
t.Fatalf("editor's video models %v, image models %v", got.FilmIDs, got.DrawIDs)
|
||||
}
|
||||
|
||||
post(`{` + base + `,"from":"films","models":[],"headers":{},"hiddenVideomakers":["vid-a"],"hiddenDrawers":["img-a"]}`)
|
||||
if got := info(); !slices.Equal(got.HiddenVideomakers, []string{"vid-a"}) || !slices.Equal(got.HiddenDrawers, []string{"img-a"}) {
|
||||
t.Fatalf("saved videos %v, images %v", got.HiddenVideomakers, got.HiddenDrawers)
|
||||
}
|
||||
post(`{` + base + `,"from":"films","models":[],"headers":{}}`)
|
||||
if got := info(); !slices.Equal(got.HiddenVideomakers, []string{"vid-a"}) {
|
||||
t.Fatalf("a Save that left them out changed them: %v", got.HiddenVideomakers)
|
||||
}
|
||||
post(`{` + base + `,"from":"films","models":[],"headers":{},"hiddenVideomakers":[]}`)
|
||||
if got := info(); len(got.HiddenVideomakers) != 0 || !slices.Equal(got.HiddenDrawers, []string{"img-a"}) {
|
||||
t.Fatalf("[] kept videos %v, or touched images %v", got.HiddenVideomakers, got.HiddenDrawers)
|
||||
}
|
||||
}
|
||||
@@ -132,3 +132,11 @@ func setModelKind(ref, kind string) (bool, error) {
|
||||
func (p Provider) DrawerHidden(model string) bool {
|
||||
return slices.Contains(p.HiddenDrawers, model)
|
||||
}
|
||||
|
||||
// VideomakerHidden is whether the user unticked p's video model in its
|
||||
// editor (HiddenVideomakers): it is left out of the lists a video model is
|
||||
// picked from and of Automatic's choice, and still makes videos when
|
||||
// named.
|
||||
func (p Provider) VideomakerHidden(model string) bool {
|
||||
return slices.Contains(p.HiddenVideomakers, model)
|
||||
}
|
||||
|
||||
@@ -548,6 +548,13 @@ type Provider struct {
|
||||
// one still draws with it, and so does the one Settings › Images
|
||||
// names: a hidden pick is shown as picked, and said to be hidden.
|
||||
HiddenDrawers []string `json:"hiddenDrawers,omitempty"`
|
||||
// HiddenVideomakers are its video models unticked in its editor, as
|
||||
// HiddenDrawers are its image models (axelburks on Discord: a
|
||||
// Volcengine Ark key lists a dozen Seedance models): left out of
|
||||
// what lists video models to pick from (generate_video's, another
|
||||
// magpie's, /v1/models' ?kind=video) and of Automatic's choice. A
|
||||
// request that names one still makes its video.
|
||||
HiddenVideomakers []string `json:"hiddenVideomakers,omitempty"`
|
||||
// Off switches the provider off without removing it: its keys and
|
||||
// settings stay, but agents aren't given its models, no request,
|
||||
// routing group or fallback goes to it, and its balance isn't asked,
|
||||
@@ -939,6 +946,7 @@ func accountSettings(a, pk Provider) Provider {
|
||||
a.ExtraBody = pk.ExtraBody
|
||||
// the image models unticked in its editor (HiddenDrawers)
|
||||
a.HiddenDrawers = pk.HiddenDrawers
|
||||
a.HiddenVideomakers = pk.HiddenVideomakers
|
||||
// and the headers of its replies passed on (#4145)
|
||||
a.ReplyHeaders = pk.ReplyHeaders
|
||||
// and the headers of the agent's requests passed on
|
||||
@@ -1325,6 +1333,9 @@ func AddCopy(p Provider, from string) (string, error) {
|
||||
if p.HiddenDrawers == nil {
|
||||
p.HiddenDrawers = slices.Clone(src.HiddenDrawers)
|
||||
}
|
||||
if p.HiddenVideomakers == nil {
|
||||
p.HiddenVideomakers = slices.Clone(src.HiddenVideomakers)
|
||||
}
|
||||
p.Searches = p.Searches || src.Searches
|
||||
p.Unredacted = p.Unredacted || src.Unredacted
|
||||
p.CountFree = p.CountFree || src.CountFree
|
||||
|
||||
Reference in New Issue
Block a user