mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into patch-7
This commit is contained in:
@ -224,6 +224,88 @@ const sensitiveFields = [
|
||||
'custom_include_headers',
|
||||
];
|
||||
|
||||
/**
|
||||
* preset_name -> [selector, setting_name, is_checkbox]
|
||||
* @type {Record<string, [string, string, boolean]>}
|
||||
*/
|
||||
export const settingsToUpdate = {
|
||||
chat_completion_source: ['#chat_completion_source', 'chat_completion_source', false],
|
||||
temperature: ['#temp_openai', 'temp_openai', false],
|
||||
frequency_penalty: ['#freq_pen_openai', 'freq_pen_openai', false],
|
||||
presence_penalty: ['#pres_pen_openai', 'pres_pen_openai', false],
|
||||
top_p: ['#top_p_openai', 'top_p_openai', false],
|
||||
top_k: ['#top_k_openai', 'top_k_openai', false],
|
||||
top_a: ['#top_a_openai', 'top_a_openai', false],
|
||||
min_p: ['#min_p_openai', 'min_p_openai', false],
|
||||
repetition_penalty: ['#repetition_penalty_openai', 'repetition_penalty_openai', false],
|
||||
max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true],
|
||||
openai_model: ['#model_openai_select', 'openai_model', false],
|
||||
claude_model: ['#model_claude_select', 'claude_model', false],
|
||||
windowai_model: ['#model_windowai_select', 'windowai_model', false],
|
||||
openrouter_model: ['#model_openrouter_select', 'openrouter_model', false],
|
||||
openrouter_use_fallback: ['#openrouter_use_fallback', 'openrouter_use_fallback', true],
|
||||
openrouter_group_models: ['#openrouter_group_models', 'openrouter_group_models', false],
|
||||
openrouter_sort_models: ['#openrouter_sort_models', 'openrouter_sort_models', false],
|
||||
openrouter_providers: ['#openrouter_providers_chat', 'openrouter_providers', false],
|
||||
openrouter_allow_fallbacks: ['#openrouter_allow_fallbacks', 'openrouter_allow_fallbacks', true],
|
||||
openrouter_middleout: ['#openrouter_middleout', 'openrouter_middleout', false],
|
||||
ai21_model: ['#model_ai21_select', 'ai21_model', false],
|
||||
mistralai_model: ['#model_mistralai_select', 'mistralai_model', false],
|
||||
cohere_model: ['#model_cohere_select', 'cohere_model', false],
|
||||
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false],
|
||||
groq_model: ['#model_groq_select', 'groq_model', false],
|
||||
nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false],
|
||||
deepseek_model: ['#model_deepseek_select', 'deepseek_model', false],
|
||||
zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false],
|
||||
blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false],
|
||||
custom_model: ['#custom_model_id', 'custom_model', false],
|
||||
custom_url: ['#custom_api_url_text', 'custom_url', false],
|
||||
custom_include_body: ['#custom_include_body', 'custom_include_body', false],
|
||||
custom_exclude_body: ['#custom_exclude_body', 'custom_exclude_body', false],
|
||||
custom_include_headers: ['#custom_include_headers', 'custom_include_headers', false],
|
||||
custom_prompt_post_processing: ['#custom_prompt_post_processing', 'custom_prompt_post_processing', false],
|
||||
google_model: ['#model_google_select', 'google_model', false],
|
||||
openai_max_context: ['#openai_max_context', 'openai_max_context', false],
|
||||
openai_max_tokens: ['#openai_max_tokens', 'openai_max_tokens', false],
|
||||
wrap_in_quotes: ['#wrap_in_quotes', 'wrap_in_quotes', true],
|
||||
names_behavior: ['#names_behavior', 'names_behavior', false],
|
||||
send_if_empty: ['#send_if_empty_textarea', 'send_if_empty', false],
|
||||
impersonation_prompt: ['#impersonation_prompt_textarea', 'impersonation_prompt', false],
|
||||
new_chat_prompt: ['#newchat_prompt_textarea', 'new_chat_prompt', false],
|
||||
new_group_chat_prompt: ['#newgroupchat_prompt_textarea', 'new_group_chat_prompt', false],
|
||||
new_example_chat_prompt: ['#newexamplechat_prompt_textarea', 'new_example_chat_prompt', false],
|
||||
continue_nudge_prompt: ['#continue_nudge_prompt_textarea', 'continue_nudge_prompt', false],
|
||||
bias_preset_selected: ['#openai_logit_bias_preset', 'bias_preset_selected', false],
|
||||
reverse_proxy: ['#openai_reverse_proxy', 'reverse_proxy', false],
|
||||
wi_format: ['#wi_format_textarea', 'wi_format', false],
|
||||
scenario_format: ['#scenario_format_textarea', 'scenario_format', false],
|
||||
personality_format: ['#personality_format_textarea', 'personality_format', false],
|
||||
group_nudge_prompt: ['#group_nudge_prompt_textarea', 'group_nudge_prompt', false],
|
||||
stream_openai: ['#stream_toggle', 'stream_openai', true],
|
||||
prompts: ['', 'prompts', false],
|
||||
prompt_order: ['', 'prompt_order', false],
|
||||
api_url_scale: ['#api_url_scale', 'api_url_scale', false],
|
||||
show_external_models: ['#openai_show_external_models', 'show_external_models', true],
|
||||
proxy_password: ['#openai_proxy_password', 'proxy_password', false],
|
||||
assistant_prefill: ['#claude_assistant_prefill', 'assistant_prefill', false],
|
||||
assistant_impersonation: ['#claude_assistant_impersonation', 'assistant_impersonation', false],
|
||||
claude_use_sysprompt: ['#claude_use_sysprompt', 'claude_use_sysprompt', true],
|
||||
use_makersuite_sysprompt: ['#use_makersuite_sysprompt', 'use_makersuite_sysprompt', true],
|
||||
use_alt_scale: ['#use_alt_scale', 'use_alt_scale', true],
|
||||
squash_system_messages: ['#squash_system_messages', 'squash_system_messages', true],
|
||||
image_inlining: ['#openai_image_inlining', 'image_inlining', true],
|
||||
inline_image_quality: ['#openai_inline_image_quality', 'inline_image_quality', false],
|
||||
continue_prefill: ['#continue_prefill', 'continue_prefill', true],
|
||||
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],
|
||||
enable_web_search: ['#openai_enable_web_search', 'enable_web_search', true],
|
||||
seed: ['#seed_openai', 'seed', false],
|
||||
n: ['#n_openai', 'n', false],
|
||||
bypass_status_check: ['#openai_bypass_status_check', 'bypass_status_check', true],
|
||||
};
|
||||
|
||||
const default_settings = {
|
||||
preset_settings_openai: 'Default',
|
||||
temp_openai: 1.0,
|
||||
@ -255,7 +337,7 @@ const default_settings = {
|
||||
openai_model: 'gpt-4-turbo',
|
||||
claude_model: 'claude-3-5-sonnet-20240620',
|
||||
google_model: 'gemini-1.5-pro',
|
||||
ai21_model: 'jamba-1.5-large',
|
||||
ai21_model: 'jamba-1.6-large',
|
||||
mistralai_model: 'mistral-large-latest',
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'sonar-pro',
|
||||
@ -277,7 +359,6 @@ const default_settings = {
|
||||
openrouter_providers: [],
|
||||
openrouter_allow_fallbacks: true,
|
||||
openrouter_middleout: openrouter_middleout_types.ON,
|
||||
jailbreak_system: false,
|
||||
reverse_proxy: '',
|
||||
chat_completion_source: chat_completion_sources.OPENAI,
|
||||
max_context_unlocked: false,
|
||||
@ -300,6 +381,7 @@ const default_settings = {
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
enable_web_search: false,
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@ -335,7 +417,7 @@ const oai_settings = {
|
||||
openai_model: 'gpt-4-turbo',
|
||||
claude_model: 'claude-3-5-sonnet-20240620',
|
||||
google_model: 'gemini-1.5-pro',
|
||||
ai21_model: 'jamba-1.5-large',
|
||||
ai21_model: 'jamba-1.6-large',
|
||||
mistralai_model: 'mistral-large-latest',
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'sonar-pro',
|
||||
@ -357,7 +439,6 @@ const oai_settings = {
|
||||
openrouter_providers: [],
|
||||
openrouter_allow_fallbacks: true,
|
||||
openrouter_middleout: openrouter_middleout_types.ON,
|
||||
jailbreak_system: false,
|
||||
reverse_proxy: '',
|
||||
chat_completion_source: chat_completion_sources.OPENAI,
|
||||
max_context_unlocked: false,
|
||||
@ -380,6 +461,7 @@ const oai_settings = {
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
enable_web_search: false,
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@ -393,8 +475,8 @@ export let proxies = [
|
||||
];
|
||||
export let selected_proxy = proxies[0];
|
||||
|
||||
let openai_setting_names;
|
||||
let openai_settings;
|
||||
export let openai_setting_names;
|
||||
export let openai_settings;
|
||||
|
||||
/** @type {import('./PromptManager.js').PromptManager} */
|
||||
export let promptManager = null;
|
||||
@ -1497,8 +1579,14 @@ async function sendWindowAIRequest(messages, signal, stream) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getChatCompletionModel() {
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
/**
|
||||
* Gets the API model for the selected chat completion source.
|
||||
* @param {string} source If it's set, ignores active source
|
||||
* @returns {string} API model
|
||||
*/
|
||||
export function getChatCompletionModel(source = null) {
|
||||
const activeSource = source ?? oai_settings.chat_completion_source;
|
||||
switch (activeSource) {
|
||||
case chat_completion_sources.CLAUDE:
|
||||
return oai_settings.claude_model;
|
||||
case chat_completion_sources.OPENAI:
|
||||
@ -1532,7 +1620,7 @@ export function getChatCompletionModel() {
|
||||
case chat_completion_sources.DEEPSEEK:
|
||||
return oai_settings.deepseek_model;
|
||||
default:
|
||||
throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`);
|
||||
throw new Error(`Unknown chat completion source: ${activeSource}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1915,6 +2003,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
'group_names': getGroupNames(),
|
||||
'include_reasoning': Boolean(oai_settings.show_thoughts),
|
||||
'reasoning_effort': String(oai_settings.reasoning_effort),
|
||||
'enable_web_search': Boolean(oai_settings.enable_web_search),
|
||||
};
|
||||
|
||||
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
||||
@ -1986,6 +2075,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
|
||||
if (isMistral) {
|
||||
generate_data['safe_prompt'] = false; // already defaults to false, but just incase they change that in the future.
|
||||
generate_data['stop'] = getCustomStoppingStrings(); // Mistral shouldn't have limits on stop strings.
|
||||
}
|
||||
|
||||
if (isCustom) {
|
||||
@ -2152,6 +2242,9 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
*/
|
||||
function getStreamingReply(data, state) {
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.CLAUDE) {
|
||||
if (oai_settings.show_thoughts) {
|
||||
state.reasoning += data?.delta?.thinking || '';
|
||||
}
|
||||
return data?.delta?.text || '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.MAKERSUITE) {
|
||||
if (oai_settings.show_thoughts) {
|
||||
@ -2170,6 +2263,14 @@ function getStreamingReply(data, state) {
|
||||
state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
|
||||
}
|
||||
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) {
|
||||
if (oai_settings.show_thoughts) {
|
||||
state.reasoning +=
|
||||
data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
|
||||
data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning ??
|
||||
'';
|
||||
}
|
||||
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
|
||||
} else {
|
||||
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
|
||||
}
|
||||
@ -3129,6 +3230,7 @@ function loadOpenAISettings(data, settings) {
|
||||
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.enable_web_search = settings.enable_web_search ?? default_settings.enable_web_search;
|
||||
oai_settings.seed = settings.seed ?? default_settings.seed;
|
||||
oai_settings.n = settings.n ?? default_settings.n;
|
||||
|
||||
@ -3152,7 +3254,7 @@ function loadOpenAISettings(data, settings) {
|
||||
}
|
||||
|
||||
if (oai_settings.ai21_model.startsWith('j2-')) {
|
||||
oai_settings.ai21_model = 'jamba-1.5-large';
|
||||
oai_settings.ai21_model = 'jamba-1.6-large';
|
||||
}
|
||||
|
||||
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
||||
@ -3205,7 +3307,6 @@ function loadOpenAISettings(data, settings) {
|
||||
$('#openai_max_tokens').val(oai_settings.openai_max_tokens);
|
||||
|
||||
$('#wrap_in_quotes').prop('checked', oai_settings.wrap_in_quotes);
|
||||
$('#jailbreak_system').prop('checked', oai_settings.jailbreak_system);
|
||||
$('#openai_show_external_models').prop('checked', oai_settings.show_external_models);
|
||||
$('#openai_external_category').toggle(oai_settings.show_external_models);
|
||||
$('#claude_use_sysprompt').prop('checked', oai_settings.claude_use_sysprompt);
|
||||
@ -3257,6 +3358,7 @@ function loadOpenAISettings(data, settings) {
|
||||
$('#seed_openai').val(oai_settings.seed);
|
||||
$('#n_openai').val(oai_settings.n);
|
||||
$('#openai_show_thoughts').prop('checked', oai_settings.show_thoughts);
|
||||
$('#openai_enable_web_search').prop('checked', oai_settings.enable_web_search);
|
||||
|
||||
$('#openai_reasoning_effort').val(oai_settings.reasoning_effort);
|
||||
$(`#openai_reasoning_effort option[value="${oai_settings.reasoning_effort}"]`).prop('selected', true);
|
||||
@ -3489,7 +3591,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
names_behavior: settings.names_behavior,
|
||||
send_if_empty: settings.send_if_empty,
|
||||
jailbreak_prompt: settings.jailbreak_prompt,
|
||||
jailbreak_system: settings.jailbreak_system,
|
||||
impersonation_prompt: settings.impersonation_prompt,
|
||||
new_chat_prompt: settings.new_chat_prompt,
|
||||
new_group_chat_prompt: settings.new_group_chat_prompt,
|
||||
@ -3522,6 +3623,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
function_calling: settings.function_calling,
|
||||
show_thoughts: settings.show_thoughts,
|
||||
reasoning_effort: settings.reasoning_effort,
|
||||
enable_web_search: settings.enable_web_search,
|
||||
seed: settings.seed,
|
||||
n: settings.n,
|
||||
};
|
||||
@ -3909,81 +4011,7 @@ async function onLogitBiasPresetDeleteClick() {
|
||||
|
||||
// Load OpenAI preset settings
|
||||
function onSettingsPresetChange() {
|
||||
const settingsToUpdate = {
|
||||
chat_completion_source: ['#chat_completion_source', 'chat_completion_source', false],
|
||||
temperature: ['#temp_openai', 'temp_openai', false],
|
||||
frequency_penalty: ['#freq_pen_openai', 'freq_pen_openai', false],
|
||||
presence_penalty: ['#pres_pen_openai', 'pres_pen_openai', false],
|
||||
top_p: ['#top_p_openai', 'top_p_openai', false],
|
||||
top_k: ['#top_k_openai', 'top_k_openai', false],
|
||||
top_a: ['#top_a_openai', 'top_a_openai', false],
|
||||
min_p: ['#min_p_openai', 'min_p_openai', false],
|
||||
repetition_penalty: ['#repetition_penalty_openai', 'repetition_penalty_openai', false],
|
||||
max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true],
|
||||
openai_model: ['#model_openai_select', 'openai_model', false],
|
||||
claude_model: ['#model_claude_select', 'claude_model', false],
|
||||
windowai_model: ['#model_windowai_select', 'windowai_model', false],
|
||||
openrouter_model: ['#model_openrouter_select', 'openrouter_model', false],
|
||||
openrouter_use_fallback: ['#openrouter_use_fallback', 'openrouter_use_fallback', true],
|
||||
openrouter_group_models: ['#openrouter_group_models', 'openrouter_group_models', false],
|
||||
openrouter_sort_models: ['#openrouter_sort_models', 'openrouter_sort_models', false],
|
||||
openrouter_providers: ['#openrouter_providers_chat', 'openrouter_providers', false],
|
||||
openrouter_allow_fallbacks: ['#openrouter_allow_fallbacks', 'openrouter_allow_fallbacks', true],
|
||||
openrouter_middleout: ['#openrouter_middleout', 'openrouter_middleout', false],
|
||||
ai21_model: ['#model_ai21_select', 'ai21_model', false],
|
||||
mistralai_model: ['#model_mistralai_select', 'mistralai_model', false],
|
||||
cohere_model: ['#model_cohere_select', 'cohere_model', false],
|
||||
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false],
|
||||
groq_model: ['#model_groq_select', 'groq_model', false],
|
||||
nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false],
|
||||
deepseek_model: ['#model_deepseek_select', 'deepseek_model', false],
|
||||
zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false],
|
||||
blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false],
|
||||
custom_model: ['#custom_model_id', 'custom_model', false],
|
||||
custom_url: ['#custom_api_url_text', 'custom_url', false],
|
||||
custom_include_body: ['#custom_include_body', 'custom_include_body', false],
|
||||
custom_exclude_body: ['#custom_exclude_body', 'custom_exclude_body', false],
|
||||
custom_include_headers: ['#custom_include_headers', 'custom_include_headers', false],
|
||||
custom_prompt_post_processing: ['#custom_prompt_post_processing', 'custom_prompt_post_processing', false],
|
||||
google_model: ['#model_google_select', 'google_model', false],
|
||||
openai_max_context: ['#openai_max_context', 'openai_max_context', false],
|
||||
openai_max_tokens: ['#openai_max_tokens', 'openai_max_tokens', false],
|
||||
wrap_in_quotes: ['#wrap_in_quotes', 'wrap_in_quotes', true],
|
||||
names_behavior: ['#names_behavior', 'names_behavior', false],
|
||||
send_if_empty: ['#send_if_empty_textarea', 'send_if_empty', false],
|
||||
impersonation_prompt: ['#impersonation_prompt_textarea', 'impersonation_prompt', false],
|
||||
new_chat_prompt: ['#newchat_prompt_textarea', 'new_chat_prompt', false],
|
||||
new_group_chat_prompt: ['#newgroupchat_prompt_textarea', 'new_group_chat_prompt', false],
|
||||
new_example_chat_prompt: ['#newexamplechat_prompt_textarea', 'new_example_chat_prompt', false],
|
||||
continue_nudge_prompt: ['#continue_nudge_prompt_textarea', 'continue_nudge_prompt', false],
|
||||
bias_preset_selected: ['#openai_logit_bias_preset', 'bias_preset_selected', false],
|
||||
reverse_proxy: ['#openai_reverse_proxy', 'reverse_proxy', false],
|
||||
wi_format: ['#wi_format_textarea', 'wi_format', false],
|
||||
scenario_format: ['#scenario_format_textarea', 'scenario_format', false],
|
||||
personality_format: ['#personality_format_textarea', 'personality_format', false],
|
||||
group_nudge_prompt: ['#group_nudge_prompt_textarea', 'group_nudge_prompt', false],
|
||||
stream_openai: ['#stream_toggle', 'stream_openai', true],
|
||||
prompts: ['', 'prompts', false],
|
||||
prompt_order: ['', 'prompt_order', false],
|
||||
api_url_scale: ['#api_url_scale', 'api_url_scale', false],
|
||||
show_external_models: ['#openai_show_external_models', 'show_external_models', true],
|
||||
proxy_password: ['#openai_proxy_password', 'proxy_password', false],
|
||||
assistant_prefill: ['#claude_assistant_prefill', 'assistant_prefill', false],
|
||||
assistant_impersonation: ['#claude_assistant_impersonation', 'assistant_impersonation', false],
|
||||
claude_use_sysprompt: ['#claude_use_sysprompt', 'claude_use_sysprompt', true],
|
||||
use_makersuite_sysprompt: ['#use_makersuite_sysprompt', 'use_makersuite_sysprompt', true],
|
||||
use_alt_scale: ['#use_alt_scale', 'use_alt_scale', true],
|
||||
squash_system_messages: ['#squash_system_messages', 'squash_system_messages', true],
|
||||
image_inlining: ['#openai_image_inlining', 'image_inlining', true],
|
||||
inline_image_quality: ['#openai_inline_image_quality', 'inline_image_quality', false],
|
||||
continue_prefill: ['#continue_prefill', 'continue_prefill', true],
|
||||
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],
|
||||
};
|
||||
const presetNameBefore = oai_settings.preset_settings_openai;
|
||||
|
||||
const presetName = $('#settings_preset_openai').find(':selected').text();
|
||||
oai_settings.preset_settings_openai = presetName;
|
||||
@ -4010,6 +4038,7 @@ function onSettingsPresetChange() {
|
||||
settingsToUpdate: settingsToUpdate,
|
||||
settings: oai_settings,
|
||||
savePreset: saveOpenAIPreset,
|
||||
presetNameBefore: presetNameBefore,
|
||||
}).finally(r => {
|
||||
$('.model_custom_select').empty();
|
||||
|
||||
@ -4110,6 +4139,40 @@ function getMaxContextWindowAI(value) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum context size for the Groq model
|
||||
* @param {string} model Model identifier
|
||||
* @param {boolean} isUnlocked Whether context limits are unlocked
|
||||
* @returns {number} Maximum context size in tokens
|
||||
*/
|
||||
function getGroqMaxContext(model, isUnlocked) {
|
||||
if (isUnlocked) {
|
||||
return unlocked_max;
|
||||
}
|
||||
|
||||
const contextMap = {
|
||||
'gemma2-9b-it': max_8k,
|
||||
'llama-3.3-70b-versatile': max_128k,
|
||||
'llama-3.1-8b-instant': max_128k,
|
||||
'llama3-70b-8192': max_8k,
|
||||
'llama3-8b-8192': max_8k,
|
||||
'llama-guard-3-8b': max_8k,
|
||||
'mixtral-8x7b-32768': max_32k,
|
||||
'deepseek-r1-distill-llama-70b': max_128k,
|
||||
'llama-3.3-70b-specdec': max_8k,
|
||||
'llama-3.2-1b-preview': max_128k,
|
||||
'llama-3.2-3b-preview': max_128k,
|
||||
'llama-3.2-11b-vision-preview': max_128k,
|
||||
'llama-3.2-90b-vision-preview': max_128k,
|
||||
'qwen-2.5-32b': max_128k,
|
||||
'deepseek-r1-distill-qwen-32b': max_128k,
|
||||
'deepseek-r1-distill-llama-70b-specdec': max_128k,
|
||||
};
|
||||
|
||||
// Return context size if model found, otherwise default to 128k
|
||||
return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_128k;
|
||||
}
|
||||
|
||||
async function onModelChange() {
|
||||
biasCache = undefined;
|
||||
let value = String($(this).val() || '');
|
||||
@ -4148,7 +4211,7 @@ async function onModelChange() {
|
||||
|
||||
if ($(this).is('#model_ai21_select')) {
|
||||
if (value === '' || value.startsWith('j2-')) {
|
||||
value = 'jamba-1.5-large';
|
||||
value = 'jamba-1.6-large';
|
||||
$('#model_ai21_select').val(value);
|
||||
}
|
||||
|
||||
@ -4378,6 +4441,9 @@ async function onModelChange() {
|
||||
else if (['c4ai-aya-23-8b', 'c4ai-aya-expanse-8b'].includes(oai_settings.cohere_model)) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
}
|
||||
else if (['c4ai-aya-vision-8b', 'c4ai-aya-vision-32b'].includes(oai_settings.cohere_model)) {
|
||||
$('#openai_max_context').attr('max', max_16k);
|
||||
}
|
||||
else {
|
||||
$('#openai_max_context').attr('max', max_4k);
|
||||
}
|
||||
@ -4390,7 +4456,7 @@ async function onModelChange() {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
}
|
||||
else if (['sonar', 'sonar-reasoning'].includes(oai_settings.perplexity_model)) {
|
||||
else if (['sonar', 'sonar-reasoning', 'sonar-reasoning-pro', 'r1-1776'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', 127000);
|
||||
}
|
||||
else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {
|
||||
@ -4411,33 +4477,8 @@ async function onModelChange() {
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else if (oai_settings.groq_model.includes('gemma2-9b-it')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.3-70b-versatile')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.1-8b-instant')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama3-70b-8192')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
} else if (oai_settings.groq_model.includes('llama3-8b-8192')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
} else if (oai_settings.groq_model.includes('mixtral-8x7b-32768')) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
} else if (oai_settings.groq_model.includes('deepseek-r1-distill-llama-70b')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.3-70b-specdec')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-1b-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-3b-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-11b-vision-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-90b-vision-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
const maxContext = getGroqMaxContext(oai_settings.groq_model, oai_settings.max_context_unlocked);
|
||||
$('#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');
|
||||
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
|
||||
@ -4447,7 +4488,7 @@ async function onModelChange() {
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.AI21) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else if (oai_settings.ai21_model.includes('jamba-1.5') || oai_settings.ai21_model.includes('jamba-instruct')) {
|
||||
} else if (oai_settings.ai21_model.startsWith('jamba-')) {
|
||||
$('#openai_max_context').attr('max', max_256k);
|
||||
}
|
||||
|
||||
@ -4967,9 +5008,12 @@ export function isImageInliningSupported() {
|
||||
'gemini-1.5-pro-exp-0827',
|
||||
'claude-3',
|
||||
'claude-3-5',
|
||||
'claude-3-7',
|
||||
'gpt-4-turbo',
|
||||
'gpt-4o',
|
||||
'gpt-4o-mini',
|
||||
'gpt-4.5-preview',
|
||||
'gpt-4.5-preview-2025-02-27',
|
||||
'o1',
|
||||
'o1-2024-12-17',
|
||||
'chatgpt-4o-latest',
|
||||
@ -4980,6 +5024,8 @@ export function isImageInliningSupported() {
|
||||
'pixtral-12b-2409',
|
||||
'pixtral-large-latest',
|
||||
'pixtral-large-2411',
|
||||
'c4ai-aya-vision-8b',
|
||||
'c4ai-aya-vision-32b',
|
||||
];
|
||||
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
@ -4997,6 +5043,8 @@ export function isImageInliningSupported() {
|
||||
return visionSupportedModels.some(model => oai_settings.zerooneai_model.includes(model));
|
||||
case chat_completion_sources.MISTRALAI:
|
||||
return visionSupportedModels.some(model => oai_settings.mistralai_model.includes(model));
|
||||
case chat_completion_sources.COHERE:
|
||||
return visionSupportedModels.some(model => oai_settings.cohere_model.includes(model));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -5535,6 +5583,11 @@ export function initOpenAI() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#openai_enable_web_search').on('input', function () {
|
||||
oai_settings.enable_web_search = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
if (!CSS.supports('field-sizing', 'content')) {
|
||||
$(document).on('input', '#openai_settings .autoSetHeight', function () {
|
||||
resetScrollHeight($(this));
|
||||
|
Reference in New Issue
Block a user