settings: Video generation picks the model Magpie Image makes videos with
The same Discord (#feedback) user: a custom provider's video model still couldn't be chosen. A custom provider's video model was already found (seedance, kling, veo, wan, hailuo ids by name, or marked by hand with right-click › Makes › Video model, #1399), but generate_video always used AutoVideomaker's pick, the first video model of the first provider, with nowhere to choose another, as Settings › Images does for images. settings.VideoGen (provider/model or a routing group) is now the model a request that names none makes its video with, while it resolves; else AutoVideomaker's, as before. Image generation turned off turns video off with it, as before. Settings › Models › Images gets a Video generation row under Image generation: Automatic (naming the automatic pick) and every model Magpie Image can make videos with. A pick that no longer makes videos (provider gone or off, model unmarked) says so and the automatic one is used in its place; the settings API refuses a model that makes none, and keeps the pick when a save doesn't send it. The row is drawn by videogen.js, imported when Settings draws Image generation, with one call in app.js: drawn in app.js it put the core scripts 616 bytes over TestCoreScriptBudget (1,534,418 > 1,533,802, found by the first full run), and the budget is not raised. Run on mote: - At this change onbceeabd93(rebased ontoc630d9a29, which changes only the gateway key page): gofmt -l clean; GOOS=windows go vet and GOOS=linux go vet -tags nogui of the changed packages: ok. go test -run 'Budget|VideoGen|Videomaker|TestSettingsSave|TestKeysAreWhatTheSaveWrites' in settings, settingsapi, gateway, gui: ok. GUI: video-gen-pick (32 subtests: chromium and webkit; en, zh, zh-TW, ja, de at 1100px, en and zh at 400px), old-webkit, i18n-en-no-cjk and the six image/Settings files (image-timeout-setting, images-codex-one, images-library-way, images-missing, image-models-hide, image-mcp): 220 of 220 ok. - At 95a3fa3e0 (the change before the videogen.js move and the rebase): go test -timeout 45m ./internal/settings ./internal/settingsapi ./internal/gateway ./internal/gui: ok except TestCoreScriptBudget (fixed above). i18n-keys at 4394ea1b9: only the known plugin-words red (#5332). - Not run at this head: the whole of those four packages and the 183 GUI files a Settings change reaches; the suite lock on mote was an hour deep in other sessions' suites. Broken by hand, each red: - videomaker ignoring VideoGen: TestVideoGenPicksAMarkedModel. - settingsapi not keeping a pick a save doesn't send: TestVideoGenCheckedAndKept. - No Video generation row: video-gen-pick.test.cjs, 30 of 32. - videoGen left out of the Settings page's prefsKeep: TestSettingsSaveKeepsWhatItDoesNotSend ("VideoGen: not sent by the Settings page"), found before it was added. Not tried: a real video generation with a custom provider's model (the gateway tests hold the vendor's replies).
This commit is contained in:
@@ -2420,6 +2420,27 @@ hidden ones, read by `AutoVideomaker`, `videomakerObjects` and
|
||||
`mediaModels(true)`. A hidden one still makes its video when named:
|
||||
`bareVideomaker`, `videosCreate` and `arkFilms` read `Videomakers`.
|
||||
|
||||
Settings › Models › Images › Video generation (`#videoGenRow`, under
|
||||
Image generation, gone while that is Off) picks the model a video
|
||||
request that names none is made with, the Magpie Image MCP's
|
||||
`generate_video` and `/v1/videos` alike (Discord #feedback: a custom
|
||||
provider's model marked a video model by hand was made with only when
|
||||
Automatic happened to take it). `settings.VideoGen` holds a
|
||||
provider/model or a group ref; `videomaker` takes it while
|
||||
`VideomakerMissingOf` finds it among its provider's `Videomakers` (on,
|
||||
not decide-only; a group through `mediaGroupFirst`), and
|
||||
`AutoVideomaker` otherwise. A save of a model that makes no videos is
|
||||
refused (settingsapi), a save that doesn't send `videoGen` keeps it, and
|
||||
a pick that stops making videos is `videoGenMissing`: the row says so
|
||||
and Automatic makes them meanwhile. The list (`videoGenModels`) is every
|
||||
`Videomakers` model of such providers, a hidden one only when it is the
|
||||
pick. With none, the row says how to mark one (right-click in the
|
||||
provider's Model settings, Makes › Video model; kept in sight). The
|
||||
row is drawn by `videogen.js`, imported when Settings draws Image
|
||||
generation, so it weighs nothing on the core.
|
||||
`TestVideoGenPicksAMarkedModel`, `TestVideoGenCheckedAndKept`,
|
||||
`TestVideoGenModelsListed`, `video-gen-pick.test.cjs`.
|
||||
|
||||
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
|
||||
|
||||
@@ -260,16 +260,60 @@ func markedKey(p provider.Provider, by string) (provider.Provider, bool) {
|
||||
}
|
||||
|
||||
// videomaker is the model a request that names none makes its video with:
|
||||
// AutoVideomaker's, unless the Settings turned image generation off, which
|
||||
// turns video off with it. None when it is off or no provider makes videos.
|
||||
// the Settings' VideoGen while it resolves, else AutoVideomaker's, unless
|
||||
// the Settings turned image generation off, which turns video off with
|
||||
// it. None when it is off or no provider makes videos.
|
||||
func videomaker() (string, bool) {
|
||||
if settings.Load().ImageGen == "off" {
|
||||
st := settings.Load()
|
||||
if st.ImageGen == "off" {
|
||||
return "", false
|
||||
}
|
||||
if v := st.VideoGen; v != "" && VideomakerMissingOf(v) == "" {
|
||||
return v, true
|
||||
}
|
||||
m := AutoVideomaker()
|
||||
return m, m != ""
|
||||
}
|
||||
|
||||
// Videomaker is the model a request that names none makes its video with
|
||||
// (videomaker), as provider/model: "" when it is off or none can.
|
||||
func Videomaker() string {
|
||||
m, _ := videomaker()
|
||||
return m
|
||||
}
|
||||
|
||||
// VideomakerMissing is the model Settings › Images › Video generation
|
||||
// names when magpie can't make videos with it any more, so that
|
||||
// AutoVideomaker's makes them in its place, as DrawerMissing is Image
|
||||
// generation's. "" when none is named or it resolves.
|
||||
func VideomakerMissing() string { return VideomakerMissingOf(settings.Load().VideoGen) }
|
||||
|
||||
// VideomakerMissingOf is v, a Video generation pick, when magpie can't
|
||||
// make videos with it: its provider is gone, off or decide-only, or no
|
||||
// longer has it among its Videomakers (a custom provider's model the user
|
||||
// no longer marks a video model, #1399). A routing group resolves while
|
||||
// one of its members makes videos.
|
||||
func VideomakerMissingOf(v string) string {
|
||||
if v == "" {
|
||||
return ""
|
||||
}
|
||||
if provider.IsGroupRef(v) {
|
||||
if _, _, ok := mediaGroupFirst(v, provider.KindVideo); ok {
|
||||
return ""
|
||||
}
|
||||
return v
|
||||
}
|
||||
id, model, _ := strings.Cut(v, "/")
|
||||
p, err := provider.Find(id)
|
||||
if err != nil || !p.On() || p.DecideOnly() {
|
||||
return v
|
||||
}
|
||||
if slices.ContainsFunc(Videomakers(*p), func(m catalog.Model) bool { return m.ID == model }) {
|
||||
return ""
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// AutoVideomaker is the model a request that names none makes its video
|
||||
// with: the first model of the first provider that makes any. "" when none
|
||||
// can. A MiniMax API key's H3 comes after every other: it is paid by the
|
||||
|
||||
@@ -434,3 +434,71 @@ func TestCustomProviderVideoKeepsTheCallersFields(t *testing.T) {
|
||||
t.Fatalf("sent %s", b)
|
||||
}
|
||||
}
|
||||
|
||||
// Settings › Images › Video generation (the reporter's "custom providers
|
||||
// still can't pick a video model"): a custom provider's model the user
|
||||
// marked a video model, picked there, makes the video a request that names
|
||||
// none gets, and is generate_video's default, though Automatic would take
|
||||
// the provider's listed one. One no longer marked is said missing, and
|
||||
// Automatic's makes the video in its place; Image generation's Off turns
|
||||
// it off with the rest.
|
||||
func TestVideoGenPicksAMarkedModel(t *testing.T) {
|
||||
fresh(t)
|
||||
up := newOpenAIVideos(t)
|
||||
saveFetched(t, provider.Provider{ID: "studio", Name: "Studio", Chat: up.URL + "/v1", Key: "sk-studio", Models: []string{"gpt-5.5", "agnes-video-2.5-flash"}})
|
||||
const pick = "studio/agnes-video-2.5-flash"
|
||||
if err := provider.SetModelKind(pick, provider.KindVideo); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h := New().Handler()
|
||||
made := func() string {
|
||||
t.Helper()
|
||||
n := len(up.bodies)
|
||||
code, _, raw := asKey(t, h, "", "POST", "/v1/videos", `{"prompt":"waves on a rock"}`)
|
||||
if code != 200 || len(up.bodies) != n+1 {
|
||||
t.Fatalf("%d %s", code, raw)
|
||||
}
|
||||
var sent map[string]any
|
||||
json.Unmarshal([]byte(up.bodies[n]), &sent)
|
||||
return "studio/" + sent["model"].(string)
|
||||
}
|
||||
if a := AutoVideomaker(); a != "studio/vid-1" {
|
||||
t.Fatalf("automatic %q", a)
|
||||
}
|
||||
if m := made(); m != "studio/vid-1" {
|
||||
t.Fatalf("with none picked, made with %s", m)
|
||||
}
|
||||
|
||||
st := settings.Load()
|
||||
st.VideoGen = pick
|
||||
if err := settings.Save(st); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m := made(); m != pick {
|
||||
t.Fatalf("picked %s, made with %s", pick, m)
|
||||
}
|
||||
if _, def := mediaModels(true); def != pick {
|
||||
t.Fatalf("generate_video's default %q", def)
|
||||
}
|
||||
if v := VideomakerMissing(); v != "" {
|
||||
t.Fatalf("a marked pick said missing: %q", v)
|
||||
}
|
||||
|
||||
if err := provider.SetModelKind(pick, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v := VideomakerMissing(); v != pick {
|
||||
t.Fatalf("unmarked, missing %q", v)
|
||||
}
|
||||
if m := made(); m != "studio/vid-1" {
|
||||
t.Fatalf("a missing pick made with %s, not Automatic's", m)
|
||||
}
|
||||
|
||||
st.ImageGen = "off"
|
||||
if err := settings.Save(st); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, ok := videomaker(); ok || m != "" {
|
||||
t.Fatalf("image generation off, videomaker %q", m)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,6 +488,14 @@ type settingsJSON struct {
|
||||
// editor since (provider.HiddenDrawers): it still draws, and is
|
||||
// listed, as picked, with the row saying it is hidden
|
||||
ImageGenHidden bool `json:"imageGenHidden,omitempty"`
|
||||
// the model a video request that names none is made with when
|
||||
// VideoGen names none (gateway.AutoVideomaker), the VideoGen picked
|
||||
// when magpie can't find it any more, and those that can be picked:
|
||||
// each provider's video models, a custom provider's the user marked
|
||||
// (#1399) among them, less those unticked in its editor
|
||||
VideoGenAuto string `json:"videoGenAuto,omitempty"`
|
||||
VideoGenMissing string `json:"videoGenMissing,omitempty"`
|
||||
VideoGenModels []modelRef `json:"videoGenModels"`
|
||||
// the web search APIs a model's search goes to when no provider can
|
||||
// search (#419), their keys masked; the ones that can be added; and
|
||||
// the provider that searches first, if one does
|
||||
@@ -925,6 +933,19 @@ func settingsState() settingsJSON {
|
||||
s.ImageGenShown = v
|
||||
}
|
||||
s.ImageGenHidden = gateway.DrawerHidden(s.ImageGen)
|
||||
s.VideoGenAuto, s.VideoGenModels, s.VideoGenMissing = gateway.AutoVideomaker(), []modelRef{}, gateway.VideomakerMissing()
|
||||
for _, p := range provider.All() {
|
||||
if !p.On() || p.DecideOnly() {
|
||||
continue
|
||||
}
|
||||
// one unticked in its editor is left out, but the one picked here
|
||||
for _, m := range gateway.Videomakers(p) {
|
||||
if p.VideomakerHidden(m.ID) && s.VideoGen != p.ID+"/"+m.ID {
|
||||
continue
|
||||
}
|
||||
s.VideoGenModels = append(s.VideoGenModels, modelRef{ID: p.ID + "/" + m.ID, Name: cmp.Or(m.Name, m.ID), Provider: p.ID, PName: p.Name, Icon: p.Icon})
|
||||
}
|
||||
}
|
||||
// the Codex subagents row's warning: magpie's multi-agent V1 doesn't reach
|
||||
// Codex where its own multi_agent_v2 is on in the config magpie routes, and
|
||||
// magpie writes nothing there — the setting is the user's to turn off
|
||||
|
||||
@@ -3897,7 +3897,7 @@ input.words.compact-num { flex: none; width: 76px; font-variant-numeric: tabular
|
||||
sends, who the allow list lets in), a line with a button or link in
|
||||
it. A touch screen, with no hover, keeps them all. */
|
||||
@media (hover: hover) {
|
||||
#view-settings:not(.set-searching) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) {
|
||||
#view-settings:not(.set-searching) .row.pref > .who > .sub:not(.err, .bad, .say, .proxy-check, .lib-way, .image-gen-hidden, .sync-sign-in, .no-names, .pv-hits, .feat-why, .vision-not-marked, .video-gen-how, .font-note, .acts, [role="status"], #proxySub):not(#otelSessionsRow *, #allowList *, .disabled-model *) {
|
||||
--hint: 1; position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
||||
}
|
||||
/* a row left with its name alone is as tall as any other: its control
|
||||
|
||||
@@ -21571,6 +21571,13 @@ function renderImageGen(s, keep, box) {
|
||||
val.append(b);
|
||||
r.append(who, val);
|
||||
box.append(r);
|
||||
// Video generation's row (#1399), drawn by videogen.js
|
||||
if (v !== "off") {
|
||||
const vr = el("div", "row pref");
|
||||
box.append(vr);
|
||||
if (window.videoGenFill) videoGenFill(vr, s, keep);
|
||||
else { vr.hidden = true; import("./videogen.js").then(() => videoGenFill(vr, s, keep), () => {}); }
|
||||
}
|
||||
// how long a vendor is given to draw an image and send it: 5 minutes
|
||||
// unless set, as a slow image endpoint needs more (neighbads on X)
|
||||
box.append(waitRow("imageTimeoutRow", t("Image generation timeout"), t("How long a provider is given to draw an image and send it, before the request is given up. A slow image endpoint may need longer"),
|
||||
@@ -22671,7 +22678,7 @@ function prefsKeep(s) {
|
||||
codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly,
|
||||
replyModel: s.replyModel || "", noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudePrintMode: !!s.claudePrintMode, refusalRetries: s.refusalRetries ?? null, retryAfterCap: s.retryAfterCap ?? null,
|
||||
noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload, updateChannel: s.updateChannel || "",
|
||||
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd",
|
||||
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", videoGen: s.videoGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd",
|
||||
chineseUnits: !!s.chineseUnits, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0, resetReminder: s.resetReminder || 0,
|
||||
turnDoneAlert: s.turnDoneAlert || 0, maskAlert: !!s.maskAlert };
|
||||
}
|
||||
|
||||
@@ -1119,6 +1119,12 @@ const I18N = {
|
||||
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "这里选的 {model} 已不可用:它的服务商被删除或关闭了,或者不再提供这个模型。也没有其他能生图的模型,所以没指定模型的请求会被拒绝。请在这里另选一个模型。",
|
||||
"images turned away": "带图的请求被拒绝",
|
||||
"Image generation": "生图模型",
|
||||
"Video generation": "视频生成",
|
||||
"To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "右键点服务商「模型设置」里的模型,选「类型:视频模型」,就能用它生成视频",
|
||||
"no model that makes videos": "没有能生成视频的模型",
|
||||
"The model Magpie Image makes videos with": "Magpie Image 生成视频用的模型",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "这里选的 {model} 已不能生成视频:它的服务商被删除或关闭了,或者这个模型不再标记为视频模型。现在由自动选择的 {auto} 代为生成视频。请在这里另选一个模型。",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "这里选的 {model} 已不能生成视频:它的服务商被删除或关闭了,或者这个模型不再标记为视频模型。也没有其他能生成视频的模型。请在这里另选一个模型。",
|
||||
"Intent classifier timeout": "意图判断超时",
|
||||
"How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由组的意图判断模型判断这一轮属于哪种意图可用的时间。这一轮要等它判断完才会发出,超过则不等它的回答直接继续。较慢的判断模型可能需要更长时间",
|
||||
"Image generation timeout": "生图超时",
|
||||
@@ -5870,6 +5876,12 @@ const I18N = {
|
||||
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "這裡選的 {model} 已無法使用:它的服務商被刪除或關閉了,或者不再提供這個模型。也沒有其他能生圖的模型,所以沒指定模型的請求會被拒絕。請在這裡另選一個模型。",
|
||||
"images turned away": "帶圖的請求被拒絕",
|
||||
"Image generation": "生圖模型",
|
||||
"Video generation": "影片生成",
|
||||
"To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "在服務商「模型設定」裡的模型上按右鍵,選「類型:影片模型」,就能用它生成影片",
|
||||
"no model that makes videos": "沒有能生成影片的模型",
|
||||
"The model Magpie Image makes videos with": "Magpie Image 生成影片用的模型",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "這裡選的 {model} 已無法生成影片:它的服務商被刪除或關閉了,或者這個模型不再標記為影片模型。現在由自動選擇的 {auto} 代為生成影片。請在這裡另選一個模型。",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "這裡選的 {model} 已無法生成影片:它的服務商被刪除或關閉了,或者這個模型不再標記為影片模型。也沒有其他能生成影片的模型。請在這裡另選一個模型。",
|
||||
"Intent classifier timeout": "意圖判斷逾時",
|
||||
"How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "路由組的意圖判斷模型判斷這一輪屬於哪種意圖可用的時間。這一輪要等它判斷完才會送出,超過則不等它的回答直接繼續。較慢的判斷模型可能需要更長時間",
|
||||
"Image generation timeout": "生圖逾時",
|
||||
@@ -10592,6 +10604,12 @@ const I18N = {
|
||||
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "ここで選んだ {model} は使えなくなっています。プロバイダーが削除またはオフにされたか、このモデルがなくなりました。画像を生成できるモデルが他にないため、モデルを指定しないリクエストは拒否されます。ここで別のモデルを選んでください。",
|
||||
"images turned away": "画像付きリクエストは拒否",
|
||||
"Image generation": "画像生成",
|
||||
"Video generation": "動画生成",
|
||||
"To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "プロバイダーの「モデル設定」でモデルを右クリックし、「種類:動画モデル」を選ぶと、そのモデルで動画を生成できます",
|
||||
"no model that makes videos": "動画を生成できるモデルがありません",
|
||||
"The model Magpie Image makes videos with": "Magpie Image が動画の生成に使うモデル",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "ここで選んだ {model} は動画を生成できなくなっています。プロバイダーが削除またはオフにされたか、このモデルが動画モデルとしてマークされなくなりました。代わりに自動で選ばれた {auto} が動画を生成しています。ここで別のモデルを選んでください。",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "ここで選んだ {model} は動画を生成できなくなっています。プロバイダーが削除またはオフにされたか、このモデルが動画モデルとしてマークされなくなりました。動画を生成できるモデルが他にありません。ここで別のモデルを選んでください。",
|
||||
"Intent classifier timeout": "インテント判定のタイムアウト",
|
||||
"How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "ルーティンググループの分類モデルが、このターンがどのインテントかを答えるまで待つ時間。ターンは答えを待ってから送られ、過ぎると答えなしで進みます。遅い分類モデルではもっと長く必要なことがあります",
|
||||
"Image generation timeout": "画像生成のタイムアウト",
|
||||
@@ -15329,6 +15347,12 @@ const I18N = {
|
||||
"{model}, picked here, isn't set up any more: its provider was removed or turned off, or no longer has it. No other model draws, so a request that names no model is turned away. Pick another model here.": "{model}, hier gewählt, ist nicht mehr eingerichtet: Sein Anbieter wurde entfernt oder ausgeschaltet, oder er hat das Modell nicht mehr. Kein anderes Modell erzeugt Bilder, daher wird eine Anfrage ohne Modell abgewiesen. Wähle hier ein anderes Modell.",
|
||||
"images turned away": "Bilder werden abgelehnt",
|
||||
"Image generation": "Bilderzeugung",
|
||||
"Video generation": "Videoerzeugung",
|
||||
"To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes \u203a Video model": "Um mit einem Modell eines Anbieters Videos zu erzeugen, klicke es in den Modelleinstellungen des Anbieters mit rechts an und wähle Erzeugt › Videomodell",
|
||||
"no model that makes videos": "kein Modell zur Videoerzeugung",
|
||||
"The model Magpie Image makes videos with": "Das Modell, mit dem Magpie Image Videos erzeugt",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.": "{model}, hier gewählt, erzeugt keine Videos mehr: Sein Anbieter wurde entfernt oder ausgeschaltet, oder das Modell ist nicht mehr als Videomodell markiert. {auto}, die automatische Wahl, erzeugt die Videos an seiner Stelle. Wähle hier ein anderes Modell.",
|
||||
"{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.": "{model}, hier gewählt, erzeugt keine Videos mehr: Sein Anbieter wurde entfernt oder ausgeschaltet, oder das Modell ist nicht mehr als Videomodell markiert. Kein anderes Modell erzeugt Videos. Wähle hier ein anderes Modell.",
|
||||
"Intent classifier timeout": "Zeitlimit für den Absicht-Klassifikator",
|
||||
"How long a routing group's classifier is given to say which intent a turn is. The turn waits for it before it goes anywhere, and past it goes on without its answer. A slow classifier may need longer": "Wie lange der Klassifikator einer Routing-Gruppe Zeit hat zu sagen, welche Absicht eine Runde hat. Die Runde wartet darauf, bevor sie irgendwohin geht, und danach geht sie ohne seine Antwort weiter. Ein langsamer Klassifikator braucht vielleicht länger",
|
||||
"Image generation timeout": "Zeitlimit für Bilderzeugung",
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// Settings › Models › Images' Video generation: the model a video request
|
||||
// that names none is made with, generate_video's — the one magpie picks or
|
||||
// one named. A custom provider's model makes videos once marked so in its
|
||||
// Model settings (#1399), which the row says while no model makes any.
|
||||
// Image generation's Off turns it off too. app.js imports this when
|
||||
// Settings draws Image generation, so it weighs nothing on the core.
|
||||
|
||||
// videoGenFill draws the row into r
|
||||
window.videoGenFill = function (r, s, keep) {
|
||||
const models = s.videoGenModels || [];
|
||||
const v = s.videoGen || "";
|
||||
const named = namedIn(models);
|
||||
const icOf = (id) => models.find((x) => x.id === id)?.icon;
|
||||
const gone = v && v === s.videoGenMissing;
|
||||
r.id = "videoGenRow";
|
||||
r.hidden = false;
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", t("Video generation")), el("div", "sub wraps", t("The model Magpie Image makes videos with")));
|
||||
if (!models.length && !v) who.append(el("div", "sub wraps video-gen-how", t("To make videos with a provider's model, right-click it in the provider's Model settings and choose Makes › Video model")));
|
||||
if (gone) who.append(el("div", "sub err video-gen-missing", s.videoGenAuto
|
||||
? t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. {auto}, the automatic choice, makes videos in its place. Pick another model here.", { model: v, auto: named(s.videoGenAuto) })
|
||||
: t("{model}, picked here, no longer makes videos: its provider was removed or turned off, or the model isn't marked a video model any more. No other model makes videos. Pick another model here.", { model: v })));
|
||||
const b = el("button", "rt-cond on");
|
||||
if (gone) b.append(icon("generic"), el("span", "", v + " · " + t("missing")));
|
||||
else if (v) b.append(icon(icOf(v) || "generic"), el("span", "", named(v)));
|
||||
else {
|
||||
if (s.videoGenAuto) b.append(icon(icOf(s.videoGenAuto) || "generic"));
|
||||
b.append(el("span", "", s.videoGenAuto ? t("Automatic") + " · " + named(s.videoGenAuto) : t("Automatic") + " · " + t("no model that makes videos")));
|
||||
}
|
||||
b.onclick = (ev) => openPicker({ id: "", name: "", fields: [] }, { key: "videoGen", label: "model", value: v, options: [
|
||||
{ value: "", label: t("Automatic"), note: s.videoGenAuto ? named(s.videoGenAuto) : t("no model that makes videos"), reset: true },
|
||||
...models.map((x) => ({ value: x.id, label: x.name || x.id, note: x.providerName, icon: x.icon, group: x.providerName, ref: x.id }))],
|
||||
onPick: (id) => { if (id !== v) savePrefs({ ...keep, videoGen: id }); } }, b, ev);
|
||||
const val = el("div", "val");
|
||||
val.append(b);
|
||||
r.append(who, val);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -161,9 +161,10 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
// with no Balance URL, passerrors.js when it draws a key provider's
|
||||
// Errors, keybalance.js when it draws a key whose vendor tells no
|
||||
// balance, modellimits.js when it draws a model's row, notices.js when
|
||||
// About's Open-source licenses opens; the checks above
|
||||
// About's Open-source licenses opens, videogen.js when Settings draws
|
||||
// Image generation; the checks above
|
||||
// still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quitask.js", "checkinnow.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "balfound.js", "passerrors.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Discord #feedback: "自定义的供应商还是不能选视频模型". A custom
|
||||
// provider's model marked a video model (right-click in its Model settings,
|
||||
// Makes › Video model) made videos only when magpie happened to pick it:
|
||||
// Magpie Image's video generation had no setting, Automatic took the first
|
||||
// provider's. Settings › Models › Images now has a Video generation row,
|
||||
// beside Image generation: Automatic names its pick, the picker lists every
|
||||
// model that makes videos by provider, picking one saves videoGen, a pick
|
||||
// that no longer makes videos says so, and with none at all the row says
|
||||
// how to mark one (in sight: it is the way there). Image generation off
|
||||
// takes the row away. Every language; wide and at a phone's width; no
|
||||
// backend, 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");
|
||||
|
||||
function settingsPayload(lang, over) {
|
||||
return {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", textSize: 100,
|
||||
dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [],
|
||||
codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false,
|
||||
trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "",
|
||||
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
|
||||
proxyNow: "none", proxySource: "none", login: false,
|
||||
visionModels: [], workbuddyCheckins: [], lanURLs: [],
|
||||
imageGenAuto: "openai/gpt-image-2",
|
||||
imageGenModels: [{ id: "openai/gpt-image-2", name: "gpt-image-2", provider: "openai", providerName: "OpenAI", icon: "openai" }],
|
||||
videoGen: "",
|
||||
videoGenAuto: "grok/grok-imagine-video",
|
||||
videoGenModels: [
|
||||
{ id: "grok/grok-imagine-video", name: "Grok Imagine Video", provider: "grok", providerName: "Grok", icon: "grok" },
|
||||
{ id: "studio/kling-v3", name: "kling-v3", provider: "studio", providerName: "Studio", icon: "" },
|
||||
],
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||||
...over,
|
||||
};
|
||||
}
|
||||
|
||||
function server(lang, cur, posted) {
|
||||
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 }, fx: cur.fx });
|
||||
if (url.pathname === "/api/settings") {
|
||||
if (req.method() === "POST") {
|
||||
const body = JSON.parse(req.postData() || "{}");
|
||||
posted.push(body);
|
||||
Object.assign(cur, body);
|
||||
}
|
||||
return json(cur);
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
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 want = {
|
||||
en: { name: "Video generation", auto: "Automatic", how: /^To make videos with a provider's model, right-click it/, none: "no model that makes videos", missing: "missing", gone: /^studio\/kling-v3, picked here, no longer makes videos/ },
|
||||
zh: { name: "视频生成", auto: "自动", how: /类型:视频模型/, none: "没有能生成视频的模型", missing: "已失效", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ },
|
||||
"zh-TW": { name: "影片生成", auto: "自動", how: /類型:影片模型/, none: "沒有能生成影片的模型", missing: "已失效", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ },
|
||||
ja: { name: "動画生成", auto: "自動", how: /種類:動画モデル/, none: "動画を生成できるモデルがありません", missing: "見つかりません", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ },
|
||||
de: { name: "Videoerzeugung", auto: "Automatisch", how: /Videomodell/, none: "kein Modell zur Videoerzeugung", missing: "fehlt", gone: /studio\/kling-v3[^]*Grok Imagine Video · Grok/ },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": Settings picks the model Magpie Image makes videos with", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const shots = [];
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
for (const [name, buf] of shots) await fs.writeFile(path.join(process.env.ARTIFACT_DIR, `${engine}-video-gen-pick-${name}.png`), buf);
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
const open = async (lang, cur, width, posted) => {
|
||||
const context = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.errors = [];
|
||||
page.on("pageerror", (e) => page.errors.push(e.message));
|
||||
await page.route("**/*", server(lang, cur, posted));
|
||||
await page.goto("http://magpie.test/?view=settings&tab=models");
|
||||
await page.locator("#imagesList .row").nth(1).waitFor();
|
||||
return page;
|
||||
};
|
||||
const click = async (page, loc) => {
|
||||
const b = await loc.boundingBox();
|
||||
await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2);
|
||||
};
|
||||
const fits = (page) => page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
||||
for (const lang of Object.keys(want)) {
|
||||
const w = want[lang];
|
||||
for (const width of lang === "en" || lang === "zh" ? [1100, 400] : [1100]) {
|
||||
await t.test(`${lang} at ${width}px: Automatic names its pick, and a custom provider's video model is picked`, async () => {
|
||||
const posted = [];
|
||||
const page = await open(lang, settingsPayload(lang, {}), width, posted);
|
||||
const row = page.locator("#imagesList #videoGenRow");
|
||||
await row.waitFor();
|
||||
assert.equal((await row.locator(".name").textContent()).trim(), w.name);
|
||||
const button = row.locator("button.rt-cond");
|
||||
assert.equal((await button.textContent()).trim(), `${w.auto} · Grok Imagine Video · Grok`);
|
||||
assert.equal(await row.locator(".video-gen-how").count(), 0, "no how-to while a model makes videos");
|
||||
assert.equal(await row.locator(".video-gen-missing").count(), 0);
|
||||
assert.equal(await fits(page), 0, "no sideways scroll");
|
||||
shots.push([`${lang}-${width}`, await page.screenshot({ fullPage: true })]);
|
||||
|
||||
await click(page, button);
|
||||
await page.locator("#pop").waitFor({ state: "visible" });
|
||||
const items = await page.locator("#list li:not(.group)").allInnerTexts();
|
||||
assert.equal(items.length, 3, items.join(" | "));
|
||||
assert(items[0].startsWith(w.auto), items[0]);
|
||||
assert(items.some((x) => x.includes("kling-v3") && x.includes("Studio")), items.join(" | "));
|
||||
assert(items.some((x) => x.includes("Grok Imagine Video") && x.includes("Grok")), items.join(" | "));
|
||||
await click(page, page.locator("#list li:not(.group)", { hasText: "kling-v3" }));
|
||||
await page.waitForFunction(() => document.querySelector("#videoGenRow button.rt-cond")?.textContent.includes("kling-v3"));
|
||||
assert.equal(posted.length, 1, JSON.stringify(posted));
|
||||
assert.equal(posted[0].videoGen, "studio/kling-v3");
|
||||
assert.equal((await page.locator("#videoGenRow button.rt-cond").textContent()).trim(), "kling-v3 · Studio");
|
||||
// picking Automatic again clears it
|
||||
await click(page, page.locator("#videoGenRow button.rt-cond"));
|
||||
await page.locator("#pop").waitFor({ state: "visible" });
|
||||
assert((await page.locator("#list li.cur").innerText()).includes("kling-v3"));
|
||||
await click(page, page.locator("#list li:not(.group):not(.cur)", { hasText: w.auto }));
|
||||
await page.waitForFunction(() => !document.querySelector("#videoGenRow button.rt-cond")?.textContent.includes("kling-v3"));
|
||||
assert.equal(posted.at(-1).videoGen, "");
|
||||
assert.deepEqual(page.errors, []);
|
||||
await page.context().close();
|
||||
});
|
||||
await t.test(`${lang} at ${width}px: a pick that no longer makes videos says so; none at all says how to mark one`, async () => {
|
||||
const posted = [];
|
||||
let page = await open(lang, settingsPayload(lang, { videoGen: "studio/kling-v3", videoGenMissing: "studio/kling-v3",
|
||||
videoGenModels: [{ id: "grok/grok-imagine-video", name: "Grok Imagine Video", provider: "grok", providerName: "Grok", icon: "grok" }] }), width, posted);
|
||||
let row = page.locator("#videoGenRow");
|
||||
await row.waitFor();
|
||||
assert.equal((await row.locator("button.rt-cond").textContent()).trim(), `studio/kling-v3 · ${w.missing}`);
|
||||
const gone = row.locator(".video-gen-missing");
|
||||
assert.match((await gone.textContent()).trim(), w.gone);
|
||||
assert.equal(await gone.isVisible(), true, "the error is in sight");
|
||||
assert.equal(await fits(page), 0);
|
||||
await page.context().close();
|
||||
|
||||
page = await open(lang, settingsPayload(lang, { videoGenAuto: "", videoGenModels: [] }), width, posted);
|
||||
row = page.locator("#videoGenRow");
|
||||
await row.waitFor();
|
||||
assert.equal((await row.locator("button.rt-cond").textContent()).trim(), `${w.auto} · ${w.none}`);
|
||||
const how = row.locator(".video-gen-how");
|
||||
assert.match((await how.textContent()).trim(), w.how);
|
||||
assert.equal(await how.evaluate((e) => getComputedStyle(e).getPropertyValue("--hint").trim()), "", "the way to a video model shows at rest");
|
||||
assert.equal(await how.isVisible(), true);
|
||||
assert.equal(await fits(page), 0);
|
||||
shots.push([`${lang}-${width}-none`, await page.screenshot({ fullPage: true })]);
|
||||
assert.deepEqual(posted, []);
|
||||
assert.deepEqual(page.errors, []);
|
||||
await page.context().close();
|
||||
});
|
||||
}
|
||||
}
|
||||
await t.test("Image generation off takes the row away", async () => {
|
||||
const page = await open("en", settingsPayload("en", { imageGen: "off" }), 1100, []);
|
||||
await page.locator("#imagesList .row").nth(1).waitFor();
|
||||
assert.equal(await page.locator("#videoGenRow").count(), 0);
|
||||
assert.deepEqual(page.errors, []);
|
||||
await page.context().close();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// Settings › Images › Video generation lists a custom provider's model the
|
||||
// user marked a video model (#1399), and none of its others; one unticked
|
||||
// in its editor is left out unless it is the one picked; a pick no longer
|
||||
// marked is said missing, with Automatic's named.
|
||||
func TestVideoGenModelsListed(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: "studio", Name: "Studio", Chat: "https://studio.example/v1", Key: "sk-s", Models: []string{"chat-1", "seedance-x", "kling-y"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, ref := range []string{"studio/seedance-x", "studio/kling-y"} {
|
||||
if err := provider.SetModelKind(ref, provider.KindVideo); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
listed := func() (ids []string) {
|
||||
for _, m := range settingsState().VideoGenModels {
|
||||
if m.Provider == "studio" {
|
||||
ids = append(ids, m.ID)
|
||||
}
|
||||
}
|
||||
slices.Sort(ids)
|
||||
return
|
||||
}
|
||||
if got := listed(); !slices.Equal(got, []string{"studio/kling-y", "studio/seedance-x"}) {
|
||||
t.Fatalf("listed %v", got)
|
||||
}
|
||||
if a := settingsState().VideoGenAuto; a == "" {
|
||||
t.Fatal("no automatic video model")
|
||||
}
|
||||
|
||||
p, _ := provider.Find("studio")
|
||||
q := *p
|
||||
q.HiddenVideomakers = []string{"kling-y"}
|
||||
if err := provider.Save(q); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := listed(); !slices.Equal(got, []string{"studio/seedance-x"}) {
|
||||
t.Fatalf("an unticked one is listed: %v", got)
|
||||
}
|
||||
st := settings.Load()
|
||||
st.VideoGen = "studio/kling-y"
|
||||
if err := settings.Save(st); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := listed(); !slices.Equal(got, []string{"studio/kling-y", "studio/seedance-x"}) {
|
||||
t.Fatalf("the unticked pick isn't listed: %v", got)
|
||||
}
|
||||
if m := settingsState().VideoGenMissing; m != "" {
|
||||
t.Fatalf("a marked pick said missing: %q", m)
|
||||
}
|
||||
|
||||
if err := provider.SetModelKind("studio/kling-y", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := settingsState()
|
||||
if s.VideoGenMissing != "studio/kling-y" || s.VideoGenAuto != "studio/seedance-x" {
|
||||
t.Fatalf("unmarked pick: missing %q, automatic %q", s.VideoGenMissing, s.VideoGenAuto)
|
||||
}
|
||||
}
|
||||
@@ -500,6 +500,11 @@ type Settings struct {
|
||||
// "off" turns the video a request that names no model gets off too
|
||||
// (gateway.videomaker).
|
||||
ImageGen string `json:"imageGen,omitempty"`
|
||||
// VideoGen is the model a video request that names none is made with
|
||||
// (generate_video, the gateway's /v1/videos): a model's id, or empty
|
||||
// for one magpie picks (gateway.videomaker). ImageGen's "off" turns it
|
||||
// off too.
|
||||
VideoGen string `json:"videoGen,omitempty"`
|
||||
// ImageTimeout is how long, in minutes, a vendor is given to draw an
|
||||
// image and send it (neighbads on X: a slow image endpoint needs more
|
||||
// than 5): from 1 to ImageTimeoutMost, 0 for ImageTimeoutDefault.
|
||||
@@ -2299,6 +2304,10 @@ func saveOwn(s Settings, recording, reads bool) error {
|
||||
if s.ImageGen != "" && s.ImageGen != "off" && !strings.Contains(s.ImageGen, "/") {
|
||||
return fmt.Errorf("the image generation model must be a model's id such as openai/gpt-image-2, or off, not %q", s.ImageGen)
|
||||
}
|
||||
s.VideoGen = strings.TrimSpace(s.VideoGen)
|
||||
if s.VideoGen != "" && !strings.Contains(s.VideoGen, "/") {
|
||||
return fmt.Errorf("the video generation model must be a model's id such as grok/grok-imagine-video, not %q", s.VideoGen)
|
||||
}
|
||||
rules, err := redact.CheckRules(s.RedactRules)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -46,7 +46,7 @@ var Keys = []string{
|
||||
"workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin",
|
||||
// models: replies, vision, images, search
|
||||
"replyModel", "noLoopGuard", "claudeLeanPrompt", "claudePrintMode", "refusalRetries", "retryAfterCap",
|
||||
"vision", "visionEffort", "imageGen", "imageTimeout", "classifyTimeout",
|
||||
"vision", "visionEffort", "imageGen", "videoGen", "imageTimeout", "classifyTimeout",
|
||||
// what every routing group does that says nothing of its own
|
||||
"groupSink", "groupFirstToken", "groupPatience",
|
||||
"searcher", "searcherThen", "searcherEffort", "searchFirst",
|
||||
@@ -206,6 +206,10 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err
|
||||
in.RedactShape = cur.RedactShape
|
||||
}
|
||||
// nor how long an image is given to be drawn
|
||||
// nor the video model, picked in its own row
|
||||
if _, sent := fields["videoGen"]; !sent {
|
||||
in.VideoGen = cur.VideoGen
|
||||
}
|
||||
if _, sent := fields["imageTimeout"]; !sent {
|
||||
in.ImageTimeout = cur.ImageTimeout
|
||||
}
|
||||
@@ -385,6 +389,9 @@ func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, err
|
||||
return in, fmt.Errorf("no model %s to generate images", v)
|
||||
}
|
||||
}
|
||||
if v := strings.TrimSpace(in.VideoGen); v != "" && v != cur.VideoGen && gateway.VideomakerMissingOf(v) != "" {
|
||||
return in, fmt.Errorf("no model %s to make videos", v)
|
||||
}
|
||||
// the searchers after the one named, set in their own row: a save
|
||||
// that doesn't send them (prefsKeep has none) keeps them, and an
|
||||
// empty list clears them
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
"github.com/yetone/magpie/internal/testenv"
|
||||
)
|
||||
@@ -36,6 +37,8 @@ func sample(t reflect.Type, key string, was reflect.Value) reflect.Value {
|
||||
switch key {
|
||||
case "vision", "imageGen", "searcher", "searcherThen":
|
||||
s = "off" // a model is checked against the catalog
|
||||
case "videoGen":
|
||||
s = "studio/clip-1" // a video model, videoModel's
|
||||
}
|
||||
for _, c := range Choices[key] {
|
||||
if c != was.String() {
|
||||
@@ -78,6 +81,8 @@ func sample(t reflect.Type, key string, was reflect.Value) reflect.Value {
|
||||
// fails here, and so `magpie settings` can't fall behind the window
|
||||
// (#4745).
|
||||
func TestKeysAreWhatTheSaveWrites(t *testing.T) {
|
||||
home(t)
|
||||
videoModel(t)
|
||||
cur := settings.Defaults()
|
||||
curJSON, err := json.Marshal(cur)
|
||||
if err != nil {
|
||||
@@ -127,6 +132,46 @@ func TestKeysAreWhatTheSaveWrites(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// videoModel sets up a provider whose clip-1 the user marked a video
|
||||
// model (#1399), so studio/clip-1 is one videoGen can name.
|
||||
func videoModel(t *testing.T) {
|
||||
t.Helper()
|
||||
if err := provider.Save(provider.Provider{ID: "studio", Name: "Studio", Chat: "https://studio.example/v1", Key: "sk-studio", Models: []string{"chat-1", "clip-1"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := provider.SetModelKind("studio/clip-1", provider.KindVideo); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Settings › Images' video model: a model that makes videos is saved, one
|
||||
// that doesn't (a chat model, or none such) is refused, and a save from
|
||||
// another row, which doesn't send it, keeps it.
|
||||
func TestVideoGenCheckedAndKept(t *testing.T) {
|
||||
home(t)
|
||||
videoModel(t)
|
||||
for _, bad := range []string{"studio/chat-1", "studio/nope", "clip-1"} {
|
||||
if _, _, err := Apply([]byte(`{"videoGen":"`+bad+`"}`), false); err == nil {
|
||||
t.Errorf("%s was taken as a video model", bad)
|
||||
}
|
||||
}
|
||||
if _, _, err := Apply([]byte(`{"videoGen":"studio/clip-1"}`), false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, _, err := Apply([]byte(`{"theme":"dark"}`), false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := settings.Load().VideoGen; got != "studio/clip-1" {
|
||||
t.Fatalf("videoGen %q after another row's save", got)
|
||||
}
|
||||
if _, _, err := Apply([]byte(`{"videoGen":""}`), false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := settings.Load().VideoGen; got != "" {
|
||||
t.Fatalf("Automatic left videoGen %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func minus(a, b []string) []string {
|
||||
var out []string
|
||||
for _, k := range a {
|
||||
|
||||
Reference in New Issue
Block a user