Add reasoning effort control for CC OpenRouter Closes #3890

5241b22a7392dc7ff30c5646ff3d1be5cb8e52da

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +7 -2Ignore whitespace
public/index.html+2 -2
@@ -2048,11 +2048,11 @@
2048 </span>2048 </span>
2049 </div>2049 </div>
2050 </div>2050 </div>
2051 <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite">2051 <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite,openrouter">
2052 <div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models.&#10;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.">2052 <div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models.&#10;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.">
2053 <label for="openai_reasoning_effort">2053 <label for="openai_reasoning_effort">
2054 <span data-i18n="Reasoning Effort">Reasoning Effort</span>2054 <span data-i18n="Reasoning Effort">Reasoning Effort</span>
2055 <i data-source="openai,custom,xai" class="opacity50p fa-solid fa-circle-info" title="OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level."></i>2055 <i data-source="openai,custom,xai,openrouter" class="opacity50p fa-solid fa-circle-info" title="OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level."></i>
2056 <i data-source="claude,makersuite" class="opacity50p fa-solid fa-circle-info" title="Allocates a portion of the response length for thinking (low: 10%, medium: 25%, high: 50%). Other options are model-dependent."></i>2056 <i data-source="claude,makersuite" class="opacity50p fa-solid fa-circle-info" title="Allocates a portion of the response length for thinking (low: 10%, medium: 25%, high: 50%). Other options are model-dependent."></i>
2057 </label>2057 </label>
2058 <select id="openai_reasoning_effort">2058 <select id="openai_reasoning_effort">
public/scripts/openai.js+1 -0
@@ -1952,6 +1952,7 @@ function getReasoningEffort() {
1952 chat_completion_sources.OPENAI,1952 chat_completion_sources.OPENAI,
1953 chat_completion_sources.CUSTOM,1953 chat_completion_sources.CUSTOM,
1954 chat_completion_sources.XAI,1954 chat_completion_sources.XAI,
1955 chat_completion_sources.OPENROUTER,
1955 ];1956 ];
19561957
1957 if (!reasoningEffortSources.includes(oai_settings.chat_completion_source)) {1958 if (!reasoningEffortSources.includes(oai_settings.chat_completion_source)) {
src/endpoints/backends/chat-completions.js+4 -0
@@ -1225,6 +1225,10 @@ router.post('/generate', function (request, response) {
1225 bodyParams['route'] = 'fallback';1225 bodyParams['route'] = 'fallback';
1226 }1226 }
12271227
1228 if (request.body.reasoning_effort) {
1229 bodyParams['reasoning'] = { effort: request.body.reasoning_effort };
1230 }
1231
1228 let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number');1232 let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number');
1229 if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && request.body.model?.startsWith('anthropic/claude-3')) {1233 if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && request.body.model?.startsWith('anthropic/claude-3')) {
1230 cachingAtDepthForOpenRouterClaude(request.body.messages, cachingAtDepth);1234 cachingAtDepthForOpenRouterClaude(request.body.messages, cachingAtDepth);