Remove Window AI from CC sources (#4294)

7429726eb105466f75eadf2c21d01ef80a95b271

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
10 files changed, +1 -286Showing whitespace changes
default/content/presets/openai/Default.json+0 -1
@@ -2,7 +2,6 @@
2 "chat_completion_source": "openai",2 "chat_completion_source": "openai",
3 "openai_model": "gpt-4-turbo",3 "openai_model": "gpt-4-turbo",
4 "claude_model": "claude-3-5-sonnet-20240620",4 "claude_model": "claude-3-5-sonnet-20240620",
5 "windowai_model": "",
6 "openrouter_model": "OR_Website",5 "openrouter_model": "OR_Website",
7 "openrouter_use_fallback": false,6 "openrouter_use_fallback": false,
8 "openrouter_group_models": false,7 "openrouter_group_models": false,
default/content/settings.json+0 -1
@@ -624,7 +624,6 @@
624 "openai_model": "gpt-4-turbo",624 "openai_model": "gpt-4-turbo",
625 "claude_model": "claude-3-5-sonnet-20240620",625 "claude_model": "claude-3-5-sonnet-20240620",
626 "ai21_model": "jamba-large",626 "ai21_model": "jamba-large",
627 "windowai_model": "",
628 "openrouter_model": "OR_Website",627 "openrouter_model": "OR_Website",
629 "reverse_proxy": "",628 "reverse_proxy": "",
630 "chat_completion_source": "openai",629 "chat_completion_source": "openai",
public/index.html+1 -22
@@ -691,7 +691,7 @@
691 </span>691 </span>
692 </div>692 </div>
693 </div>693 </div>
694 <div class="range-block" data-source="openai,claude,windowai,aimlapi,openrouter,ai21,scale,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">694 <div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,scale,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">
695 <div class="range-block-title" data-i18n="Temperature">695 <div class="range-block-title" data-i18n="Temperature">
696 Temperature696 Temperature
697 </div>697 </div>
@@ -2803,7 +2803,6 @@
2803 <option value="perplexity">Perplexity</option>2803 <option value="perplexity">Perplexity</option>
2804 <option value="pollinations">Pollinations</option>2804 <option value="pollinations">Pollinations</option>
2805 <option value="scale">Scale</option>2805 <option value="scale">Scale</option>
2806 <option value="windowai">Window AI</option>
2807 <option value="xai">xAI (Grok)</option>2806 <option value="xai">xAI (Grok)</option>
2808 </optgroup>2807 </optgroup>
2809 </select>2808 </select>
@@ -3031,26 +3030,6 @@
3031 </select>3030 </select>
3032 </div>3031 </div>
3033 </form>3032 </form>
3034 <form id="windowai_form" data-source="windowai" action="javascript:void(null);" method="post" enctype="multipart/form-data">
3035 <div>
3036 <h4 data-i18n="Window AI Model">Window AI Model</h4>
3037 <select id="model_windowai_select">
3038 <option data-i18n="Use extension settings" value="">Use extension settings</option>
3039 <option value="openai/gpt-3.5-turbo">openai/gpt-3.5-turbo</option>
3040 <option value="openai/gpt-3.5-turbo-16k">openai/gpt-3.5-turbo-16k</option>
3041 <option value="openai/gpt-4">openai/gpt-4</option>
3042 <option value="openai/gpt-4-32k">openai/gpt-4-32k</option>
3043 <option value="anthropic/claude-instant-v1">anthropic/claude-instant-v1</option>
3044 <option value="anthropic/claude-instant-v1-100k">anthropic/claude-instant-v1-100k</option>
3045 <option value="anthropic/claude-v1">anthropic/claude-v1</option>
3046 <option value="anthropic/claude-v1-100k">anthropic/claude-v1-100k</option>
3047 <option value="google/palm-2-chat-bison">google/palm-2-chat-bison</option>
3048 <option value="google/palm-2-codechat-bison">google/palm-2-codechat-bison</option>
3049 <option value="togethercomputer/GPT-NeoXT-Chat-Base-20B">togethercomputer/GPT-NeoXT-Chat-Base-20B</option>
3050 <option value="cohere/command-nightly">cohere/command-nightly</option>
3051 </select>
3052 </div>
3053 </form>
3054 <form id="openrouter_form" data-source="openrouter" action="javascript:void(null);" method="post" enctype="multipart/form-data">3033 <form id="openrouter_form" data-source="openrouter" action="javascript:void(null);" method="post" enctype="multipart/form-data">
3055 <h4 data-i18n="OpenRouter API Key">OpenRouter API Key</h4>3034 <h4 data-i18n="OpenRouter API Key">OpenRouter API Key</h4>
3056 <div>3035 <div>
public/locales/ru-ru.json+0 -2
@@ -1749,8 +1749,6 @@
1749 "dot quota_error": "имеется достаточно кредитов.",1749 "dot quota_error": "имеется достаточно кредитов.",
1750 "If you have sufficient credits, please try again later.": "Если кредитов достаточно, то повторите попытку позднее.",1750 "If you have sufficient credits, please try again later.": "Если кредитов достаточно, то повторите попытку позднее.",
1751 "Proxy preset '${0}' not found": "Пресет '${0}' не найден",1751 "Proxy preset '${0}' not found": "Пресет '${0}' не найден",
1752 "Window.ai returned an error": "Window.ai ответил ошибкой",
1753 "Extension is not installed": "Расширение не установлено",
1754 "Update or remove your reverse proxy settings.": "Измените или удалите ваши настройки прокси.",1752 "Update or remove your reverse proxy settings.": "Измените или удалите ваши настройки прокси.",
1755 "An error occurred while importing prompts. More info available in console.": "В процессе импорта произошла ошибка. Подробную информацию см. в консоли.",1753 "An error occurred while importing prompts. More info available in console.": "В процессе импорта произошла ошибка. Подробную информацию см. в консоли.",
1756 "Could not import prompts. Export failed validation.": "Не удалось импортировать промпты. Не пройдена валидация при экспорте.",1754 "Could not import prompts. Export failed validation.": "Не удалось импортировать промпты. Не пройдена валидация при экспорте.",
public/script.js+0 -4
@@ -6785,10 +6785,6 @@ export function changeMainAPI() {
6785 main_api = selectedVal;6785 main_api = selectedVal;
6786 setOnlineStatus('no_connection');6786 setOnlineStatus('no_connection');
67876787
6788 if (main_api == 'openai' && oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
6789 $('#api_button_openai').trigger('click');
6790 }
6791
6792 if (main_api == 'koboldhorde') {6788 if (main_api == 'koboldhorde') {
6793 getStatusHorde();6789 getStatusHorde();
6794 getHordeModels(true);6790 getHordeModels(true);
public/scripts/RossAscends-mods.js+0 -1
@@ -398,7 +398,6 @@ function RA_autoconnect(PrevApi) {
398 if (((secret_state[SECRET_KEYS.OPENAI] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.OPENAI)398 if (((secret_state[SECRET_KEYS.OPENAI] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.OPENAI)
399 || ((secret_state[SECRET_KEYS.CLAUDE] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.CLAUDE)399 || ((secret_state[SECRET_KEYS.CLAUDE] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.CLAUDE)
400 || ((secret_state[SECRET_KEYS.SCALE] || secret_state[SECRET_KEYS.SCALE_COOKIE]) && oai_settings.chat_completion_source == chat_completion_sources.SCALE)400 || ((secret_state[SECRET_KEYS.SCALE] || secret_state[SECRET_KEYS.SCALE_COOKIE]) && oai_settings.chat_completion_source == chat_completion_sources.SCALE)
401 || (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI)
402 || (secret_state[SECRET_KEYS.OPENROUTER] && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER)401 || (secret_state[SECRET_KEYS.OPENROUTER] && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER)
403 || (secret_state[SECRET_KEYS.AI21] && oai_settings.chat_completion_source == chat_completion_sources.AI21)402 || (secret_state[SECRET_KEYS.AI21] && oai_settings.chat_completion_source == chat_completion_sources.AI21)
404 || (secret_state[SECRET_KEYS.MAKERSUITE] && oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE)403 || (secret_state[SECRET_KEYS.MAKERSUITE] && oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE)
public/scripts/openai.js+0 -237
@@ -171,7 +171,6 @@ export let model_list = [];
171171
172export const chat_completion_sources = {172export const chat_completion_sources = {
173 OPENAI: 'openai',173 OPENAI: 'openai',
174 WINDOWAI: 'windowai',
175 CLAUDE: 'claude',174 CLAUDE: 'claude',
176 SCALE: 'scale',175 SCALE: 'scale',
177 OPENROUTER: 'openrouter',176 OPENROUTER: 'openrouter',
@@ -261,7 +260,6 @@ export const settingsToUpdate = {
261 max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true, false],260 max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true, false],
262 openai_model: ['#model_openai_select', 'openai_model', false, true],261 openai_model: ['#model_openai_select', 'openai_model', false, true],
263 claude_model: ['#model_claude_select', 'claude_model', false, true],262 claude_model: ['#model_claude_select', 'claude_model', false, true],
264 windowai_model: ['#model_windowai_select', 'windowai_model', false, true],
265 openrouter_model: ['#model_openrouter_select', 'openrouter_model', false, true],263 openrouter_model: ['#model_openrouter_select', 'openrouter_model', false, true],
266 openrouter_use_fallback: ['#openrouter_use_fallback', 'openrouter_use_fallback', true, true],264 openrouter_use_fallback: ['#openrouter_use_fallback', 'openrouter_use_fallback', true, true],
267 openrouter_group_models: ['#openrouter_group_models', 'openrouter_group_models', false, true],265 openrouter_group_models: ['#openrouter_group_models', 'openrouter_group_models', false, true],
@@ -383,7 +381,6 @@ const default_settings = {
383 custom_include_body: '',381 custom_include_body: '',
384 custom_exclude_body: '',382 custom_exclude_body: '',
385 custom_include_headers: '',383 custom_include_headers: '',
386 windowai_model: '',
387 openrouter_model: openrouter_website_model,384 openrouter_model: openrouter_website_model,
388 openrouter_use_fallback: false,385 openrouter_use_fallback: false,
389 openrouter_group_models: false,386 openrouter_group_models: false,
@@ -473,7 +470,6 @@ const oai_settings = {
473 custom_include_body: '',470 custom_include_body: '',
474 custom_exclude_body: '',471 custom_exclude_body: '',
475 custom_include_headers: '',472 custom_include_headers: '',
476 windowai_model: '',
477 openrouter_model: openrouter_website_model,473 openrouter_model: openrouter_website_model,
478 openrouter_use_fallback: false,474 openrouter_use_fallback: false,
479 openrouter_group_models: false,475 openrouter_group_models: false,
@@ -1591,97 +1587,6 @@ function checkModerationError(data, { quiet = false } = {}) {
1591 }1587 }
1592}1588}
15931589
1594async function sendWindowAIRequest(messages, signal, stream) {
1595 if (!('ai' in window)) {
1596 return showWindowExtensionError();
1597 }
1598
1599 let content = '';
1600 let lastContent = '';
1601 let finished = false;
1602
1603 const currentModel = await window.ai.getCurrentModel();
1604 let temperature = Number(oai_settings.temp_openai);
1605
1606 if ((currentModel.includes('claude') || currentModel.includes('palm-2')) && temperature > claude_max_temp) {
1607 console.warn(`Claude and PaLM models only supports temperature up to ${claude_max_temp}. Clamping ${temperature} to ${claude_max_temp}.`);
1608 temperature = claude_max_temp;
1609 }
1610
1611 async function* windowStreamingFunction() {
1612 while (true) {
1613 if (signal.aborted) {
1614 return;
1615 }
1616
1617 // unhang UI thread
1618 await delay(1);
1619
1620 if (lastContent !== content) {
1621 yield { text: content, swipes: [] };
1622 }
1623
1624 lastContent = content;
1625
1626 if (finished) {
1627 return;
1628 }
1629 }
1630 }
1631
1632 const onStreamResult = (res, err) => {
1633 if (err) return;
1634
1635 const thisContent = res?.message?.content;
1636
1637 if (res?.isPartial) {
1638 content += thisContent;
1639 }
1640 else {
1641 content = thisContent;
1642 }
1643 };
1644
1645 const generatePromise = window.ai.generateText(
1646 {
1647 messages: messages,
1648 },
1649 {
1650 temperature: temperature,
1651 maxTokens: oai_settings.openai_max_tokens,
1652 model: oai_settings.windowai_model || null,
1653 onStreamResult: onStreamResult,
1654 },
1655 );
1656
1657 const handleGeneratePromise = (resolve, reject) => {
1658 generatePromise
1659 .then((res) => {
1660 content = res[0]?.message?.content;
1661 finished = true;
1662 resolve && resolve(content);
1663 })
1664 .catch((err) => {
1665 finished = true;
1666 reject && reject(err);
1667 handleWindowError(err);
1668 });
1669 };
1670
1671 if (stream) {
1672 handleGeneratePromise();
1673 return windowStreamingFunction;
1674 } else {
1675 return new Promise((resolve, reject) => {
1676 signal.addEventListener('abort', (reason) => {
1677 reject(reason);
1678 });
1679
1680 handleGeneratePromise(resolve, reject);
1681 });
1682 }
1683}
1684
1685/**1590/**
1686 * Gets the API model for the selected chat completion source.1591 * Gets the API model for the selected chat completion source.
1687 * @param {string} source If it's set, ignores active source1592 * @param {string} source If it's set, ignores active source
@@ -1694,8 +1599,6 @@ export function getChatCompletionModel(source = null) {
1694 return oai_settings.claude_model;1599 return oai_settings.claude_model;
1695 case chat_completion_sources.OPENAI:1600 case chat_completion_sources.OPENAI:
1696 return oai_settings.openai_model;1601 return oai_settings.openai_model;
1697 case chat_completion_sources.WINDOWAI:
1698 return oai_settings.windowai_model;
1699 case chat_completion_sources.SCALE:1602 case chat_completion_sources.SCALE:
1700 return '';1603 return '';
1701 case chat_completion_sources.MAKERSUITE:1604 case chat_completion_sources.MAKERSUITE:
@@ -2229,12 +2132,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
2229 const useLogprobs = !!power_user.request_token_probabilities;2132 const useLogprobs = !!power_user.request_token_probabilities;
2230 const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom || isXAI || isAimlapi);2133 const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom || isXAI || isAimlapi);
22312134
2232 // If we're using the window.ai extension, use that instead
2233 // Doesn't support logit bias yet
2234 if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
2235 return sendWindowAIRequest(messages, signal, stream);
2236 }
2237
2238 const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.SCALE, chat_completion_sources.CUSTOM];2135 const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.SCALE, chat_completion_sources.CUSTOM];
2239 if (oai_settings.bias_preset_selected2136 if (oai_settings.bias_preset_selected
2240 && logitBiasSources.includes(oai_settings.chat_completion_source)2137 && logitBiasSources.includes(oai_settings.chat_completion_source)
@@ -2677,37 +2574,6 @@ function parseOpenAITextLogprobs(logprobs) {
2677 });2574 });
2678}2575}
26792576
2680
2681function handleWindowError(err) {
2682 const text = parseWindowError(err);
2683 toastr.error(text, t`Window.ai returned an error`);
2684 throw err;
2685}
2686
2687function parseWindowError(err) {
2688 let text = 'Unknown error';
2689
2690 switch (err) {
2691 case 'NOT_AUTHENTICATED':
2692 text = 'Incorrect API key / auth';
2693 break;
2694 case 'MODEL_REJECTED_REQUEST':
2695 text = 'AI model refused to fulfill a request';
2696 break;
2697 case 'PERMISSION_DENIED':
2698 text = 'User denied permission to the app';
2699 break;
2700 case 'REQUEST_NOT_FOUND':
2701 text = 'Permission request popup timed out';
2702 break;
2703 case 'INVALID_REQUEST':
2704 text = 'Malformed request';
2705 break;
2706 }
2707
2708 return text;
2709}
2710
2711async function calculateLogitBias() {2577async function calculateLogitBias() {
2712 const body = JSON.stringify(oai_settings.bias_presets[oai_settings.bias_preset_selected]);2578 const body = JSON.stringify(oai_settings.bias_presets[oai_settings.bias_preset_selected]);
2713 let result = {};2579 let result = {};
@@ -3554,7 +3420,6 @@ function loadOpenAISettings(data, settings) {
3554 oai_settings.personality_format = settings.personality_format ?? default_settings.personality_format;3420 oai_settings.personality_format = settings.personality_format ?? default_settings.personality_format;
3555 oai_settings.group_nudge_prompt = settings.group_nudge_prompt ?? default_settings.group_nudge_prompt;3421 oai_settings.group_nudge_prompt = settings.group_nudge_prompt ?? default_settings.group_nudge_prompt;
3556 oai_settings.claude_model = settings.claude_model ?? default_settings.claude_model;3422 oai_settings.claude_model = settings.claude_model ?? default_settings.claude_model;
3557 oai_settings.windowai_model = settings.windowai_model ?? default_settings.windowai_model;
3558 oai_settings.openrouter_model = settings.openrouter_model ?? default_settings.openrouter_model;3423 oai_settings.openrouter_model = settings.openrouter_model ?? default_settings.openrouter_model;
3559 oai_settings.openrouter_group_models = settings.openrouter_group_models ?? default_settings.openrouter_group_models;3424 oai_settings.openrouter_group_models = settings.openrouter_group_models ?? default_settings.openrouter_group_models;
3560 oai_settings.openrouter_sort_models = settings.openrouter_sort_models ?? default_settings.openrouter_sort_models;3425 oai_settings.openrouter_sort_models = settings.openrouter_sort_models ?? default_settings.openrouter_sort_models;
@@ -3648,8 +3513,6 @@ function loadOpenAISettings(data, settings) {
3648 $(`#model_openai_select option[value="${oai_settings.openai_model}"`).prop('selected', true);3513 $(`#model_openai_select option[value="${oai_settings.openai_model}"`).prop('selected', true);
3649 $('#model_claude_select').val(oai_settings.claude_model);3514 $('#model_claude_select').val(oai_settings.claude_model);
3650 $(`#model_claude_select option[value="${oai_settings.claude_model}"`).prop('selected', true);3515 $(`#model_claude_select option[value="${oai_settings.claude_model}"`).prop('selected', true);
3651 $('#model_windowai_select').val(oai_settings.windowai_model);
3652 $(`#model_windowai_select option[value="${oai_settings.windowai_model}"`).prop('selected', true);
3653 $('#model_google_select').val(oai_settings.google_model);3516 $('#model_google_select').val(oai_settings.google_model);
3654 $(`#model_google_select option[value="${oai_settings.google_model}"`).prop('selected', true);3517 $(`#model_google_select option[value="${oai_settings.google_model}"`).prop('selected', true);
3655 $('#model_vertexai_select').val(oai_settings.vertexai_model);3518 $('#model_vertexai_select').val(oai_settings.vertexai_model);
@@ -3837,21 +3700,6 @@ function setContinuePostfixControls() {
3837}3700}
38383701
3839async function getStatusOpen() {3702async function getStatusOpen() {
3840 if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
3841 let status;
3842
3843 if ('ai' in window) {
3844 status = t`Valid`;
3845 }
3846 else {
3847 showWindowExtensionError();
3848 status = 'no_connection';
3849 }
3850
3851 setOnlineStatus(status);
3852 return resultCheckStatus();
3853 }
3854
3855 const noValidateSources = [3703 const noValidateSources = [
3856 chat_completion_sources.SCALE,3704 chat_completion_sources.SCALE,
3857 chat_completion_sources.CLAUDE,3705 chat_completion_sources.CLAUDE,
@@ -3936,15 +3784,6 @@ async function getStatusOpen() {
3936 return resultCheckStatus();3784 return resultCheckStatus();
3937}3785}
39383786
3939function showWindowExtensionError() {
3940 toastr.error(t`Get it here:` + ' <a href="https://windowai.io/" target="_blank">windowai.io</a>', t`Extension is not installed`, {
3941 escapeHtml: false,
3942 timeOut: 0,
3943 extendedTimeOut: 0,
3944 preventDuplicates: true,
3945 });
3946}
3947
3948/**3787/**
3949 * Persist a settings preset with the given name3788 * Persist a settings preset with the given name
3950 *3789 *
@@ -3958,7 +3797,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
3958 chat_completion_source: settings.chat_completion_source,3797 chat_completion_source: settings.chat_completion_source,
3959 openai_model: settings.openai_model,3798 openai_model: settings.openai_model,
3960 claude_model: settings.claude_model,3799 claude_model: settings.claude_model,
3961 windowai_model: settings.windowai_model,
3962 openrouter_model: settings.openrouter_model,3800 openrouter_model: settings.openrouter_model,
3963 openrouter_use_fallback: settings.openrouter_use_fallback,3801 openrouter_use_fallback: settings.openrouter_use_fallback,
3964 openrouter_group_models: settings.openrouter_group_models,3802 openrouter_group_models: settings.openrouter_group_models,
@@ -4553,49 +4391,6 @@ function getMaxContextOpenAI(value) {
4553 }4391 }
4554}4392}
45554393
4556function getMaxContextWindowAI(value) {
4557 if (oai_settings.max_context_unlocked) {
4558 return unlocked_max;
4559 }
4560 else if (value.endsWith('100k')) {
4561 return claude_100k_max;
4562 }
4563 else if (value.includes('claude')) {
4564 return claude_max;
4565 }
4566 else if (value.includes('gpt-3.5-turbo-1106')) {
4567 return max_16k;
4568 }
4569 else if (value.includes('gpt-3.5-turbo-16k')) {
4570 return max_16k;
4571 }
4572 else if (value.includes('gpt-3.5')) {
4573 return max_4k;
4574 }
4575 else if (value.includes('gpt-4-1106')) {
4576 return max_128k;
4577 }
4578 else if (value.includes('gpt-4-vision')) {
4579 return max_128k;
4580 }
4581 else if (value.includes('gpt-4-32k')) {
4582 return max_32k;
4583 }
4584 else if (value.includes('gpt-4')) {
4585 return max_8k;
4586 }
4587 else if (value.includes('palm-2')) {
4588 return max_8k;
4589 }
4590 else if (value.includes('GPT-NeoXT')) {
4591 return max_2k;
4592 }
4593 else {
4594 // default to gpt-3 (4095 tokens)
4595 return max_4k;
4596 }
4597}
4598
4599/**4394/**
4600 * Get the maximum context size for the Mistral model4395 * Get the maximum context size for the Mistral model
4601 * @param {string} model Model identifier4396 * @param {string} model Model identifier
@@ -4744,11 +4539,6 @@ async function onModelChange() {
47444539
4745 }4540 }
47464541
4747 if ($(this).is('#model_windowai_select')) {
4748 console.log('WindowAI model changed to', value);
4749 oai_settings.windowai_model = value;
4750 }
4751
4752 if ($(this).is('#model_openai_select')) {4542 if ($(this).is('#model_openai_select')) {
4753 console.log('OpenAI model changed to', value);4543 console.log('OpenAI model changed to', value);
4754 oai_settings.openai_model = value;4544 oai_settings.openai_model = value;
@@ -4956,25 +4746,6 @@ async function onModelChange() {
4956 $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');4746 $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');
4957 }4747 }
49584748
4959 if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
4960 if (value == '' && 'ai' in window) {
4961 value = (await window.ai.getCurrentModel()) || '';
4962 }
4963
4964 $('#openai_max_context').attr('max', getMaxContextWindowAI(value));
4965 oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
4966 $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
4967
4968 if (value.includes('claude') || value.includes('palm-2')) {
4969 oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai);
4970 $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');
4971 }
4972 else {
4973 oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
4974 $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
4975 }
4976 }
4977
4978 if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) {4749 if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) {
4979 $('#openai_max_context').attr('max', getMaxContextOpenAI(value));4750 $('#openai_max_context').attr('max', getMaxContextOpenAI(value));
4980 oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));4751 oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));
@@ -5219,10 +4990,6 @@ function onReverseProxyInput() {
5219async function onConnectButtonClick(e) {4990async function onConnectButtonClick(e) {
5220 e.stopPropagation();4991 e.stopPropagation();
52214992
5222 if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
5223 return await getStatusOpen();
5224 }
5225
5226 if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) {4993 if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) {
5227 const api_key_openrouter = String($('#api_key_openrouter').val()).trim();4994 const api_key_openrouter = String($('#api_key_openrouter').val()).trim();
52284995
@@ -5483,9 +5250,6 @@ function toggleChatCompletionForms() {
5483 $('#model_openai_select').trigger('change');5250 $('#model_openai_select').trigger('change');
5484 }5251 }
5485 }5252 }
5486 else if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
5487 $('#model_windowai_select').trigger('change');
5488 }
5489 else if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {5253 else if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
5490 $('#model_scale_select').trigger('change');5254 $('#model_scale_select').trigger('change');
5491 }5255 }
@@ -6456,7 +6220,6 @@ export function initOpenAI() {
6456 $('#openai_reverse_proxy').on('input', onReverseProxyInput);6220 $('#openai_reverse_proxy').on('input', onReverseProxyInput);
6457 $('#model_openai_select').on('change', onModelChange);6221 $('#model_openai_select').on('change', onModelChange);
6458 $('#model_claude_select').on('change', onModelChange);6222 $('#model_claude_select').on('change', onModelChange);
6459 $('#model_windowai_select').on('change', onModelChange);
6460 $('#model_scale_select').on('change', onModelChange);6223 $('#model_scale_select').on('change', onModelChange);
6461 $('#model_google_select').on('change', onModelChange);6224 $('#model_google_select').on('change', onModelChange);
6462 $('#model_vertexai_select').on('change', onModelChange);6225 $('#model_vertexai_select').on('change', onModelChange);
public/scripts/slash-commands.js+0 -1
@@ -4791,7 +4791,6 @@ function getModelOptions(quiet) {
4791 { id: 'featherless_model', api: 'textgenerationwebui', type: textgen_types.FEATHERLESS },4791 { id: 'featherless_model', api: 'textgenerationwebui', type: textgen_types.FEATHERLESS },
4792 { id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },4792 { id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },
4793 { id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },4793 { id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },
4794 { id: 'model_windowai_select', api: 'openai', type: chat_completion_sources.WINDOWAI },
4795 { id: 'model_openrouter_select', api: 'openai', type: chat_completion_sources.OPENROUTER },4794 { id: 'model_openrouter_select', api: 'openai', type: chat_completion_sources.OPENROUTER },
4796 { id: 'model_ai21_select', api: 'openai', type: chat_completion_sources.AI21 },4795 { id: 'model_ai21_select', api: 'openai', type: chat_completion_sources.AI21 },
4797 { id: 'model_google_select', api: 'openai', type: chat_completion_sources.MAKERSUITE },4796 { id: 'model_google_select', api: 'openai', type: chat_completion_sources.MAKERSUITE },
public/scripts/tokenizers.js+0 -16
@@ -595,22 +595,6 @@ export function getTokenizerModel() {
595 return deepseekTokenizer;595 return deepseekTokenizer;
596 }596 }
597597
598 // Select correct tokenizer for WindowAI proxies
599 if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI && oai_settings.windowai_model) {
600 if (oai_settings.windowai_model.includes('gpt-4')) {
601 return gpt4Tokenizer;
602 }
603 else if (oai_settings.windowai_model.includes('gpt-3.5-turbo')) {
604 return turboTokenizer;
605 }
606 else if (oai_settings.windowai_model.includes('claude')) {
607 return claudeTokenizer;
608 }
609 else if (oai_settings.windowai_model.includes('GPT-NeoXT')) {
610 return gpt2Tokenizer;
611 }
612 }
613
614 // And for OpenRouter (if not a site model, then it's impossible to determine the tokenizer)598 // And for OpenRouter (if not a site model, then it's impossible to determine the tokenizer)
615 if (main_api == 'openai' && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER && oai_settings.openrouter_model ||599 if (main_api == 'openai' && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER && oai_settings.openrouter_model ||
616 main_api == 'textgenerationwebui' && textgen_settings.type === textgen_types.OPENROUTER && textgen_settings.openrouter_model) {600 main_api == 'textgenerationwebui' && textgen_settings.type === textgen_types.OPENROUTER && textgen_settings.openrouter_model) {
src/constants.js+0 -1
@@ -163,7 +163,6 @@ export const GEMINI_SAFETY = [
163163
164export const CHAT_COMPLETION_SOURCES = {164export const CHAT_COMPLETION_SOURCES = {
165 OPENAI: 'openai',165 OPENAI: 'openai',
166 WINDOWAI: 'windowai',
167 CLAUDE: 'claude',166 CLAUDE: 'claude',
168 SCALE: 'scale',167 SCALE: 'scale',
169 OPENROUTER: 'openrouter',168 OPENROUTER: 'openrouter',