feat: add DeepSeek V4 model support with thinking mode and reasoning effort (#5522)
* fix: align DeepSeek provider with V4 API * Fix DeepSeek beta routing for standard chat completions * feat: add DeepSeek V4 model support with thinking mode and reasoning effort * Address DeepSeek review feedback * Set DeepSeek default model to v4 flash * fix: clean-up deprecated models, add migration * fix: move reasoning effort mapping to resolveReasoningEffort * fix: lint empty line * fix: remove duplicate code * fix: add coder model to migration logic --------- Co-authored-by: dclef <drclef233@gmail.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
+3
-5
@@ -2130,12 +2130,12 @@
|
||||
<span data-i18n="Allows the model to return its thinking process.">
|
||||
Allows the model to return its thinking process.
|
||||
</span>
|
||||
<strong data-i18n="This setting affects visibility only." data-source-mode="except" data-source="zai,moonshot,openrouter">
|
||||
<strong data-i18n="This setting affects visibility only." data-source-mode="except" data-source="zai,moonshot,openrouter,deepseek">
|
||||
This setting affects visibility only.
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite,vertexai,aimlapi,openrouter,pollinations,perplexity,cometapi,electronhub,azure_openai,chutes,nanogpt">
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite,vertexai,aimlapi,openrouter,pollinations,perplexity,cometapi,electronhub,azure_openai,chutes,nanogpt,deepseek">
|
||||
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response." data-i18n="[title]Constrains effort on reasoning for reasoning models.">
|
||||
<label for="openai_reasoning_effort">
|
||||
<span data-i18n="Reasoning Effort">Reasoning Effort</span>
|
||||
@@ -3735,9 +3735,7 @@
|
||||
<div>
|
||||
<h4 data-i18n="DeepSeek Model">DeepSeek Model</h4>
|
||||
<select id="model_deepseek_select">
|
||||
<option value="deepseek-chat">deepseek-chat</option>
|
||||
<option value="deepseek-coder">deepseek-coder</option>
|
||||
<option value="deepseek-reasoner">deepseek-reasoner</option>
|
||||
<option value="" data-i18n="-- Connect to the API --">-- Connect to the API --</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+16
-11
@@ -446,7 +446,7 @@ const default_settings = {
|
||||
electronhub_sort_models: 'alphabetically',
|
||||
electronhub_group_models: false,
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
deepseek_model: 'deepseek-chat',
|
||||
deepseek_model: 'deepseek-v4-flash',
|
||||
aimlapi_model: 'chatgpt-4o-latest',
|
||||
xai_model: 'grok-3-beta',
|
||||
pollinations_model: 'openai',
|
||||
@@ -2501,6 +2501,7 @@ function getReasoningEffort(settings = null, model = null) {
|
||||
chat_completion_sources.COMETAPI,
|
||||
chat_completion_sources.ELECTRONHUB,
|
||||
chat_completion_sources.CHUTES,
|
||||
chat_completion_sources.DEEPSEEK,
|
||||
];
|
||||
|
||||
if (!reasoningEffortSources.includes(settings.chat_completion_source)) {
|
||||
@@ -2508,6 +2509,17 @@ function getReasoningEffort(settings = null, model = null) {
|
||||
}
|
||||
|
||||
function resolveReasoningEffort() {
|
||||
if (settings.chat_completion_source === chat_completion_sources.DEEPSEEK) {
|
||||
switch (settings.reasoning_effort) {
|
||||
case reasoning_effort_types.auto:
|
||||
return undefined;
|
||||
case reasoning_effort_types.max:
|
||||
return reasoning_effort_types.max;
|
||||
default:
|
||||
return reasoning_effort_types.high;
|
||||
}
|
||||
}
|
||||
|
||||
switch (settings.reasoning_effort) {
|
||||
case reasoning_effort_types.auto:
|
||||
return undefined;
|
||||
@@ -4110,6 +4122,7 @@ function migrateChatCompletionSettings(settings) {
|
||||
{ oldKey: 'claude_use_sysprompt', oldValue: true, newKey: 'use_sysprompt', newValue: true },
|
||||
{ oldKey: 'use_makersuite_sysprompt', oldValue: true, newKey: 'use_sysprompt', newValue: true },
|
||||
{ oldKey: 'mistralai_model', oldValue: /^(mistral-medium|mistral-small)$/, newKey: 'mistralai_model', newValue: (settings.mistralai_model + '-latest') },
|
||||
{ oldKey: 'deepseek_model', oldValue: /^deepseek-(chat|reasoner|coder)$/, newKey: 'deepseek_model', newValue: 'deepseek-v4-flash' },
|
||||
];
|
||||
|
||||
for (const migration of migrateMap) {
|
||||
@@ -5622,16 +5635,8 @@ async function onModelChange() {
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.DEEPSEEK) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else if (['deepseek-reasoner', 'deepseek-chat'].includes(oai_settings.deepseek_model)) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.deepseek_model == 'deepseek-coder') {
|
||||
$('#openai_max_context').attr('max', max_16k);
|
||||
} else {
|
||||
$('#openai_max_context').attr('max', max_64k);
|
||||
}
|
||||
|
||||
const maxContext = oai_settings.max_context_unlocked ? unlocked_max : max_1mil;
|
||||
$('#openai_max_context').attr('max', maxContext);
|
||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
|
||||
@@ -1074,9 +1074,10 @@ async function sendDeepSeekRequest(request, response) {
|
||||
}
|
||||
|
||||
const processedMessages = addAssistantPrefix(postProcessPrompt(request.body.messages, PROMPT_PROCESSING_TYPE.SEMI_TOOLS, getPromptNames(request)), bodyParams.tools, 'prefix');
|
||||
addReasoningContentToToolCalls(processedMessages);
|
||||
|
||||
if (/-reasoner/.test(request.body.model)) {
|
||||
addReasoningContentToToolCalls(processedMessages);
|
||||
if (request.body.include_reasoning && request.body.reasoning_effort) {
|
||||
bodyParams['reasoning_effort'] = request.body.reasoning_effort;
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
@@ -1090,6 +1091,7 @@ async function sendDeepSeekRequest(request, response) {
|
||||
'top_p': request.body.top_p,
|
||||
'stop': request.body.stop,
|
||||
'seed': request.body.seed,
|
||||
'thinking': { type: request.body.include_reasoning ? 'enabled' : 'disabled' },
|
||||
...bodyParams,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user