mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Add Window AI model settings
This commit is contained in:
		| @@ -457,7 +457,7 @@ | |||||||
|                                 </div> |                                 </div> | ||||||
|                             </div> |                             </div> | ||||||
|                             <div id="range_block_openai"> |                             <div id="range_block_openai"> | ||||||
|                                 <div class="range-block"> |                                 <div class="range-block" data-source="openai,claude"> | ||||||
|                                     <div class="range-block-title justifyLeft" data-i18n="OpenAI Reverse Proxy"> |                                     <div class="range-block-title justifyLeft" data-i18n="OpenAI Reverse Proxy"> | ||||||
|                                         OpenAI / Claude Reverse Proxy |                                         OpenAI / Claude Reverse Proxy | ||||||
|                                     </div> |                                     </div> | ||||||
| @@ -482,7 +482,7 @@ | |||||||
|                                         <input id="openai_reverse_proxy" type="text" class="text_pole" placeholder="https://api.openai.com/v1" maxlength="100" /> |                                         <input id="openai_reverse_proxy" type="text" class="text_pole" placeholder="https://api.openai.com/v1" maxlength="100" /> | ||||||
|                                     </div> |                                     </div> | ||||||
|                                 </div> |                                 </div> | ||||||
|                                 <div class="range-block"> |                                 <div class="range-block" data-source="openai,claude"> | ||||||
|                                     <div class="range-block-title justifyLeft"> |                                     <div class="range-block-title justifyLeft"> | ||||||
|                                         <label for="legacy_streaming" class="checkbox_label"> |                                         <label for="legacy_streaming" class="checkbox_label"> | ||||||
|                                             <input id="legacy_streaming" type="checkbox" /> |                                             <input id="legacy_streaming" type="checkbox" /> | ||||||
| @@ -1450,6 +1450,23 @@ | |||||||
|                             </div> |                             </div> | ||||||
|                         </form> |                         </form> | ||||||
|  |  | ||||||
|  |                         <form id="windowai_form" data-source="windowai"> | ||||||
|  |                             <div> | ||||||
|  |                                 <h4 data-i18n="Window AI Model">Window AI Model</h4> | ||||||
|  |                                 <select id="model_windowai_select"> | ||||||
|  |                                     <option value="">Use extension settings</option> | ||||||
|  |                                     <option value="openai/gpt-3.5-turbo">openai/gpt-3.5-turbo</option> | ||||||
|  |                                     <option value="openai/gpt-4">openai/gpt-4</option> | ||||||
|  |                                     <option value="anthropic/claude-instant-v1">anthropic/claude-instant-v1</option> | ||||||
|  |                                     <option value="anthropic/claude-instant-v1-100k">anthropic/claude-instant-v1-100k</option> | ||||||
|  |                                     <option value="anthropic/claude-v1">anthropic/claude-v1</option> | ||||||
|  |                                     <option value="anthropic/claude-v1-100k">anthropic/claude-v1-100k</option> | ||||||
|  |                                     <option value="togethercomputer/GPT-NeoXT-Chat-Base-20B">togethercomputer/GPT-NeoXT-Chat-Base-20B</option> | ||||||
|  |                                     <option value="cohere/command-nightly">cohere/command-nightly</option> | ||||||
|  |                                 </select> | ||||||
|  |                             </div> | ||||||
|  |                         </form> | ||||||
|  |  | ||||||
|                         <div class="flex-container flex"> |                         <div class="flex-container flex"> | ||||||
|                             <input id="api_button_openai" class="menu_button" type="submit" value="Connect"> |                             <input id="api_button_openai" class="menu_button" type="submit" value="Connect"> | ||||||
|                             <input id="test_api_button" class="menu_button" type="button" value="Test Message" title="Verifies your API connection by sending a short test message. Be aware that you'll be credited for it!"> |                             <input id="test_api_button" class="menu_button" type="button" value="Test Message" title="Verifies your API connection by sending a short test message. Be aware that you'll be credited for it!"> | ||||||
|   | |||||||
| @@ -81,6 +81,7 @@ const default_bias_presets = { | |||||||
|  |  | ||||||
| const gpt3_max = 4095; | const gpt3_max = 4095; | ||||||
| const gpt4_max = 8191; | const gpt4_max = 8191; | ||||||
|  | const gpt_neox_max = 2048; | ||||||
| const gpt4_32k_max = 32767; | const gpt4_32k_max = 32767; | ||||||
| const claude_max = 7500; | const claude_max = 7500; | ||||||
| const claude_100k_max = 99000; | const claude_100k_max = 99000; | ||||||
| @@ -121,6 +122,7 @@ const default_settings = { | |||||||
|     wi_format: default_wi_format, |     wi_format: default_wi_format, | ||||||
|     openai_model: 'gpt-3.5-turbo', |     openai_model: 'gpt-3.5-turbo', | ||||||
|     claude_model: 'claude-instant-v1', |     claude_model: 'claude-instant-v1', | ||||||
|  |     windowai_model: '', | ||||||
|     jailbreak_system: false, |     jailbreak_system: false, | ||||||
|     reverse_proxy: '', |     reverse_proxy: '', | ||||||
|     legacy_streaming: false, |     legacy_streaming: false, | ||||||
| @@ -152,6 +154,7 @@ const oai_settings = { | |||||||
|     wi_format: default_wi_format, |     wi_format: default_wi_format, | ||||||
|     openai_model: 'gpt-3.5-turbo', |     openai_model: 'gpt-3.5-turbo', | ||||||
|     claude_model: 'claude-instant-v1', |     claude_model: 'claude-instant-v1', | ||||||
|  |     windowai_model: '', | ||||||
|     jailbreak_system: false, |     jailbreak_system: false, | ||||||
|     reverse_proxy: '', |     reverse_proxy: '', | ||||||
|     legacy_streaming: false, |     legacy_streaming: false, | ||||||
| @@ -608,6 +611,7 @@ async function sendWindowAIRequest(openai_msgs_tosend, signal, stream) { | |||||||
|         { |         { | ||||||
|             temperature: temperature, |             temperature: temperature, | ||||||
|             maxTokens: oai_settings.openai_max_tokens, |             maxTokens: oai_settings.openai_max_tokens, | ||||||
|  |             model: oai_settings.windowai_model || null, | ||||||
|             onStreamResult: onStreamResult, |             onStreamResult: onStreamResult, | ||||||
|         } |         } | ||||||
|     ); |     ); | ||||||
| @@ -955,6 +959,7 @@ function loadOpenAISettings(data, settings) { | |||||||
|  |  | ||||||
|     $(`#model_openai_select option[value="${oai_settings.openai_model}"`).attr('selected', true); |     $(`#model_openai_select option[value="${oai_settings.openai_model}"`).attr('selected', true); | ||||||
|     $(`#model_claude_select option[value="${oai_settings.claude_model}"`).attr('selected', true); |     $(`#model_claude_select option[value="${oai_settings.claude_model}"`).attr('selected', true); | ||||||
|  |     $(`#model_windowai_select option[value="${oai_settings.windowai_model}"`).attr('selected', true); | ||||||
|     $('#openai_max_context').val(oai_settings.openai_max_context); |     $('#openai_max_context').val(oai_settings.openai_max_context); | ||||||
|     $('#openai_max_context_counter').text(`${oai_settings.openai_max_context}`); |     $('#openai_max_context_counter').text(`${oai_settings.openai_max_context}`); | ||||||
|  |  | ||||||
| @@ -1130,6 +1135,7 @@ async function saveOpenAIPreset(name, settings) { | |||||||
|         nsfw_avoidance_prompt: settings.nsfw_avoidance_prompt, |         nsfw_avoidance_prompt: settings.nsfw_avoidance_prompt, | ||||||
|         wi_format: settings.wi_format, |         wi_format: settings.wi_format, | ||||||
|         claude_model: settings.claude_model, |         claude_model: settings.claude_model, | ||||||
|  |         windowai_model: settings.windowai_model, | ||||||
|         chat_completion_source: settings.chat_completion_source, |         chat_completion_source: settings.chat_completion_source, | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
| @@ -1387,6 +1393,7 @@ function onSettingsPresetChange() { | |||||||
|         max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true], |         max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true], | ||||||
|         openai_model: ['#model_openai_select', 'openai_model', false], |         openai_model: ['#model_openai_select', 'openai_model', false], | ||||||
|         claude_model: ['#model_claude_select', 'claude_model', false], |         claude_model: ['#model_claude_select', 'claude_model', false], | ||||||
|  |         windowai_model: ['#model_windowai_select', 'windowai_model', false], | ||||||
|         openai_max_context: ['#openai_max_context', 'openai_max_context', false], |         openai_max_context: ['#openai_max_context', 'openai_max_context', false], | ||||||
|         openai_max_tokens: ['#openai_max_tokens', 'openai_max_tokens', false], |         openai_max_tokens: ['#openai_max_tokens', 'openai_max_tokens', false], | ||||||
|         nsfw_toggle: ['#nsfw_toggle', 'nsfw_toggle', true], |         nsfw_toggle: ['#nsfw_toggle', 'nsfw_toggle', true], | ||||||
| @@ -1429,6 +1436,11 @@ function onModelChange() { | |||||||
|         oai_settings.claude_model  = value; |         oai_settings.claude_model  = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if ($(this).is('#model_windowai_select')) { | ||||||
|  |         console.log('WindowAI model changed to', value); | ||||||
|  |         oai_settings.windowai_model = value; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if ($(this).is('#model_openai_select')) { |     if ($(this).is('#model_openai_select')) { | ||||||
|         console.log('OpenAI model changed to', value); |         console.log('OpenAI model changed to', value); | ||||||
|         oai_settings.openai_model = value; |         oai_settings.openai_model = value; | ||||||
| @@ -1453,7 +1465,44 @@ function onModelChange() { | |||||||
|         $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); |         $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI || oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) { |     if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) { | ||||||
|  |         if (oai_settings.max_context_unlocked) { | ||||||
|  |             $('#openai_max_context').attr('max', unlocked_max); | ||||||
|  |         } | ||||||
|  |         else if (value.endsWith('100k')) { | ||||||
|  |             $('#openai_max_context').attr('max', claude_100k_max); | ||||||
|  |         } | ||||||
|  |         else if (value.includes('claude')) { | ||||||
|  |             $('#openai_max_context').attr('max', claude_max); | ||||||
|  |         } | ||||||
|  |         else if (value.includes('gpt-3.5')) { | ||||||
|  |             $('#openai_max_context').attr('max', gpt3_max); | ||||||
|  |         } | ||||||
|  |         else if (value.includes('gpt-4')) { | ||||||
|  |             $('#openai_max_context').attr('max', gpt4_max); | ||||||
|  |         } | ||||||
|  |         else if (value.includes('GPT-NeoXT')) { | ||||||
|  |             $('#openai_max_context').attr('max', gpt_neox_max); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             // default to gpt-3 (4095 tokens) | ||||||
|  |             $('#openai_max_context').attr('max', gpt3_max); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         oai_settings.openai_max_context = Math.max(Number($('#openai_max_context').val()), oai_settings.openai_max_context); | ||||||
|  |         $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); | ||||||
|  |  | ||||||
|  |         if (value.includes('claude')) { | ||||||
|  |             oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai); | ||||||
|  |             $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); | ||||||
|  |             $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) { | ||||||
|         if (oai_settings.max_context_unlocked) { |         if (oai_settings.max_context_unlocked) { | ||||||
|             $('#openai_max_context').attr('max', unlocked_max); |             $('#openai_max_context').attr('max', unlocked_max); | ||||||
|         } |         } | ||||||
| @@ -1545,9 +1594,13 @@ async function onConnectButtonClick(e) { | |||||||
| function toggleChatCompletionForms() { | function toggleChatCompletionForms() { | ||||||
|     if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) { |     if (oai_settings.chat_completion_source == chat_completion_sources.CLAUDE) { | ||||||
|         $('#model_claude_select').trigger('change'); |         $('#model_claude_select').trigger('change'); | ||||||
|     } else { |     } | ||||||
|  |     else if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) { | ||||||
|         $('#model_openai_select').trigger('change'); |         $('#model_openai_select').trigger('change'); | ||||||
|     } |     } | ||||||
|  |     else if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) { | ||||||
|  |         $('#model_windowai_select').trigger('change'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     $('[data-source]').each(function () { |     $('[data-source]').each(function () { | ||||||
|         const validSources = $(this).data('source').split(','); |         const validSources = $(this).data('source').split(','); | ||||||
| @@ -1766,6 +1819,7 @@ $(document).ready(function () { | |||||||
|     $("#openai_reverse_proxy").on("input", onReverseProxyInput); |     $("#openai_reverse_proxy").on("input", onReverseProxyInput); | ||||||
|     $("#model_openai_select").on("change", onModelChange); |     $("#model_openai_select").on("change", onModelChange); | ||||||
|     $("#model_claude_select").on("change", onModelChange); |     $("#model_claude_select").on("change", onModelChange); | ||||||
|  |     $("#model_windowai_select").on("change", onModelChange); | ||||||
|     $("#settings_perset_openai").on("change", onSettingsPresetChange); |     $("#settings_perset_openai").on("change", onSettingsPresetChange); | ||||||
|     $("#new_oai_preset").on("click", onNewPresetClick); |     $("#new_oai_preset").on("click", onNewPresetClick); | ||||||
|     $("#delete_oai_preset").on("click", onDeletePresetClick); |     $("#delete_oai_preset").on("click", onDeletePresetClick); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user