NanoGPT: Add reasoning effort control Closes #4999
| @@ -2110,7 +2110,7 @@ | |||
| 2110 | </strong> | 2110 | </strong> |
| 2111 | </div> | 2111 | </div> |
| 2112 | </div> | 2112 | </div> |
| 2113 | <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"> | 2113 | <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"> |
| 2114 | <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."> | 2114 | <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."> |
| 2115 | <label for="openai_reasoning_effort"> | 2115 | <label for="openai_reasoning_effort"> |
| 2116 | <span data-i18n="Reasoning Effort">Reasoning Effort</span> | 2116 | <span data-i18n="Reasoning Effort">Reasoning Effort</span> |
| @@ -482,6 +482,14 @@ export const OPENAI_REASONING_EFFORT_MAP = { | |||
| 482 | min: 'minimal', | 482 | min: 'minimal', |
| 483 | }; | 483 | }; |
| 484 | 484 | ||
| 485 | export const NANOGPT_REASONING_EFFORT_MAP = { | ||
| 486 | min: 'none', | ||
| 487 | low: 'minimal', | ||
| 488 | medium: 'low', | ||
| 489 | high: 'medium', | ||
| 490 | max: 'high', | ||
| 491 | }; | ||
| 492 | |||
| 485 | export const LOG_LEVELS = { | 493 | export const LOG_LEVELS = { |
| 486 | DEBUG: 0, | 494 | DEBUG: 0, |
| 487 | INFO: 1, | 495 | INFO: 1, |
| @@ -9,6 +9,7 @@ import { | |||
| 9 | AZURE_OPENAI_KEYS, | 9 | AZURE_OPENAI_KEYS, |
| 10 | CHAT_COMPLETION_SOURCES, | 10 | CHAT_COMPLETION_SOURCES, |
| 11 | GEMINI_SAFETY, | 11 | GEMINI_SAFETY, |
| 12 | NANOGPT_REASONING_EFFORT_MAP, | ||
| 12 | OPENAI_REASONING_EFFORT_MAP, | 13 | OPENAI_REASONING_EFFORT_MAP, |
| 13 | OPENAI_REASONING_EFFORT_MODELS, | 14 | OPENAI_REASONING_EFFORT_MODELS, |
| 14 | OPENAI_VERBOSITY_MODELS, | 15 | OPENAI_VERBOSITY_MODELS, |
| @@ -2228,6 +2229,10 @@ router.post('/generate', async function (request, response) { | |||
| 2228 | if (request.body.repetition_penalty !== undefined) { | 2229 | if (request.body.repetition_penalty !== undefined) { |
| 2229 | bodyParams['repetition_penalty'] = request.body.repetition_penalty; | 2230 | bodyParams['repetition_penalty'] = request.body.repetition_penalty; |
| 2230 | } | 2231 | } |
| 2232 | if (request.body.reasoning_effort) { | ||
| 2233 | const effort = NANOGPT_REASONING_EFFORT_MAP[request.body.reasoning_effort]; | ||
| 2234 | bodyParams['reasoning'] = { effort: effort }; | ||
| 2235 | } | ||
| 2231 | 2236 | ||
| 2232 | const isClaude = /^claude-/.test(request.body.model); | 2237 | const isClaude = /^claude-/.test(request.body.model); |
| 2233 | if (enableSystemPromptCache && isClaude) { | 2238 | if (enableSystemPromptCache && isClaude) { |