mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #3424 from SillyTavern/oai-reasoning-effort
OpenAI "Reasoning Effort" for o1/o3-mini + oai models restructured
This commit is contained in:
@@ -1957,14 +1957,16 @@
|
||||
<span data-i18n="image_inlining_hint_3">menu to attach an image file to the chat.</span>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
|
||||
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
|
||||
Inline Image Quality
|
||||
</label>
|
||||
<select id="openai_inline_image_quality">
|
||||
<option data-i18n="openai_inline_image_quality_auto" value="auto">Auto</option>
|
||||
<option data-i18n="openai_inline_image_quality_low" value="low">Low</option>
|
||||
<option data-i18n="openai_inline_image_quality_high" value="high">High</option>
|
||||
</select>
|
||||
<div class="flex-container oneline-dropdown">
|
||||
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
|
||||
Inline Image Quality
|
||||
</label>
|
||||
<select id="openai_inline_image_quality">
|
||||
<option data-i18n="openai_inline_image_quality_auto" value="auto">Auto</option>
|
||||
<option data-i18n="openai_inline_image_quality_low" value="low">Low</option>
|
||||
<option data-i18n="openai_inline_image_quality_high" value="high">High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="makersuite">
|
||||
@@ -1995,6 +1997,18 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
|
||||
<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.">
|
||||
<label for="openai_reasoning_effort" data-i18n="Reasoning Effort">
|
||||
Reasoning Effort
|
||||
</label>
|
||||
<select id="openai_reasoning_effort">
|
||||
<option data-i18n="openai_reasoning_effort_low" value="low">Low</option>
|
||||
<option data-i18n="openai_reasoning_effort_medium" value="medium">Medium</option>
|
||||
<option data-i18n="openai_reasoning_effort_high" value="high">High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="claude">
|
||||
<div class="wide100p">
|
||||
<div class="flex-container alignItemsCenter">
|
||||
@@ -2809,27 +2823,6 @@
|
||||
<div>
|
||||
<h4 data-i18n="OpenAI Model">OpenAI Model</h4>
|
||||
<select id="model_openai_select">
|
||||
<optgroup label="GPT-3.5 Turbo">
|
||||
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
|
||||
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
|
||||
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-0613">gpt-3.5-turbo-0613 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-0301">gpt-3.5-turbo-0301 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option>
|
||||
<option value="gpt-3.5-turbo-16k-0613">gpt-3.5-turbo-16k-0613 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-3.5 Turbo Instruct">
|
||||
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
|
||||
<option value="gpt-3.5-turbo-instruct-0914">gpt-3.5-turbo-instruct-0914</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4">
|
||||
<option value="gpt-4">gpt-4</option>
|
||||
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
|
||||
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
|
||||
<option value="gpt-4-32k">gpt-4-32k</option>
|
||||
<option value="gpt-4-32k-0613">gpt-4-32k-0613 (2023)</option>
|
||||
<option value="gpt-4-32k-0314">gpt-4-32k-0314 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4o">
|
||||
<option value="gpt-4o">gpt-4o</option>
|
||||
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
|
||||
@@ -2837,33 +2830,44 @@
|
||||
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
|
||||
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
|
||||
</optgroup>
|
||||
<optgroup label="gpt-4o-mini">
|
||||
<optgroup label="GPT-4o mini">
|
||||
<option value="gpt-4o-mini">gpt-4o-mini</option>
|
||||
<option value="gpt-4o-mini-2024-07-18">gpt-4o-mini-2024-07-18</option>
|
||||
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
|
||||
<option value="gpt-4o-2024-08-06">gpt-4o-2024-08-06</option>
|
||||
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
|
||||
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4 Turbo">
|
||||
<option value="gpt-4-turbo">gpt-4-turbo</option>
|
||||
<option value="gpt-4-turbo-2024-04-09">gpt-4-turbo-2024-04-09</option>
|
||||
<option value="gpt-4-turbo-preview">gpt-4-turbo-preview</option>
|
||||
<option value="gpt-4-vision-preview">gpt-4-vision-preview</option>
|
||||
<option value="gpt-4-0125-preview">gpt-4-0125-preview (2024)</option>
|
||||
<option value="gpt-4-1106-preview">gpt-4-1106-preview (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="o1">
|
||||
<option value="o1-preview">o1-preview</option>
|
||||
<optgroup label="o1 and o1-mini">
|
||||
<option value="o1">o1</option>
|
||||
<option value="o1-2024-12-17">o1-2024-12-17</option>
|
||||
<option value="o1-mini">o1-mini</option>
|
||||
<option value="o1-mini-2024-09-12">o1-mini-2024-09-12</option>
|
||||
<option value="o1-preview">o1-preview</option>
|
||||
<option value="o1-preview-2024-09-12">o1-preview-2024-09-12</option>
|
||||
</optgroup>
|
||||
<optgroup label="o3">
|
||||
<option value="o3-mini">o3-mini</option>
|
||||
<option value="o3-mini-2025-01-31">o3-mini-2025-01-31</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4 Turbo and GPT-4">
|
||||
<option value="gpt-4-turbo">gpt-4-turbo</option>
|
||||
<option value="gpt-4-turbo-2024-04-09">gpt-4-turbo-2024-04-09</option>
|
||||
<option value="gpt-4-turbo-preview">gpt-4-turbo-preview</option>
|
||||
<option value="gpt-4-0125-preview">gpt-4-0125-preview (2024)</option>
|
||||
<option value="gpt-4-1106-preview">gpt-4-1106-preview (2023)</option>
|
||||
<option value="gpt-4">gpt-4</option>
|
||||
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
|
||||
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-3.5 Turbo">
|
||||
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
|
||||
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
|
||||
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
|
||||
</optgroup>
|
||||
<optgroup label="Other">
|
||||
<option value="text-davinci-003">text-davinci-003</option>
|
||||
<option value="text-davinci-002">text-davinci-002</option>
|
||||
<option value="text-curie-001">text-curie-001</option>
|
||||
<option value="text-babbage-001">text-babbage-001</option>
|
||||
<option value="text-ada-001">text-ada-001</option>
|
||||
<option value="code-davinci-002">code-davinci-002</option>
|
||||
<option value="babbage-002">babbage-002</option>
|
||||
<option value="davinci-002">davinci-002</option>
|
||||
</optgroup>
|
||||
<optgroup id="openai_external_category" label="External">
|
||||
</optgroup>
|
||||
|
@@ -299,6 +299,7 @@ const default_settings = {
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@@ -378,6 +379,7 @@ const oai_settings = {
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@@ -1912,6 +1914,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
'char_name': name2,
|
||||
'group_names': getGroupNames(),
|
||||
'include_reasoning': Boolean(oai_settings.show_thoughts),
|
||||
'reasoning_effort': String(oai_settings.reasoning_effort),
|
||||
};
|
||||
|
||||
// Empty array will produce a validation error
|
||||
@@ -3122,6 +3125,7 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.inline_image_quality = settings.inline_image_quality ?? default_settings.inline_image_quality;
|
||||
oai_settings.bypass_status_check = settings.bypass_status_check ?? default_settings.bypass_status_check;
|
||||
oai_settings.show_thoughts = settings.show_thoughts ?? default_settings.show_thoughts;
|
||||
oai_settings.reasoning_effort = settings.reasoning_effort ?? default_settings.reasoning_effort;
|
||||
oai_settings.seed = settings.seed ?? default_settings.seed;
|
||||
oai_settings.n = settings.n ?? default_settings.n;
|
||||
|
||||
@@ -3251,6 +3255,9 @@ function loadOpenAISettings(data, settings) {
|
||||
$('#n_openai').val(oai_settings.n);
|
||||
$('#openai_show_thoughts').prop('checked', oai_settings.show_thoughts);
|
||||
|
||||
$('#openai_reasoning_effort').val(oai_settings.reasoning_effort);
|
||||
$(`#openai_reasoning_effort option[value="${oai_settings.reasoning_effort}"]`).prop('selected', true);
|
||||
|
||||
if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy;
|
||||
$('#openai_reverse_proxy').val(oai_settings.reverse_proxy);
|
||||
|
||||
@@ -3511,6 +3518,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
continue_postfix: settings.continue_postfix,
|
||||
function_calling: settings.function_calling,
|
||||
show_thoughts: settings.show_thoughts,
|
||||
reasoning_effort: settings.reasoning_effort,
|
||||
seed: settings.seed,
|
||||
n: settings.n,
|
||||
};
|
||||
@@ -3969,6 +3977,7 @@ function onSettingsPresetChange() {
|
||||
continue_postfix: ['#continue_postfix', 'continue_postfix', false],
|
||||
function_calling: ['#openai_function_calling', 'function_calling', true],
|
||||
show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true],
|
||||
reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false],
|
||||
seed: ['#seed_openai', 'seed', false],
|
||||
n: ['#n_openai', 'n', false],
|
||||
};
|
||||
@@ -5510,6 +5519,11 @@ export function initOpenAI() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#openai_reasoning_effort').on('input', function () {
|
||||
oai_settings.reasoning_effort = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
if (!CSS.supports('field-sizing', 'content')) {
|
||||
$(document).on('input', '#openai_settings .autoSetHeight', function () {
|
||||
resetScrollHeight($(this));
|
||||
|
@@ -5914,3 +5914,15 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
.mes_text div[data-type="assistant_note"]:has(.assistant_note_export)>div:not(.assistant_note_export) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.oneline-dropdown label {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 5px;
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.oneline-dropdown select {
|
||||
min-width: fit-content;
|
||||
width: 40%;
|
||||
}
|
||||
|
@@ -1063,6 +1063,13 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
// A few of OpenAIs reasoning models support reasoning effort
|
||||
if ([CHAT_COMPLETION_SOURCES.CUSTOM, CHAT_COMPLETION_SOURCES.OPENAI].includes(request.body.chat_completion_source)) {
|
||||
if (['o1', 'o3-mini', 'o3-mini-2025-01-31'].includes(request.body.model)) {
|
||||
bodyParams['reasoning_effort'] = request.body.reasoning_effort;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apiKey && !request.body.reverse_proxy && request.body.chat_completion_source !== CHAT_COMPLETION_SOURCES.CUSTOM) {
|
||||
console.warn('OpenAI API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
|
Reference in New Issue
Block a user