feat(providers): add a dedicated DeepSeek provider module - #3035
Merged
Merged
Conversation
DeepSeek's V4.1 line (deepseek-flash) replaced the retired deepseek-v4-flash default and changed the wire contract, so all DeepSeek knowledge moves out of the shared OpenAI-compatible modules into two new files: - providers/deepseek-config.js owns the API contract: endpoints, the shipped and retired model ids, model capacities, the reasoning-effort mapping, and the thinking/planner/vision request extras for both wire formats. It is dependency-free so provider-compatibility.js can import it without a cycle. - providers/deepseek.js adds DeepSeekProvider extends OpenAICompatibleProvider, which owns vision capability, stream usage, and reasoning_content replay. openai.js and provider-compatibility.js no longer contain any DeepSeek literals: the shared provider gains a _modelNameSniffedVision() hook and the compatibility presets delegate to the contract module. A source-guard test keeps that boundary in place. Behaviour changes: - the default model is deepseek-flash; deepseek-v4-pro and the V3-era ids stay on a conservative 64K context / 8K output / text-only profile - the V4.1-Flash family, including the retired deepseek-v4-flash aliases, is multimodal with a 1M context window and a 384K output ceiling - Chat Completions stays the default wire format; the Responses API is an opt-in apiFormat setting that maps thinking to reasoning.effort - pricing moves to the off-peak list price plus a cache-hit rate, and usage.prompt_cache_hit_tokens is priced at the cache-read rate - untouched default configs migrate to the new model id and prices, while saved cards are never rewritten Tests: test/run.js (2308 passed) and test/provider-model-limits.mjs.
|
@xianhongtao is attempting to deploy a commit to the esokullu's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a dedicated DeepSeek provider and refreshes WebBrain against the current
DeepSeek API (V4.1 line). The vendor-specific logic is moved out of the shared
OpenAI-compatible modules into two new files, so
openai.jsandprovider-compatibility.jsstay protocol-generic.Docs of record: https://api-docs.deepseek.com/zh-cn/ (模型 & 价格 / 思考模式 /
图像理解 / 上下文硬盘缓存 / 使用 Responses API / 限速与隔离).
Why
deepseek-v4-flash; the currentid is
deepseek-flash(DeepSeek-V4.1-Flash).deepseek-flashwas not recognised by the capacity tables: it fell through tothe 8K output ceiling and the generic 128K context window instead of 384K / 1M.
deepseek-v4-flash-vision-exp, although the wholeV4.1-Flash family is multimodal and
deepseek-v4-prois text-only.DeepSeek's top-level
prompt_cache_hit_tokenscounter was ignored, so cachedinput was billed at the full input rate.
Architecture
Two new modules per build (
src/chrome+src/firefox):providers/deepseek-config.js— the API contract: endpoints, shipped andretired model ids, model capacities, the reasoning-effort mapping, and the
thinking / planner / vision request extras for both wire formats. It has no
internal imports, so
provider-compatibility.jscan delegate to it withoutcreating an import cycle.
providers/deepseek.js—DeepSeekProvider extends OpenAICompatibleProvider,owning vision capability,
stream_options.include_usage, and cross-turnreasoning_contentreplay (DeepSeek returns 400 when a tool-carryingfollow-up omits it).
ProviderManager#_createProvider()dispatches thedeepseekcard — or any cardpointed at
api.deepseek.com, or one that explicitly selects thedeepseekcompatibility preset — to the dedicated class. Router-hosted DeepSeek models
(for example
deepseek/deepseek-v4on OpenRouter) stay on the generic provider.Cleanup in the shared modules:
openai.jsloses its DeepSeek import, thedeepseekentry in_shouldRequestStreamUsage(), the DeepSeek branch of_supportsReasoningContentReplay(), and the DeepSeek id in the vision regex; itgains a
_modelNameSniffedVision(model)hook that vendor subclasses override.provider-compatibility.jslosesmappedDeepSeekReasoningEffort()and thehard-coded DeepSeek host/endpoint knowledge and now delegates. A source-guard
test fails the build if DeepSeek literals reappear in either shared module.
Behaviour changes
deepseek-flashdeepseek-v4-flash,deepseek-v4-flash-vision-exp(retired aliases, same model)deepseek-v4-pro(retired),deepseek-chat,deepseek-reasonerUnknown DeepSeek ids deliberately fall into the conservative profile rather than
inheriting capacities we cannot verify.
thinkingobject plusreasoning_effort; disablingthinking omits
reasoning_effortentirely. The shared UI ladder mapsminimal→lowandmedium/xhigh→high, matching DeepSeek's table.apiFormatselector in the Advanced panel opts into DeepSeek's Responses API, which then
uses
reasoning.effort(includingnoneto disable thinking) and fulltext.formatJSON Schema for the planner.1M, peak 2 / 0.04 / 8) converted at 1 USD = 7.1 CNY, with a new
cacheReadCostPerMillionUsd.usage.prompt_cache_hit_tokensis now countedas cached input and priced at the cache-read rate, and the field is preserved
in usage traces.
id, old base path and old prices, no API key, never saved) migrate to
deepseek-flashand the new prices; saved or customised cards are neverrewritten.
deepseek-flashis advertised as multimodal, so screenshots flowthrough the existing
image_urlpath.Also updated
ui/settings.js: model suggestions drop the retired ids; the newapiFormatselect is rendered only for the DeepSeek card, behind the Advanced panel.
st.provider.field.api_format) added to all 23 localefiles in both builds.
docs/providers-and-models.md,docs/zh-CN/…,docs/fr/…— defaultmodel row, vision-detection table, a new DeepSeek section, and the contributor
guidance now points at
_modelNameSniffedVision()/ vendor subclasses.Verification
node test/run.js→ 2308 passed, 0 failed (includes new assertions formodel capacities, the Responses wire shape, prompt-cache pricing, dispatch,
migration, and the module-boundary guard).
npm run test:provider-limits→ passed./chat/completionswiththinking+reasoning_effort;reasoningEffort: offclearsreasoning_effort;apiFormat: responsessends onlyreasoning.effort;deepseek-v4-prono longer advertises vision.Notes / follow-ups
user_id(DeepSeek's KVCache and scheduling isolation parameter) is notimplemented; low concurrency limits (2500 for Flash) are expected to be fine
for browser-agent traffic.
https://api.deepseek.com/anthropic) works byoverriding the built-in
anthropiccard's base URL; documented, not a newprovider card.