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 @@
22 "chat_completion_source": "openai",
33 "openai_model": "gpt-4-turbo",
44 "claude_model": "claude-3-5-sonnet-20240620",
5- "windowai_model": "",
65 "openrouter_model": "OR_Website",
76 "openrouter_use_fallback": false,
87 "openrouter_group_models": false,
default/content/settings.json+0 -1
@@ -624,7 +624,6 @@
624624 "openai_model": "gpt-4-turbo",
625625 "claude_model": "claude-3-5-sonnet-20240620",
626626 "ai21_model": "jamba-large",
627- "windowai_model": "",
628627 "openrouter_model": "OR_Website",
629628 "reverse_proxy": "",
630629 "chat_completion_source": "openai",
public/index.html+1 -22
@@ -691,7 +691,7 @@
691691 </span>
692692 </div>
693693 </div>
694694 <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">
695695 <div class="range-block-title" data-i18n="Temperature">
696696 Temperature
697697 </div>
@@ -2803,7 +2803,6 @@
28032803 <option value="perplexity">Perplexity</option>
28042804 <option value="pollinations">Pollinations</option>
28052805 <option value="scale">Scale</option>
2806- <option value="windowai">Window AI</option>
28072806 <option value="xai">xAI (Grok)</option>
28082807 </optgroup>
28092808 </select>
@@ -3031,26 +3030,6 @@
30313030 </select>
30323031 </div>
30333032 </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>
30543033 <form id="openrouter_form" data-source="openrouter" action="javascript:void(null);" method="post" enctype="multipart/form-data">
30553034 <h4 data-i18n="OpenRouter API Key">OpenRouter API Key</h4>
30563035 <div>
public/locales/ru-ru.json+0 -2
@@ -1749,8 +1749,6 @@
17491749 "dot quota_error": "имеется достаточно кредитов.",
17501750 "If you have sufficient credits, please try again later.": "Если кредитов достаточно, то повторите попытку позднее.",
17511751 "Proxy preset '${0}' not found": "Пресет '${0}' не найден",
1752- "Window.ai returned an error": "Window.ai ответил ошибкой",
1753- "Extension is not installed": "Расширение не установлено",
17541752 "Update or remove your reverse proxy settings.": "Измените или удалите ваши настройки прокси.",
17551753 "An error occurred while importing prompts. More info available in console.": "В процессе импорта произошла ошибка. Подробную информацию см. в консоли.",
17561754 "Could not import prompts. Export failed validation.": "Не удалось импортировать промпты. Не пройдена валидация при экспорте.",
public/script.js+0 -4
@@ -6785,10 +6785,6 @@ export function changeMainAPI() {
67856785 main_api = selectedVal;
67866786 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-
67926788 if (main_api == 'koboldhorde') {
67936789 getStatusHorde();
67946790 getHordeModels(true);
public/scripts/RossAscends-mods.js+0 -1
@@ -398,7 +398,6 @@ function RA_autoconnect(PrevApi) {
398398 if (((secret_state[SECRET_KEYS.OPENAI] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.OPENAI)
399399 || ((secret_state[SECRET_KEYS.CLAUDE] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.CLAUDE)
400400 || ((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)
402401 || (secret_state[SECRET_KEYS.OPENROUTER] && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER)
403402 || (secret_state[SECRET_KEYS.AI21] && oai_settings.chat_completion_source == chat_completion_sources.AI21)
404403 || (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
172172export const chat_completion_sources = {
173173 OPENAI: 'openai',
174- WINDOWAI: 'windowai',
175174 CLAUDE: 'claude',
176175 SCALE: 'scale',
177176 OPENROUTER: 'openrouter',
@@ -261,7 +260,6 @@ export const settingsToUpdate = {
261260 max_context_unlocked: ['#oai_max_context_unlocked', 'max_context_unlocked', true, false],
262261 openai_model: ['#model_openai_select', 'openai_model', false, true],
263262 claude_model: ['#model_claude_select', 'claude_model', false, true],
264- windowai_model: ['#model_windowai_select', 'windowai_model', false, true],
265263 openrouter_model: ['#model_openrouter_select', 'openrouter_model', false, true],
266264 openrouter_use_fallback: ['#openrouter_use_fallback', 'openrouter_use_fallback', true, true],
267265 openrouter_group_models: ['#openrouter_group_models', 'openrouter_group_models', false, true],
@@ -383,7 +381,6 @@ const default_settings = {
383381 custom_include_body: '',
384382 custom_exclude_body: '',
385383 custom_include_headers: '',
386- windowai_model: '',
387384 openrouter_model: openrouter_website_model,
388385 openrouter_use_fallback: false,
389386 openrouter_group_models: false,
@@ -473,7 +470,6 @@ const oai_settings = {
473470 custom_include_body: '',
474471 custom_exclude_body: '',
475472 custom_include_headers: '',
476- windowai_model: '',
477473 openrouter_model: openrouter_website_model,
478474 openrouter_use_fallback: false,
479475 openrouter_group_models: false,
@@ -1591,97 +1587,6 @@ function checkModerationError(data, { quiet = false } = {}) {
15911587 }
15921588}
15931589
1594-async 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-
16851590/**
16861591 * Gets the API model for the selected chat completion source.
16871592 * @param {string} source If it's set, ignores active source
@@ -1694,8 +1599,6 @@ export function getChatCompletionModel(source = null) {
16941599 return oai_settings.claude_model;
16951600 case chat_completion_sources.OPENAI:
16961601 return oai_settings.openai_model;
1697- case chat_completion_sources.WINDOWAI:
1698- return oai_settings.windowai_model;
16991602 case chat_completion_sources.SCALE:
17001603 return '';
17011604 case chat_completion_sources.MAKERSUITE:
@@ -2229,12 +2132,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
22292132 const useLogprobs = !!power_user.request_token_probabilities;
22302133 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-
22382135 const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.SCALE, chat_completion_sources.CUSTOM];
22392136 if (oai_settings.bias_preset_selected
22402137 && logitBiasSources.includes(oai_settings.chat_completion_source)
@@ -2677,37 +2574,6 @@ function parseOpenAITextLogprobs(logprobs) {
26772574 });
26782575}
26792576
2680-
2681-function handleWindowError(err) {
2682- const text = parseWindowError(err);
2683- toastr.error(text, t`Window.ai returned an error`);
2684- throw err;
2685-}
2686-
2687-function 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-
27112577async function calculateLogitBias() {
27122578 const body = JSON.stringify(oai_settings.bias_presets[oai_settings.bias_preset_selected]);
27132579 let result = {};
@@ -3554,7 +3420,6 @@ function loadOpenAISettings(data, settings) {
35543420 oai_settings.personality_format = settings.personality_format ?? default_settings.personality_format;
35553421 oai_settings.group_nudge_prompt = settings.group_nudge_prompt ?? default_settings.group_nudge_prompt;
35563422 oai_settings.claude_model = settings.claude_model ?? default_settings.claude_model;
3557- oai_settings.windowai_model = settings.windowai_model ?? default_settings.windowai_model;
35583423 oai_settings.openrouter_model = settings.openrouter_model ?? default_settings.openrouter_model;
35593424 oai_settings.openrouter_group_models = settings.openrouter_group_models ?? default_settings.openrouter_group_models;
35603425 oai_settings.openrouter_sort_models = settings.openrouter_sort_models ?? default_settings.openrouter_sort_models;
@@ -3648,8 +3513,6 @@ function loadOpenAISettings(data, settings) {
36483513 $(`#model_openai_select option[value="${oai_settings.openai_model}"`).prop('selected', true);
36493514 $('#model_claude_select').val(oai_settings.claude_model);
36503515 $(`#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);
36533516 $('#model_google_select').val(oai_settings.google_model);
36543517 $(`#model_google_select option[value="${oai_settings.google_model}"`).prop('selected', true);
36553518 $('#model_vertexai_select').val(oai_settings.vertexai_model);
@@ -3837,21 +3700,6 @@ function setContinuePostfixControls() {
38373700}
38383701
38393702async 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-
38553703 const noValidateSources = [
38563704 chat_completion_sources.SCALE,
38573705 chat_completion_sources.CLAUDE,
@@ -3936,15 +3784,6 @@ async function getStatusOpen() {
39363784 return resultCheckStatus();
39373785}
39383786
3939-function 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-
39483787/**
39493788 * Persist a settings preset with the given name
39503789 *
@@ -3958,7 +3797,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
39583797 chat_completion_source: settings.chat_completion_source,
39593798 openai_model: settings.openai_model,
39603799 claude_model: settings.claude_model,
3961- windowai_model: settings.windowai_model,
39623800 openrouter_model: settings.openrouter_model,
39633801 openrouter_use_fallback: settings.openrouter_use_fallback,
39643802 openrouter_group_models: settings.openrouter_group_models,
@@ -4553,49 +4391,6 @@ function getMaxContextOpenAI(value) {
45534391 }
45544392}
45554393
4556-function 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-
45994394/**
46004395 * Get the maximum context size for the Mistral model
46014396 * @param {string} model Model identifier
@@ -4744,11 +4539,6 @@ async function onModelChange() {
47444539
47454540 }
47464541
4747- if ($(this).is('#model_windowai_select')) {
4748- console.log('WindowAI model changed to', value);
4749- oai_settings.windowai_model = value;
4750- }
4751-
47524542 if ($(this).is('#model_openai_select')) {
47534543 console.log('OpenAI model changed to', value);
47544544 oai_settings.openai_model = value;
@@ -4956,25 +4746,6 @@ async function onModelChange() {
49564746 $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');
49574747 }
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-
49784749 if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) {
49794750 $('#openai_max_context').attr('max', getMaxContextOpenAI(value));
49804751 oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));
@@ -5219,10 +4990,6 @@ function onReverseProxyInput() {
52194990async function onConnectButtonClick(e) {
52204991 e.stopPropagation();
52214992
5222- if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
5223- return await getStatusOpen();
5224- }
5225-
52264993 if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) {
52274994 const api_key_openrouter = String($('#api_key_openrouter').val()).trim();
52284995
@@ -5483,9 +5250,6 @@ function toggleChatCompletionForms() {
54835250 $('#model_openai_select').trigger('change');
54845251 }
54855252 }
5486- else if (oai_settings.chat_completion_source == chat_completion_sources.WINDOWAI) {
5487- $('#model_windowai_select').trigger('change');
5488- }
54895253 else if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
54905254 $('#model_scale_select').trigger('change');
54915255 }
@@ -6456,7 +6220,6 @@ export function initOpenAI() {
64566220 $('#openai_reverse_proxy').on('input', onReverseProxyInput);
64576221 $('#model_openai_select').on('change', onModelChange);
64586222 $('#model_claude_select').on('change', onModelChange);
6459- $('#model_windowai_select').on('change', onModelChange);
64606223 $('#model_scale_select').on('change', onModelChange);
64616224 $('#model_google_select').on('change', onModelChange);
64626225 $('#model_vertexai_select').on('change', onModelChange);
public/scripts/slash-commands.js+0 -1
@@ -4791,7 +4791,6 @@ function getModelOptions(quiet) {
47914791 { id: 'featherless_model', api: 'textgenerationwebui', type: textgen_types.FEATHERLESS },
47924792 { id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },
47934793 { id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },
4794- { id: 'model_windowai_select', api: 'openai', type: chat_completion_sources.WINDOWAI },
47954794 { id: 'model_openrouter_select', api: 'openai', type: chat_completion_sources.OPENROUTER },
47964795 { id: 'model_ai21_select', api: 'openai', type: chat_completion_sources.AI21 },
47974796 { id: 'model_google_select', api: 'openai', type: chat_completion_sources.MAKERSUITE },
public/scripts/tokenizers.js+0 -16
@@ -595,22 +595,6 @@ export function getTokenizerModel() {
595595 return deepseekTokenizer;
596596 }
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-
614598 // And for OpenRouter (if not a site model, then it's impossible to determine the tokenizer)
615599 if (main_api == 'openai' && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER && oai_settings.openrouter_model ||
616600 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
164164export const CHAT_COMPLETION_SOURCES = {
165165 OPENAI: 'openai',
166- WINDOWAI: 'windowai',
167166 CLAUDE: 'claude',
168167 SCALE: 'scale',
169168 OPENROUTER: 'openrouter',