Add reasoning_effort for OpenAI models
| @@ -1995,6 +1995,18 @@ | ||
| 1995 | 1995 | </span> |
| 1996 | 1996 | </div> |
| 1997 | 1997 | </div> |
| 1998 | + <div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai"> | |
| 1999 | + <div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."> | |
| 2000 | + <label for="openai_reasoning_effort" data-i18n="Reasoning Effort"> | |
| 2001 | + Reasoning Effort | |
| 2002 | + </label> | |
| 2003 | + <select id="openai_reasoning_effort"> | |
| 2004 | + <option data-i18n="openai_reasoning_effort_low" value="low">Low</option> | |
| 2005 | + <option data-i18n="openai_reasoning_effort_medium" value="medium">Medium</option> | |
| 2006 | + <option data-i18n="openai_reasoning_effort_high" value="high">High</option> | |
| 2007 | + </select> | |
| 2008 | + </div> | |
| 2009 | + </div> | |
| 1998 | 2010 | <div class="range-block" data-source="claude"> |
| 1999 | 2011 | <div class="wide100p"> |
| 2000 | 2012 | <div class="flex-container alignItemsCenter"> |
| @@ -299,6 +299,7 @@ const default_settings = { | ||
| 299 | 299 | continue_postfix: continue_postfix_types.SPACE, |
| 300 | 300 | custom_prompt_post_processing: custom_prompt_post_processing_types.NONE, |
| 301 | 301 | show_thoughts: true, |
| 302 | + reasoning_effort: 'medium', | |
| 302 | 303 | seed: -1, |
| 303 | 304 | n: 1, |
| 304 | 305 | }; |
| @@ -378,6 +379,7 @@ const oai_settings = { | ||
| 378 | 379 | continue_postfix: continue_postfix_types.SPACE, |
| 379 | 380 | custom_prompt_post_processing: custom_prompt_post_processing_types.NONE, |
| 380 | 381 | show_thoughts: true, |
| 382 | + reasoning_effort: 'medium', | |
| 381 | 383 | seed: -1, |
| 382 | 384 | n: 1, |
| 383 | 385 | }; |
| @@ -1912,6 +1914,7 @@ async function sendOpenAIRequest(type, messages, signal) { | ||
| 1912 | 1914 | 'char_name': name2, |
| 1913 | 1915 | 'group_names': getGroupNames(), |
| 1914 | 1916 | 'include_reasoning': Boolean(oai_settings.show_thoughts), |
| 1917 | + 'reasoning_effort': String(oai_settings.reasoning_effort), | |
| 1915 | 1918 | }; |
| 1916 | 1919 | |
| 1917 | 1920 | // Empty array will produce a validation error |
| @@ -3122,6 +3125,7 @@ function loadOpenAISettings(data, settings) { | ||
| 3122 | 3125 | oai_settings.inline_image_quality = settings.inline_image_quality ?? default_settings.inline_image_quality; |
| 3123 | 3126 | oai_settings.bypass_status_check = settings.bypass_status_check ?? default_settings.bypass_status_check; |
| 3124 | 3127 | oai_settings.show_thoughts = settings.show_thoughts ?? default_settings.show_thoughts; |
| 3128 | + oai_settings.reasoning_effort = settings.reasoning_effort ?? default_settings.reasoning_effort; | |
| 3125 | 3129 | oai_settings.seed = settings.seed ?? default_settings.seed; |
| 3126 | 3130 | oai_settings.n = settings.n ?? default_settings.n; |
| 3127 | 3131 | |
| @@ -3251,6 +3255,9 @@ function loadOpenAISettings(data, settings) { | ||
| 3251 | 3255 | $('#n_openai').val(oai_settings.n); |
| 3252 | 3256 | $('#openai_show_thoughts').prop('checked', oai_settings.show_thoughts); |
| 3253 | 3257 | |
| 3258 | + $('#openai_reasoning_effort').val(oai_settings.reasoning_effort); | |
| 3259 | + $(`#openai_reasoning_effort option[value="${oai_settings.reasoning_effort}"]`).prop('selected', true); | |
| 3260 | + | |
| 3254 | 3261 | if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy; |
| 3255 | 3262 | $('#openai_reverse_proxy').val(oai_settings.reverse_proxy); |
| 3256 | 3263 | |
| @@ -3969,6 +3976,7 @@ function onSettingsPresetChange() { | ||
| 3969 | 3976 | continue_postfix: ['#continue_postfix', 'continue_postfix', false], |
| 3970 | 3977 | function_calling: ['#openai_function_calling', 'function_calling', true], |
| 3971 | 3978 | show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true], |
| 3979 | + reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false], | |
| 3972 | 3980 | seed: ['#seed_openai', 'seed', false], |
| 3973 | 3981 | n: ['#n_openai', 'n', false], |
| 3974 | 3982 | }; |
| @@ -5510,6 +5518,11 @@ export function initOpenAI() { | ||
| 5510 | 5518 | saveSettingsDebounced(); |
| 5511 | 5519 | }); |
| 5512 | 5520 | |
| 5521 | + $('#openai_reasoning_effort').on('input', function () { | |
| 5522 | + oai_settings.reasoning_effort = String($(this).val()); | |
| 5523 | + saveSettingsDebounced(); | |
| 5524 | + }); | |
| 5525 | + | |
| 5513 | 5526 | if (!CSS.supports('field-sizing', 'content')) { |
| 5514 | 5527 | $(document).on('input', '#openai_settings .autoSetHeight', function () { |
| 5515 | 5528 | resetScrollHeight($(this)); |
| @@ -5914,3 +5914,15 @@ body:not(.movingUI) .drawer-content.maximized { | ||
| 5914 | 5914 | .mes_text div[data-type="assistant_note"]:has(.assistant_note_export)>div:not(.assistant_note_export) { |
| 5915 | 5915 | flex: 1; |
| 5916 | 5916 | } |
| 5917 | + | |
| 5918 | +.oneline-dropdown label { | |
| 5919 | + margin-top: 3px; | |
| 5920 | + margin-bottom: 5px; | |
| 5921 | + flex-grow: 1; | |
| 5922 | + text-align: left; | |
| 5923 | +} | |
| 5924 | + | |
| 5925 | +.oneline-dropdown select { | |
| 5926 | + min-width: fit-content; | |
| 5927 | + width: 40%; | |
| 5928 | +} | |