gui: DeepSeek's image-files setting in the provider editor's Advanced (#5407)
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).
This commit is contained in:
@@ -295,7 +295,7 @@ recorded as a prediction failure (`noPrediction`).
|
||||
- Structured output is carried across every translation (`Format`, [`format.go`](../../internal/gateway/format.go)). It is read from Responses' `text.format`, Chat's `response_format`, Anthropic's `output_config.format` and Gemini's `responseMimeType` with `responseJsonSchema`/`responseSchema`: `json_schema` with its name, description, schema and strict, or `json_object`. Each upstream is asked in its own field: `text.format` on Responses, `response_format` on Chat, `output_config.format` on Messages, and `generationConfig.responseMimeType`/`responseJsonSchema` on Gemini and Code Assist. An API with no name for it gets `response`. Messages and the Claude subscription's `--json-schema` take a schema only, so `json_object` is told in the system prompt there (`inSystem`). A 400 or 422 that names the field (`refusesFormat`: DeepSeek's "This response_format type is unavailable now", a schema Anthropic can't hold) marks the provider and model (`formatRefused`), and the request is asked again with the format told in the system prompt, as are later requests to that provider and model. A relayed request keeps its format as sent. A Gemini client's format is also still told in its system prompt, as before. A model may still wrap its JSON answer in a Markdown code fence; a client that asked for structured output, in a field or told in the system prompt (`wantsJSON`), gets the JSON inside a single unlabelled or json-labelled fence when that content is a complete valid JSON value, streamed (`fenceEncoder`) or whole (`unfencedResult`), in [`format_fence.go`](../../internal/gateway/format_fence.go). Invalid or truncated JSON, other fence languages, text outside the fence, and answers to plain-text clients reach the client as they came. This normalization applies to translated replies; native protocol passthrough stays byte-preserving.
|
||||
- A tool's images reach the model on every translation (`toolOutput` in [`ir.go`](../../internal/gateway/ir.go) reads them from Anthropic's `tool_result`, Responses' `function_call_output`, such as Codex's `view_image` output `[{"type":"input_image","image_url":"data:…"}]`, and a Chat tool message). Anthropic's Messages keeps them in the `tool_result`. Chat puts them in a user message right after the results, and the result says they follow; Gemini and Code Assist after the function's response. Kiro's results hold text alone, so Kiro's plugin (from 0.1.9 on) sends them with the message that answers the call, and only the latest images go again (#369, #1861). `TestCodexToolImageReachesAnthropicPlugin` and the Kiro plugin's `tool-images.test.mjs`.
|
||||
- An image's `detail` (`Part.Detail`, read from a Responses `input_image` and a Chat `image_url`, in a message or a tool's output) is carried on a translation to Chat and Responses (`chatImage`, `chatDetail`, `responsesDetail` in [`chat.go`](../../internal/gateway/chat.go)). Chat takes `low`, `high` and `auto` as they came, and Responses' `original`, which Chat lacks, as `high`; an image without one goes without. Responses takes the four as they came, and anything else, none included, as `auto` (#1474). Messages and Gemini have no such field, so it isn't sent there (mysterious_dove on Discord, Codex: `high` and `original` were dropped on the way to Chat; `TestResponsesImageDetailReachesChat`, `TestChatImageDetailReachesResponses`).
|
||||
- DeepSeek's own API (`api.deepseek.com`, never a relay or another base) is sent an agent's inline images by file id, not their bytes on every turn (#5407, faithleysath; [`deepseek_files.go`](../../internal/gateway/deepseek_files.go)). `withDeepSeekFiles`, in `forwardOnce` after the thinking is put back and before the byte cap, finds each base64 `data:` image a Chat, Responses or Anthropic body holds (`walkImages`: messages and tool outputs) for a model with `flash` in its name (deepseek-flash sees images; deepseek-v4-pro reads each as "[Unsupported Image]"), with the provider's key, not on count_tokens, and not where the provider is set `imageFilesOff` (`magpie provider set <id> image-files=off`). An image asked at `detail: low` stays inline, as a file is read at full size. Each image not held yet goes up once through `POST /files` on the provider's host (multipart, `purpose=user_data`, `expires_after` a day from creation), signed as a Chat request with the candidate's own key; the swap is per key (`dsKeyHash` beside the image's sha256), so an id never goes with another key. The block becomes Chat's flat `{"type":"file","file_id":…}`, a Responses `input_image` with `file_id` in place of `image_url`, or an Anthropic image whose `source` is `{"type":"file","file_id":…}` with `anthropic-beta: files-api-2025-04-14` added, as DeepSeek's files_api, vision, responses_api and anthropic_api guides give them (the Anthropic guide names the `file` source type and the beta; its field name `file_id` is Anthropic's Files API's, which DeepSeek says it follows). The ids are kept in `deepseek-files.json` beside providers.json (temp file and rename; an unparseable one moved to `.bad`), an id with under an hour left uploaded again, at most 4000 kept. One upload runs per image and key however many requests want it (`flights`), at most four at once for a request, outliving a cancelled request with its own deadline (20s, plus a second per 64KiB). A failed upload leaves the image inline and rests the key's uploads for ten minutes (`dsFilesBreak`); a request waits on an upload for `dsWaitMax` at most and sends what isn't up yet inline. A 4xx whose body names a `file-api-` id or says a file is gone (`dsFileGone`) lets the ids go and asks once more with new uploads (`dsRetryGone` in `forward`); refused so again, it goes inline. Uploaded bytes count in the request's upstream bytes (#4456). Not covered: a `custom_tool_call_output`'s images (walkImages doesn't read it), and no file is deleted (`DELETE /files`): each expires in a day. `TestDeepSeekImagesByFile`, `TestDeepSeekImagesInlineElsewhere`, `TestDeepSeekImageFilesOff`, `TestDeepSeekUploadFailsInline`, `TestDeepSeekUploadSlowGoesInline`, `TestDeepSeekFileGoneUploadsAgain`, `TestDeepSeekFilesPerKey`, `TestDeepSeekFilesOneUpload`, `TestDeepSeekFilesKeptOnDisk`.
|
||||
- DeepSeek's own API (`api.deepseek.com`, never a relay or another base) is sent an agent's inline images by file id, not their bytes on every turn (#5407, faithleysath; [`deepseek_files.go`](../../internal/gateway/deepseek_files.go)). `withDeepSeekFiles`, in `forwardOnce` after the thinking is put back and before the byte cap, finds each base64 `data:` image a Chat, Responses or Anthropic body holds (`walkImages`: messages and tool outputs) for a model with `flash` in its name (deepseek-flash sees images; deepseek-v4-pro reads each as "[Unsupported Image]"), with the provider's key, not on count_tokens, and not where the provider is set `imageFilesOff` (`magpie provider set <id> image-files=off`, or the editor's *Images* tick under Advanced, offered only where `provider.TakesImageFiles` holds: the one host rule, `ImageFilesAt`, that `dsFilesOn` asks; matrix0487 on Discord; `TestProviderSaveImageFiles`, `provider-image-files.test.cjs`). An image asked at `detail: low` stays inline, as a file is read at full size. Each image not held yet goes up once through `POST /files` on the provider's host (multipart, `purpose=user_data`, `expires_after` a day from creation), signed as a Chat request with the candidate's own key; the swap is per key (`dsKeyHash` beside the image's sha256), so an id never goes with another key. The block becomes Chat's flat `{"type":"file","file_id":…}`, a Responses `input_image` with `file_id` in place of `image_url`, or an Anthropic image whose `source` is `{"type":"file","file_id":…}` with `anthropic-beta: files-api-2025-04-14` added, as DeepSeek's files_api, vision, responses_api and anthropic_api guides give them (the Anthropic guide names the `file` source type and the beta; its field name `file_id` is Anthropic's Files API's, which DeepSeek says it follows). The ids are kept in `deepseek-files.json` beside providers.json (temp file and rename; an unparseable one moved to `.bad`), an id with under an hour left uploaded again, at most 4000 kept. One upload runs per image and key however many requests want it (`flights`), at most four at once for a request, outliving a cancelled request with its own deadline (20s, plus a second per 64KiB). A failed upload leaves the image inline and rests the key's uploads for ten minutes (`dsFilesBreak`); a request waits on an upload for `dsWaitMax` at most and sends what isn't up yet inline. A 4xx whose body names a `file-api-` id or says a file is gone (`dsFileGone`) lets the ids go and asks once more with new uploads (`dsRetryGone` in `forward`); refused so again, it goes inline. Uploaded bytes count in the request's upstream bytes (#4456). Not covered: a `custom_tool_call_output`'s images (walkImages doesn't read it), and no file is deleted (`DELETE /files`): each expires in a day. `TestDeepSeekImagesByFile`, `TestDeepSeekImagesInlineElsewhere`, `TestDeepSeekImageFilesOff`, `TestDeepSeekUploadFailsInline`, `TestDeepSeekUploadSlowGoesInline`, `TestDeepSeekFileGoneUploadsAgain`, `TestDeepSeekFilesPerKey`, `TestDeepSeekFilesOneUpload`, `TestDeepSeekFilesKeptOnDisk`.
|
||||
- A Gemini client's `generationConfig.imageConfig`, the size and shape it asks an image model to draw at (`imageSize`, `aspectRatio`, and Vertex AI's own fields beside them), is carried as it was sent on a translation to an upstream that speaks Gemini: a custom provider's Gemini URL, Vertex AI, and Code Assist and Antigravity inside their envelope (`Request.ImageConfig`, `buildCodeAssistSent` in [`codeassist.go`](../../internal/gateway/codeassist.go)). A relayed request keeps it as sent. Chat, Responses and Messages have no field for it that magpie knows, so it isn't sent there. A request asked for one body that carries it is translated on the Gemini URL even where the provider has a Chat URL too (One try above); one that doesn't goes to Chat there, unless the user set the model's API to Gemini (#3820, GuoJinguang: `imageSize` 4K asked through magpie drew 1024x1024; `TestGeminiImageConfigReachesTheGeminiAPI`, `TestGeminiImageConfigReachesCodeAssist`).
|
||||
- Group members are `provider/model[:effort]`. A member with a fixed effort is asked for that effort, bounded by the group's levels (#671).
|
||||
- A member the user unchecked in its provider's model list is skipped (`unpicked` in [`group.go`](../../internal/provider/group.go), in `membersOff`; #3911, timonwong): the provider has picks and its served models lack it, as the Routing page strikes it, and the Routing card says it is not ready (`provider.ResolveRoute`). A provider with no picks still routes a model its list lacks (#2642), a decision model is still a decision group's, and a request naming the model itself still reaches it (`resolveIn` takes any `provider/model` of a provider that is on). `group_model_pick_test.go`.
|
||||
|
||||
@@ -813,7 +813,7 @@ var effortInOutputConfig = regexp.MustCompile(`(?i)glm-5\.[23](?:$|[-.:/\[])|min
|
||||
|
||||
// deepseekHost is DeepSeek's own API, whose Anthropic endpoint
|
||||
// (api.deepseek.com/anthropic) takes the effort in output_config.
|
||||
const deepseekHost = "api.deepseek.com"
|
||||
const deepseekHost = provider.DeepSeekHost
|
||||
|
||||
// deepseekEfforts are the levels DeepSeek's models think at: its thinking
|
||||
// guide maps minimal to low, medium and xhigh to high, and ultra to max.
|
||||
|
||||
@@ -78,13 +78,7 @@ const (
|
||||
// key, a model that sees images, a request that asks a reply, and the
|
||||
// provider not set image-files=off.
|
||||
func dsFilesOn(p provider.Provider, to provider.Protocol, path string, body []byte) bool {
|
||||
if p.ImageFilesOff || p.Key == "" || p.Account != nil || p.IsPlugin() || countsTokens(path) {
|
||||
return false
|
||||
}
|
||||
if to != provider.Chat && to != provider.Responses && to != provider.Anthropic {
|
||||
return false
|
||||
}
|
||||
if provider.HostOf(p.Base(to)) != deepseekHost {
|
||||
if p.ImageFilesOff || p.Key == "" || countsTokens(path) || !p.ImageFilesAt(to) {
|
||||
return false
|
||||
}
|
||||
// deepseek-flash sees images; deepseek-v4-pro reads each as the text
|
||||
|
||||
@@ -5359,7 +5359,7 @@ func (s *Server) forward(ctx context.Context, p provider.Provider, to provider.P
|
||||
heardNet() // the network is up (offline.go)
|
||||
}
|
||||
}()
|
||||
if provider.HostOf(p.Base(to)) == deepseekHost {
|
||||
if p.ImageFilesAt(to) {
|
||||
// which images a try named by file (deepseek_files.go)
|
||||
ctx = context.WithValue(ctx, dsSentKey{}, &dsSent{})
|
||||
}
|
||||
|
||||
+15
-15
@@ -8001,7 +8001,7 @@ function advancedSet(d, p) {
|
||||
!!d.proxyMode || Object.values(d.accountProxies || {}).some((x) => x?.mode) ||
|
||||
[d.concurrency, d.maxAccounts, d.queueLimit, d.queueWait, d.maxRPM, d.priceRate, d.contexts, d.outputs, d.compacts].some((v) => String(v ?? "").trim()) ||
|
||||
!!d.rateWindows?.length ||
|
||||
!!(d.searches || d.authHeader || d.passUserAgent || d.unredacted || d.countFree || d.pinUpstream || d.nativeCompaction || d.balanceToken || d.limitRestOff) ||
|
||||
!!(d.searches || d.authHeader || d.passUserAgent || d.unredacted || d.countFree || d.pinUpstream || d.nativeCompaction || d.balanceToken || d.limitRestOff || d.imageFilesOff) ||
|
||||
!!d.fallback?.length || !!p?.balanceToken?.set;
|
||||
}
|
||||
function priceRateError(ed) {
|
||||
@@ -9196,7 +9196,7 @@ 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 || [])], 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 })) };
|
||||
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, imageFilesOff: !!p.imageFilesOff, 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, its key p's unless another is pasted (#268).
|
||||
@@ -9449,11 +9449,7 @@ function drawEditor(p, presetID) {
|
||||
ed.append(...field("Base URL", urlWrap));
|
||||
}
|
||||
|
||||
// the Cline API serves a model from whichever host its AI gateway picks;
|
||||
// pinned, its DeepSeek models are served by DeepSeek's own API alone and
|
||||
// its GLM models by Z.ai's (sdytman on Discord), which keeps their prompt
|
||||
// cache (White Immortal on Discord). One tick for both makers. ClinePass,
|
||||
// or the Cline plugin's provider (ARNO on Discord)
|
||||
// Cline's DeepSeek and GLM models pinned to their makers' APIs (sdytman, ARNO on Discord)
|
||||
const upstreamField = () => {
|
||||
const [ptk, pcb] = tick(t("DeepSeek and GLM models only from their makers' own APIs"), !!draft.pinUpstream);
|
||||
ptk.classList.add("pin-upstream");
|
||||
@@ -9461,9 +9457,7 @@ function drawEditor(p, presetID) {
|
||||
return field(t("Upstream"), ptk, t("Cline serves a model from any host its gateway picks; pinned, a request for a DeepSeek model goes only to DeepSeek and one for a GLM model only to Z.ai, which keeps its prompt cache, and fails when that API can't take it"));
|
||||
};
|
||||
|
||||
// the settings few need — headers, proxy, limits, windows, fallback —
|
||||
// folded under Advanced, out of the way of the key and the models: open
|
||||
// when one of them is set, or as it was left in this editor
|
||||
// the settings few need, under Advanced: open when one is set, or as left here
|
||||
const adv = edAligned(el("details", "more advanced"));
|
||||
adv.open = advanced && advanced.of === editing ? advanced.open : advancedSet(draft, p) || (custom && !!(draft.balanceURL || "").trim());
|
||||
const of = editing;
|
||||
@@ -9725,9 +9719,7 @@ function drawEditor(p, presetID) {
|
||||
// A user-defined provider can have its own picture; presets keep theirs.
|
||||
if (custom) ed.append(...field(t("Icon"), iconPicker(ed), ""));
|
||||
|
||||
// Request headers of the user's own, for a preset's provider as much as a
|
||||
// custom one — which workspace a key is for, who the app is; signed-in
|
||||
// accounts returned above use the agent's own authentication headers.
|
||||
// the user's own request headers, a preset's or a custom one's
|
||||
if (custom) {
|
||||
if (!draft.headers.length) draft.headers.push(["", ""]);
|
||||
advIn.append(...field(t("Headers"), headerEditor(), t("Extra HTTP headers sent to the vendor, applied after auth. For gateways that need a private scheme. ${sessionId} in a value is the conversation's id; ${threadId} is the thread's, where the agent names one (Codex), else the same.")));
|
||||
@@ -9817,6 +9809,14 @@ function drawEditor(p, presetID) {
|
||||
advIn.append(...field(t("Rests"), rtk, t("Off: a 429 or an out-of-quota refusal doesn't rest its keys, and the next request is sent to it as usual. For a relay whose limits pass in a moment.")));
|
||||
}
|
||||
|
||||
// image-files, on DeepSeek's own API (#5407)
|
||||
if (p?.takesImageFiles) {
|
||||
const [itk, icb] = tick(t("Upload images once and send them by file id"), !draft.imageFilesOff);
|
||||
itk.classList.add("image-files");
|
||||
icb.onchange = () => { draft.imageFilesOff = !icb.checked; };
|
||||
advIn.append(...field(t("Images"), itk, t("Off: an agent's images are sent inline on every turn.")));
|
||||
}
|
||||
|
||||
// a balance token of the vendor's own (AiHubMix), or a custom one's (balanceFix), its URL above (balSlot)
|
||||
let balFix = null, balSlot = null;
|
||||
if (custom) {
|
||||
@@ -9913,8 +9913,7 @@ function drawEditor(p, presetID) {
|
||||
}
|
||||
}
|
||||
|
||||
// a relay that offers several regional endpoints, or a vendor whose plans
|
||||
// are served at their own: one selector, and the provider's base URLs follow it
|
||||
// regional endpoints or plans: one selector the base URLs follow
|
||||
let refreshEndpoints = () => {}, onRegion = () => {};
|
||||
if (pr?.regions?.length) {
|
||||
// Bedrock's ten regions don't fit the width: they scroll
|
||||
@@ -10166,6 +10165,7 @@ function drawEditor(p, presetID) {
|
||||
body.countFree = !!draft.countFree;
|
||||
if (tlsTakes()) body.insecureTLS = !!draft.insecureTLS && onHTTPS();
|
||||
if (custom) body.limitRestOff = !!draft.limitRestOff;
|
||||
if (p?.takesImageFiles) body.imageFilesOff = !!draft.imageFilesOff;
|
||||
if (!decideOnly(p || pr)) body.nativeCompaction = !!draft.nativeCompaction && carriesCompaction();
|
||||
body.passUserAgent = !!draft.passUserAgent && uaPassable();
|
||||
const cx = parseContexts(draft.contexts || "");
|
||||
|
||||
@@ -4032,6 +4032,8 @@ const I18N = {
|
||||
"Set it aside when out of quota or rate limited": "额度用完或被限流时暂停它",
|
||||
"Rests": "暂停",
|
||||
"Off: a 429 or an out-of-quota refusal doesn't rest its keys, and the next request is sent to it as usual. For a relay whose limits pass in a moment.": "关闭后:429 或额度用完的拒绝不会让它的密钥暂停,下一个请求照常发给它。适合限额很快就会恢复的中转。",
|
||||
"Upload images once and send them by file id": "图片只上传一次,之后按文件 ID 发送",
|
||||
"Off: an agent's images are sent inline on every turn.": "关闭后:智能体的图片每一轮都直接随请求发送。",
|
||||
"Certificate": "证书",
|
||||
"For your own server with a self-signed certificate or one from your company's CA. magpie then can't tell it from another machine answering at its address: turn it on only on a network you trust.": "用于你自己的服务器,证书是自签名的或来自公司内部 CA。开启后 magpie 无法分辨应答的是它本身还是同一地址上的另一台机器:只在你信任的网络中开启。",
|
||||
"Codex compacts on this provider": "Codex 在此服务商上原生压缩",
|
||||
@@ -8634,6 +8636,8 @@ const I18N = {
|
||||
"Set it aside when out of quota or rate limited": "額度用完或被限流時暫停它",
|
||||
"Rests": "暫停",
|
||||
"Off: a 429 or an out-of-quota refusal doesn't rest its keys, and the next request is sent to it as usual. For a relay whose limits pass in a moment.": "關閉後:429 或額度用完的拒絕不會讓它的金鑰暫停,下一個請求照常送給它。適合限額很快就會恢復的中轉。",
|
||||
"Upload images once and send them by file id": "圖片只上傳一次,之後按檔案 ID 傳送",
|
||||
"Off: an agent's images are sent inline on every turn.": "關閉後:代理的圖片每一輪都直接隨請求傳送。",
|
||||
"Certificate": "憑證",
|
||||
"For your own server with a self-signed certificate or one from your company's CA. magpie then can't tell it from another machine answering at its address: turn it on only on a network you trust.": "用於你自己的伺服器,憑證是自簽的或來自公司內部 CA。開啟後 magpie 無法分辨應答的是它本身還是同一位址上的另一台機器:只在你信任的網路中開啟。",
|
||||
"Codex compacts on this provider": "Codex 在此服務商上原生壓縮",
|
||||
@@ -13252,6 +13256,8 @@ const I18N = {
|
||||
"Set it aside when out of quota or rate limited": "クォータ切れやレート制限で一時的に外す",
|
||||
"Rests": "一時停止",
|
||||
"Off: a 429 or an out-of-quota refusal doesn't rest its keys, and the next request is sent to it as usual. For a relay whose limits pass in a moment.": "オフ:429 やクォータ切れで拒否されてもキーを休ませず、次のリクエストはいつも通り送られます。制限がすぐ解けるリレー向けです。",
|
||||
"Upload images once and send them by file id": "画像は一度だけアップロードし、以降はファイル ID で送る",
|
||||
"Off: an agent's images are sent inline on every turn.": "オフ:エージェントの画像を毎ターンそのまま送ります。",
|
||||
"Certificate": "証明書",
|
||||
"For your own server with a self-signed certificate or one from your company's CA. magpie then can't tell it from another machine answering at its address: turn it on only on a network you trust.": "自己署名証明書や社内 CA の証明書を使う自分のサーバー向けです。オンにすると、magpie はそのアドレスで応答しているのが本物か別のマシンかを見分けられません。信頼できるネットワークでのみオンにしてください。",
|
||||
"Codex compacts on this provider": "Codex のコンパクションをこのプロバイダーで行う",
|
||||
@@ -17885,6 +17891,8 @@ const I18N = {
|
||||
"Set it aside when out of quota or rate limited": "Bei aufgebrauchtem Kontingent oder Ratenlimit pausieren",
|
||||
"Rests": "Pausen",
|
||||
"Off: a 429 or an out-of-quota refusal doesn't rest its keys, and the next request is sent to it as usual. For a relay whose limits pass in a moment.": "Aus: Ein 429 oder eine Ablehnung wegen aufgebrauchtem Kontingent pausiert seine Schlüssel nicht, die nächste Anfrage geht wie gewohnt an ihn. Für ein Relay, dessen Limits gleich wieder vorbei sind.",
|
||||
"Upload images once and send them by file id": "Bilder einmal hochladen und per Datei-ID senden",
|
||||
"Off: an agent's images are sent inline on every turn.": "Aus: Die Bilder eines Agenten werden in jeder Runde direkt mitgeschickt.",
|
||||
"Certificate": "Zertifikat",
|
||||
"For your own server with a self-signed certificate or one from your company's CA. magpie then can't tell it from another machine answering at its address: turn it on only on a network you trust.": "Für Ihren eigenen Server mit selbstsigniertem Zertifikat oder einem Ihrer Firmen-CA. magpie kann ihn dann nicht von einem anderen Rechner unterscheiden, der unter seiner Adresse antwortet: nur in einem Netzwerk einschalten, dem Sie vertrauen.",
|
||||
"Codex compacts on this provider": "Codex kompaktiert bei diesem Anbieter",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// matrix0487 (Discord, 11-05): image-files, set only with `magpie provider
|
||||
// set <id> image-files=off` (#5407), is offered in the editor of a provider
|
||||
// on DeepSeek's own API, the built-in one or a custom one there, and only
|
||||
// there. A value set from the CLI opens as set, a Save that leaves it out
|
||||
// keeps it, and the editor's tick saves it either way.
|
||||
func TestProviderSaveImageFiles(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())
|
||||
}
|
||||
}
|
||||
info := func(id string) providerJSON {
|
||||
t.Helper()
|
||||
p, err := provider.Find(id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
in := providerInfo(*p, nil)
|
||||
if in.ImageFilesOff != p.ImageFilesOff {
|
||||
t.Fatalf("%s: the editor is shown off=%v, saved off=%v", id, in.ImageFilesOff, p.ImageFilesOff)
|
||||
}
|
||||
return in
|
||||
}
|
||||
|
||||
// the built-in DeepSeek, set off from the CLI (the field it writes)
|
||||
ds, err := provider.FromPreset("deepseek")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ds.Key = "sk-ds"
|
||||
ds.ImageFilesOff = true
|
||||
if err := provider.Save(ds); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := info("deepseek"); !got.TakesImageFiles || !got.ImageFilesOff {
|
||||
t.Fatalf("built-in DeepSeek set off from the CLI: offered %v, shown off %v", got.TakesImageFiles, got.ImageFilesOff)
|
||||
}
|
||||
edit := `{"id":"deepseek","from":"deepseek","name":"DeepSeek","preset":"deepseek","key":"","chat":"` + ds.Chat + `","responses":"` + ds.Responses + `","anthropic":"` + ds.Anthropic + `","catalog":"deepseek","models":[],"headers":{}`
|
||||
post(edit + `}`)
|
||||
if !info("deepseek").ImageFilesOff {
|
||||
t.Fatal("a Save that left it out turned the CLI's off back on")
|
||||
}
|
||||
post(edit + `,"imageFilesOff":false}`)
|
||||
if info("deepseek").ImageFilesOff {
|
||||
t.Fatal("ticked on in the editor, still saved off")
|
||||
}
|
||||
post(edit + `,"imageFilesOff":true}`)
|
||||
if !info("deepseek").ImageFilesOff {
|
||||
t.Fatal("unticked in the editor, still saved on")
|
||||
}
|
||||
|
||||
// a custom provider on DeepSeek's own API is offered it, added off
|
||||
post(`{"id":"mine","name":"Mine","key":"sk-m","anthropic":"https://api.deepseek.com/anthropic","icon":"generic","new":true,"imageFilesOff":true}`)
|
||||
if got := info("mine"); !got.TakesImageFiles || !got.ImageFilesOff {
|
||||
t.Fatalf("custom on api.deepseek.com: offered %v, off %v", got.TakesImageFiles, got.ImageFilesOff)
|
||||
}
|
||||
|
||||
// another base, a relay serving DeepSeek's models included, is not
|
||||
post(`{"id":"relay","name":"Relay","key":"sk-r","chat":"https://relay.example.com/deepseek/v1","icon":"generic","new":true}`)
|
||||
post(`{"id":"near","name":"Near","key":"sk-n","chat":"https://api.deepseek.com.example.com/v1","icon":"generic","new":true}`)
|
||||
for _, id := range []string{"relay", "near"} {
|
||||
if info(id).TakesImageFiles {
|
||||
t.Errorf("%s isn't DeepSeek's own API, yet offered image-files", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,6 +128,11 @@ type providerJSON struct {
|
||||
// asked as usual after a quota refusal or a 429, never set aside for
|
||||
// it (provider.LimitRestOff)
|
||||
LimitRestOff bool `json:"limitRestOff"`
|
||||
// DeepSeek's own API sent an agent's images inline on every turn, not
|
||||
// once by file id (provider.ImageFilesOff, #5407); TakesImageFiles:
|
||||
// it is DeepSeek's own API, so the editor offers it
|
||||
ImageFilesOff bool `json:"imageFilesOff"`
|
||||
TakesImageFiles bool `json:"takesImageFiles,omitempty"`
|
||||
// Codex's compaction asked of it as Codex sent it, its sealed item
|
||||
// back as it came (provider.NativeCompaction, #1099); CarriesCompaction: its
|
||||
// wire can carry it, so the editor offers it
|
||||
@@ -719,7 +724,7 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
|
||||
ID: p.ID, Name: p.Name, Icon: p.Icon, IconFrom: p.IconFrom, Preset: p.Preset, Host: p.Host(),
|
||||
Chat: p.Chat, Responses: p.Responses, Anthropic: p.Anthropic, Gemini: p.Gemini, Decide: p.Decide, BaseAPI: p.BaseAPI, ModelTest: p.ModelTest(), TestsAs: p.TestClients(), DecideTest: p.AsksDecideModels(), MarksKinds: p.MarksKinds(),
|
||||
Catalog: p.Catalog, Website: p.Website, KeysURL: p.KeysURL,
|
||||
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, AccountNames: p.AccountNames, Headers: p.Headers, ExtraBody: p.ExtraBody, ReplyHeaders: p.ReplyHeaders, PassHeaders: p.PassHeaders, Searches: p.Searches, Cline: p.ClinePinnable(), PinUpstream: p.PinUpstream, Unredacted: p.Unredacted, CountFree: p.CountFree, InsecureTLS: p.InsecureTLS, TakesInsecureTLS: p.TakesInsecureTLS(), LimitRestOff: p.LimitRestOff, NativeCompaction: p.NativeCompaction, CarriesCompaction: p.CarriesCompaction(), PassUserAgent: p.PassUserAgent, OwnClient: p.OwnClient(), AuthHeader: p.AuthHeader, BothAuth: p.BothAuth(), BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, BalanceMethod: p.BalanceMethod, ModelsURL: p.ModelsURL,
|
||||
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, AccountNames: p.AccountNames, Headers: p.Headers, ExtraBody: p.ExtraBody, ReplyHeaders: p.ReplyHeaders, PassHeaders: p.PassHeaders, Searches: p.Searches, Cline: p.ClinePinnable(), PinUpstream: p.PinUpstream, Unredacted: p.Unredacted, CountFree: p.CountFree, InsecureTLS: p.InsecureTLS, TakesInsecureTLS: p.TakesInsecureTLS(), LimitRestOff: p.LimitRestOff, ImageFilesOff: p.ImageFilesOff, TakesImageFiles: p.TakesImageFiles(), NativeCompaction: p.NativeCompaction, CarriesCompaction: p.CarriesCompaction(), PassUserAgent: p.PassUserAgent, OwnClient: p.OwnClient(), AuthHeader: p.AuthHeader, BothAuth: p.BothAuth(), BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, BalanceMethod: p.BalanceMethod, ModelsURL: p.ModelsURL,
|
||||
Ready: p.Ready(), Chosen: p.PicksOf(avail), Agents: make([]providerAgent, 0, len(agents)),
|
||||
Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, RestartApp: p.RestartApp, Self: p.SelfAnswered(), KeepSelf: p.KeepSelf, CapStop: p.CapStop, CapCareful: p.CapCareful, Unlisted: p.Unlisted, NoModels: p.ServesNone(), BestInFamily: p.BestInFamily && len(p.Models) == 0 && !p.NoModels, Off: p.Off, Contexts: p.Contexts,
|
||||
MaxConcurrency: p.MaxConcurrency, PluginConcurrency: p.PluginConcurrency(), MaxAccounts: p.MaxAccounts, PluginAccounts: p.PluginAtOnce(), PriceRate: p.PriceRate,
|
||||
@@ -1458,6 +1463,10 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
// LimitRestOff is whether a quota refusal or a 429 leaves it
|
||||
// asked as usual; a save that leaves it out keeps it
|
||||
LimitRestOff *bool `json:"limitRestOff"`
|
||||
// ImageFilesOff is whether DeepSeek's own API is sent an
|
||||
// agent's images inline (#5407); a save that leaves it out
|
||||
// keeps it, as `magpie provider set <id> image-files=off` set it
|
||||
ImageFilesOff *bool `json:"imageFilesOff"`
|
||||
// MaxConcurrency is how many requests each of its keys or
|
||||
// accounts has out at once: a number (0 none), null for what
|
||||
// its plugin says or none; a save that leaves it out keeps it
|
||||
@@ -1841,6 +1850,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
if req.LimitRestOff != nil {
|
||||
in.LimitRestOff = *req.LimitRestOff
|
||||
}
|
||||
if req.ImageFilesOff != nil {
|
||||
in.ImageFilesOff = *req.ImageFilesOff
|
||||
}
|
||||
add := provider.Add
|
||||
if req.CopyOf != "" {
|
||||
add = func(p provider.Provider) (string, error) { return provider.AddCopy(p, req.CopyOf) }
|
||||
@@ -1878,6 +1890,13 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
} else if old != nil {
|
||||
in.LimitRestOff = old.LimitRestOff
|
||||
}
|
||||
// DeepSeek's images sent inline, set here or with `magpie
|
||||
// provider set <id> image-files=off` (#5407)
|
||||
if req.ImageFilesOff != nil {
|
||||
in.ImageFilesOff = *req.ImageFilesOff
|
||||
} else if old != nil {
|
||||
in.ImageFilesOff = old.ImageFilesOff
|
||||
}
|
||||
if keepCC && old != nil {
|
||||
in.MaxConcurrency = old.MaxConcurrency
|
||||
}
|
||||
@@ -1920,11 +1939,6 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
if !in.CodexAsSent && old != nil {
|
||||
in.CodexAsSent = old.CodexAsSent
|
||||
}
|
||||
// and DeepSeek's images sent inline, set with `magpie
|
||||
// provider set <id> image-files=off` (#5407)
|
||||
if !in.ImageFilesOff && old != nil {
|
||||
in.ImageFilesOff = old.ImageFilesOff
|
||||
}
|
||||
// and Antigravity's prompt as written, set with `magpie
|
||||
// provider set antigravity prompt=as-written`
|
||||
if !in.PromptAsWritten && old != nil {
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// matrix0487 (Discord #feedback, 11-05): image-files (#5407), DeepSeek's
|
||||
// own API sent an agent's images once by file id, was only
|
||||
// `magpie provider set <id> image-files=off`. Now the editor of a
|
||||
// provider on api.deepseek.com, the built-in DeepSeek or a custom one
|
||||
// there (the server's takesImageFiles), has under Advanced "Upload images
|
||||
// once and send them by file id", ticked by default. Unticked and saved,
|
||||
// it posts imageFilesOff: true; one set off from the CLI opens unticked
|
||||
// with Advanced open, and ticked again posts false. Any other provider
|
||||
// has no such row and its Save sends none. A checkbox, never a native
|
||||
// select. Every language, wide and narrow.
|
||||
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 base = {
|
||||
icon: "generic", chat: "", responses: "", anthropic: "", catalog: "",
|
||||
models: [{ id: "deepseek-flash", name: "deepseek-flash", on: true }], agents: [], fallback: [], headers: {},
|
||||
key: { set: true, masked: "sk-…ds1" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", searches: false,
|
||||
};
|
||||
const ds = {
|
||||
...base, id: "deepseek", name: "DeepSeek", preset: "deepseek", icon: "deepseek-color", catalog: "deepseek",
|
||||
chat: "https://api.deepseek.com/v1", responses: "https://api.deepseek.com/v1", anthropic: "https://api.deepseek.com/anthropic",
|
||||
takesImageFiles: true, imageFilesOff: false,
|
||||
};
|
||||
const cliOff = { ...base, id: "mine", name: "Own Endpoint", anthropic: "https://api.deepseek.com/anthropic", takesImageFiles: true, imageFilesOff: true };
|
||||
const relay = { ...base, id: "relay", name: "Other Relay", chat: "https://relay.example.com/deepseek/v1", imageFilesOff: false };
|
||||
|
||||
function serve(lang, posts) {
|
||||
const providers = {
|
||||
providers: [ds, cliOff, relay],
|
||||
presets: [{ id: "deepseek", name: "DeepSeek", kind: "vendor", icon: "deepseek-color", chat: "https://api.deepseek.com/v1", added: true }],
|
||||
excluded: [], gateway: { running: true, window: true },
|
||||
};
|
||||
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
||||
return async (route) => {
|
||||
const url = new URL(route.request().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};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json(state);
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname.startsWith("/api/provider/") && route.request().method() === "POST") {
|
||||
posts.push({ action: url.pathname.slice("/api/provider/".length), body: route.request().postDataJSON() });
|
||||
return json(providers);
|
||||
}
|
||||
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)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
const strings = ["Images", "Upload images once and send them by file id", "Off: an agent's images are sent inline on every turn."];
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [1100, 420]) {
|
||||
const open = async (t, name) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
let page;
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR && page) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-${name.replace(/\s+/g, "-")}-image-files.png`), fullPage: true });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
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));
|
||||
const posts = [];
|
||||
await page.route("**/*", serve(lang, posts));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
const w = await page.evaluate(([lang, ks]) => Object.fromEntries(ks.map((k) => [k, (I18N[lang] || {})[k] || k])), [lang, [...strings, "Save"]]);
|
||||
await page.locator(".row.provider", { hasText: name }).click();
|
||||
await page.locator(".editor .bar").waitFor();
|
||||
return { page, errors, posts, w };
|
||||
};
|
||||
const adv = (page) => page.locator(".editor details.advanced");
|
||||
const unfold = async (page) => {
|
||||
await adv(page).waitFor({ state: "attached" });
|
||||
if (!(await adv(page).evaluate((d) => d.open))) await adv(page).locator(":scope > summary").click();
|
||||
};
|
||||
const row = (page) => page.locator(".editor label.tick.image-files");
|
||||
const box = (page) => row(page).locator("input[type=checkbox]");
|
||||
const save = async (page, posts, w) => {
|
||||
const n = posts.length;
|
||||
await page.locator(".editor .bar").getByRole("button", { name: w.Save, exact: true }).click();
|
||||
for (let i = 0; i < 50 && posts.length === n; i++) await page.waitForTimeout(50);
|
||||
return posts.at(-1);
|
||||
};
|
||||
|
||||
test(`${engine} ${lang} ${width}: the built-in DeepSeek uploads images by default, and is saved not to`, async (t) => {
|
||||
const { page, errors, posts, w } = await open(t, "DeepSeek");
|
||||
if (lang !== "en") {
|
||||
const missing = await page.evaluate(([lang, ks]) => ks.filter((k) => !(I18N[lang] || {})[k]), [lang, strings]);
|
||||
assert.deepEqual(missing, [], `every string has its ${lang}`);
|
||||
}
|
||||
assert.equal(await adv(page).evaluate((d) => d.open), false, "Advanced stays folded while it is as by default");
|
||||
await unfold(page);
|
||||
assert.equal(await row(page).isVisible(), true);
|
||||
assert.equal(await row(page).innerText().then((s) => s.trim()), w["Upload images once and send them by file id"]);
|
||||
assert.equal(await box(page).isChecked(), true, "ticked by default");
|
||||
assert.equal(await page.locator(".editor select").count(), 0, "no native select");
|
||||
await box(page).scrollIntoViewIfNeeded();
|
||||
const r = await row(page).boundingBox();
|
||||
assert.ok(r.width > 60 && r.x >= 0 && r.x + r.width <= width, `the row fits: ${JSON.stringify(r)}`);
|
||||
assert.ok(await page.locator(".editor", { hasText: w[strings[2]] }).count() > 0, "the note is shown");
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), true, "no sideways scroll");
|
||||
await box(page).uncheck();
|
||||
const saved = await save(page, posts, w);
|
||||
assert.equal(saved.action, "save");
|
||||
assert.equal(saved.body.id, "deepseek");
|
||||
assert.equal(saved.body.imageFilesOff, true);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang} ${width}: one set off from the CLI opens unticked with Advanced open, and ticked is saved on`, async (t) => {
|
||||
const { page, errors, posts, w } = await open(t, "Own Endpoint");
|
||||
assert.equal(await adv(page).evaluate((d) => d.open), true, "Advanced opens with it set");
|
||||
assert.equal(await box(page).isChecked(), false, "the CLI's off shows as off");
|
||||
await box(page).scrollIntoViewIfNeeded();
|
||||
await box(page).check();
|
||||
const saved = await save(page, posts, w);
|
||||
assert.equal(saved.body.id, "mine");
|
||||
assert.equal(saved.body.imageFilesOff, false);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang} ${width}: a provider elsewhere has no row, and its Save sends none`, async (t) => {
|
||||
const { page, errors, posts, w } = await open(t, "Other Relay");
|
||||
await unfold(page);
|
||||
assert.equal(await row(page).count(), 0);
|
||||
assert.equal(await page.locator(".editor", { hasText: w["Upload images once and send them by file id"] }).count(), 0);
|
||||
const saved = await save(page, posts, w);
|
||||
assert.equal(saved.action, "save");
|
||||
assert.equal("imageFilesOff" in saved.body, false, `its Save sends none: ${JSON.stringify(saved.body)}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user