matrix0487 on Discord (#feedback, 11-05) asked to change image-files from
the GUI: 8fbf8e0af made it CLI-only (`magpie provider set <id>
image-files=off`). The editor's Advanced now has an Images tick, "Upload
images once and send them by file id", on by default. It shows only where
the setting has effect: a provider on api.deepseek.com, the built-in
DeepSeek or a custom one with that base.
The rule has one source: provider.ImageFilesAt(to) (own key, no account or
plugin, Chat/Responses/Anthropic, host == provider.DeepSeekHost), and
TakesImageFiles for the editor. The gateway's dsFilesOn and forward's
dsSent setup ask ImageFilesAt instead of their own host checks.
/api/providers sends imageFilesOff and takesImageFiles; /api/provider/save
takes imageFilesOff as *bool, so a save that leaves it out keeps the old
value (CLI-set off stays off), false turns it on, true off. app.js sends it
only when the row is shown. Strings in zh, zh-TW, ja and de. app.js is 135
bytes under its base (four comments cut to one line); no budget raised.
Run on mote:
- provider-image-files.test.cjs: chromium + webkit, en/zh/zh-TW/ja/de,
1100 and 420 wide, 60/60. Shown for DeepSeek and a custom
api.deepseek.com base, hidden for another relay, toggling saves the
field, CLI-set off shows off.
- i18n-keys, i18n-en-no-cjk, editor-advanced-align, editor-fold-clickable,
provider-limit-rest, provider-image-files: 131/132; the red is i18n-keys
"a plugin's words are its own" from other tests' strings ("View
routing", "No session ID"), #5332 / #5327.
- go test -timeout 45m ./internal/provider ./internal/gateway
./internal/cli ok; ./internal/gui ok but TestMainWindowCorners, the
macOS 27 red (#3949). TestProviderSaveImageFiles and
TestCoreScriptBudget rerun after the comment cut.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Broken by hand, each red then restored:
- row condition `if (false)`: GUI red (chromium en 420).
- save field renamed: GUI red (webkit zh 420).
- imageFilesOff left out of draftOf: GUI red ("one set off from the CLI").
- the old keep-only save restored: TestProviderSaveImageFiles red
("ticked on in the editor, still saved off").
- host rule loosened to contains "deepseek": TestProviderSaveImageFiles
red (api.deepseek.com.example.com offered).
Not tried: a real DeepSeek key or the real app; a URL edit on an unsaved
provider doesn't show or hide the row live (it follows the saved row's
flag).
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package provider
|
|
|
|
// DeepSeekHost is DeepSeek's own API. A relay or another base serving
|
|
// DeepSeek's models is not it.
|
|
const DeepSeekHost = "api.deepseek.com"
|
|
|
|
// ImageFilesAt says whether p's requests on to reach DeepSeek's own API
|
|
// with a key of the user's, where an agent's inline images can go up once
|
|
// through DeepSeek's Files API and be named by file id (gateway's
|
|
// deepseek_files.go, #5407). ImageFilesOff turns that off; this says only
|
|
// where it can apply.
|
|
func (p Provider) ImageFilesAt(to Protocol) bool {
|
|
if p.Account != nil || p.IsPlugin() {
|
|
return false
|
|
}
|
|
if to != Chat && to != Responses && to != Anthropic {
|
|
return false
|
|
}
|
|
return HostOf(p.Base(to)) == DeepSeekHost
|
|
}
|
|
|
|
// TakesImageFiles says whether ImageFilesOff has any effect on p: one of
|
|
// its Chat, Responses or Anthropic URLs is DeepSeek's own API. The
|
|
// editor offers image-files only then.
|
|
func (p Provider) TakesImageFiles() bool {
|
|
for _, to := range []Protocol{Chat, Responses, Anthropic} {
|
|
if p.ImageFilesAt(to) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|