diff --git a/public/index.html b/public/index.html index 9800ffbba..60726aacf 100644 --- a/public/index.html +++ b/public/index.html @@ -2437,7 +2437,7 @@ - + @@ -2800,7 +2800,7 @@
-

MakerSuite API Key

+

Google AI Studio API Key

diff --git a/public/locales/ar-sa.json b/public/locales/ar-sa.json index 7758ce879..224bb480f 100644 --- a/public/locales/ar-sa.json +++ b/public/locales/ar-sa.json @@ -390,7 +390,7 @@ "Alt Method": "طريقة بديلة", "AI21 API Key": "مفتاح API لـ AI21", "AI21 Model": "نموذج AI21", - "MakerSuite API Key": "مفتاح واجهة برمجة تطبيقات MakerSuite", + "Google AI Studio API Key": "مفتاح واجهة برمجة تطبيقات Google AI Studio", "Google Model": "نموذج جوجل", "MistralAI API Key": "مفتاح واجهة برمجة التطبيقات MistralAI", "MistralAI Model": "نموذج ميسترال آي آي", diff --git a/public/locales/de-de.json b/public/locales/de-de.json index 95e496f44..7932eed10 100644 --- a/public/locales/de-de.json +++ b/public/locales/de-de.json @@ -390,7 +390,7 @@ "Alt Method": "Alternative Methode", "AI21 API Key": "AI21 API-Schlüssel", "AI21 Model": "AI21-Modell", - "MakerSuite API Key": "MakerSuite API-Schlüssel", + "Google AI Studio API Key": "Google AI Studio API-Schlüssel", "Google Model": "Google-Modell", "MistralAI API Key": "MistralAI API-Schlüssel", "MistralAI Model": "MistralAI-Modell", diff --git a/public/locales/es-es.json b/public/locales/es-es.json index 126c8efea..e03f0ca9b 100644 --- a/public/locales/es-es.json +++ b/public/locales/es-es.json @@ -390,7 +390,7 @@ "Alt Method": "Método alternativo", "AI21 API Key": "Clave API de AI21", "AI21 Model": "Modelo de AI21", - "MakerSuite API Key": "Clave API de MakerSuite", + "Google AI Studio API Key": "Clave API de Google AI Studio", "Google Model": "Modelo de Google", "MistralAI API Key": "Clave API de MistralAI", "MistralAI Model": "Modelo MistralAI", diff --git a/public/locales/fr-fr.json b/public/locales/fr-fr.json index f24eaa295..1d4403460 100644 --- a/public/locales/fr-fr.json +++ b/public/locales/fr-fr.json @@ -390,7 +390,7 @@ "Alt Method": "Méthode alternative", "AI21 API Key": "Clé API AI21", "AI21 Model": "Modèle AI21", - "MakerSuite API Key": "Clé API MakerSuite", + "Google AI Studio API Key": "Clé API Google AI Studio", "Google Model": "Modèle Google", "MistralAI API Key": "Clé API MistralAI", "MistralAI Model": "Modèle MistralAI", diff --git a/public/locales/is-is.json b/public/locales/is-is.json index 41d9a966d..5f36b6277 100644 --- a/public/locales/is-is.json +++ b/public/locales/is-is.json @@ -390,7 +390,7 @@ "Alt Method": "Aðferð Bakmenn", "AI21 API Key": "Lykill API fyrir AI21", "AI21 Model": "AI21 Módel", - "MakerSuite API Key": "MakerSuite API lykill", + "Google AI Studio API Key": "Google AI Studio API lykill", "Google Model": "Google líkan", "MistralAI API Key": "MistralAI API lykill", "MistralAI Model": "MistralAI líkan", diff --git a/public/locales/it-it.json b/public/locales/it-it.json index bad81f01e..53d969dcc 100644 --- a/public/locales/it-it.json +++ b/public/locales/it-it.json @@ -390,7 +390,7 @@ "Alt Method": "Metodo alternativo", "AI21 API Key": "Chiave API di AI21", "AI21 Model": "Modello AI21", - "MakerSuite API Key": "Chiave API MakerSuite", + "Google AI Studio API Key": "Chiave API Google AI Studio", "Google Model": "Modello Google", "MistralAI API Key": "Chiave API MistralAI", "MistralAI Model": "Modello MistralAI", diff --git a/public/locales/ja-jp.json b/public/locales/ja-jp.json index 51e4da5c8..a38abf9a5 100644 --- a/public/locales/ja-jp.json +++ b/public/locales/ja-jp.json @@ -390,7 +390,7 @@ "Alt Method": "代替手法", "AI21 API Key": "AI21のAPIキー", "AI21 Model": "AI21モデル", - "MakerSuite API Key": "MakerSuite APIキー", + "Google AI Studio API Key": "Google AI Studio APIキー", "Google Model": "Google モデル", "MistralAI API Key": "MistralAI API キー", "MistralAI Model": "MistralAI モデル", diff --git a/public/locales/ko-kr.json b/public/locales/ko-kr.json index 2ead98ace..1b23dd8cd 100644 --- a/public/locales/ko-kr.json +++ b/public/locales/ko-kr.json @@ -390,7 +390,7 @@ "Alt Method": "대체 방법", "AI21 API Key": "AI21 API 키", "AI21 Model": "AI21 모델", - "MakerSuite API Key": "MakerSuite API 키", + "Google AI Studio API Key": "Google AI Studio API 키", "Google Model": "구글 모델", "MistralAI API Key": "MistralAI API 키", "MistralAI Model": "MistralAI 모델", diff --git a/public/locales/pt-pt.json b/public/locales/pt-pt.json index d671fea47..a287d4879 100644 --- a/public/locales/pt-pt.json +++ b/public/locales/pt-pt.json @@ -390,7 +390,7 @@ "Alt Method": "Método Alternativo", "AI21 API Key": "Chave da API AI21", "AI21 Model": "Modelo AI21", - "MakerSuite API Key": "Chave API MakerSuite", + "Google AI Studio API Key": "Chave API Google AI Studio", "Google Model": "Modelo Google", "MistralAI API Key": "Chave de API MistralAI", "MistralAI Model": "Modelo MistralAI", diff --git a/public/locales/ru-ru.json b/public/locales/ru-ru.json index 101315211..17a0a406a 100644 --- a/public/locales/ru-ru.json +++ b/public/locales/ru-ru.json @@ -722,7 +722,7 @@ "Proxy Server URL": "Адрес прокси-сервера", "MistralAI Model": "Модель MistralAI", "MistralAI API Key": "Ключ от API MistralAI", - "MakerSuite API Key": "Ключ от API MakerSuite", + "Google AI Studio API Key": "Ключ от API Google AI Studio", "Google Model": "Модель Google", "Cohere API Key": "Ключ от API Cohere", "Cohere Model": "Модель Cohere", diff --git a/public/locales/uk-ua.json b/public/locales/uk-ua.json index 12290f996..4c002009e 100644 --- a/public/locales/uk-ua.json +++ b/public/locales/uk-ua.json @@ -390,7 +390,7 @@ "Alt Method": "Альтернативний метод", "AI21 API Key": "Ключ API для AI21", "AI21 Model": "Модель AI21", - "MakerSuite API Key": "Ключ API MakerSuite", + "Google AI Studio API Key": "Ключ API Google AI Studio", "Google Model": "Модель Google", "MistralAI API Key": "Ключ API MistralAI", "MistralAI Model": "Модель MistralAI", diff --git a/public/locales/vi-vn.json b/public/locales/vi-vn.json index c90edf84f..bed29e192 100644 --- a/public/locales/vi-vn.json +++ b/public/locales/vi-vn.json @@ -390,7 +390,7 @@ "Alt Method": "Phương pháp thay thế", "AI21 API Key": "Khóa API của AI21", "AI21 Model": "Mô hình AI21", - "MakerSuite API Key": "Khóa API MakerSuite", + "Google AI Studio API Key": "Khóa API Google AI Studio", "Google Model": "Mô hình Google", "MistralAI API Key": "Khóa API MistralAI", "MistralAI Model": "Mô hình MistralAI", diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 5b83fbe8c..9c1d346ed 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -406,7 +406,7 @@ "Alt Method": "备用方法", "AI21 API Key": "AI21 API 密钥", "AI21 Model": "AI21 模型", - "MakerSuite API Key": "MakerSuite API 密钥", + "Google AI Studio API Key": "Google AI Studio API 密钥", "Google Model": "Google 模型", "MistralAI API Key": "MistralAI API 密钥", "MistralAI Model": "MistralAI 模型", diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index 5744e5b93..20abdeba8 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -391,7 +391,7 @@ "Alt Method": "替代方法", "AI21 API Key": "AI21 API 金鑰", "AI21 Model": "AI21 模型", - "MakerSuite API Key": "MakerSuite API 金鑰", + "Google AI Studio API Key": "Google AI Studio API 金鑰", "Google Model": "Google 模型", "MistralAI API Key": "MistralAI API 金鑰", "MistralAI Model": "MistralAI 模型", diff --git a/public/script.js b/public/script.js index c64f10f7b..9e5029dea 100644 --- a/public/script.js +++ b/public/script.js @@ -242,7 +242,7 @@ import { DragAndDropHandler } from './scripts/dragdrop.js'; import { INTERACTABLE_CONTROL_CLASS, initKeyboard } from './scripts/keyboard.js'; import { initDynamicStyles } from './scripts/dynamic-styles.js'; import { SlashCommandEnumValue, enumTypes } from './scripts/slash-commands/SlashCommandEnumValue.js'; -import { enumIcons } from './scripts/slash-commands/SlashCommandCommonEnumsProvider.js'; +import { commonEnumProviders, enumIcons } from './scripts/slash-commands/SlashCommandCommonEnumsProvider.js'; //exporting functions and vars for mods export { @@ -1879,8 +1879,12 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId) { } if (Number(messageId) === 0 && !isSystem && !isUser) { + const mesBeforeReplace = mes; + const chatMessage = chat[messageId]; mes = substituteParams(mes, undefined, ch_name); - chat[messageId] && (chat[messageId].mes = mes); + if (chatMessage && chatMessage.mes === mesBeforeReplace && chatMessage.extra?.display_text !== mesBeforeReplace) { + chatMessage.mes = mes; + } } mesForShowdownParse = mes; @@ -8380,6 +8384,12 @@ const CONNECT_API_MAP = { button: '#api_button_openai', source: chat_completion_sources.OPENAI, }, + // Google alias + 'google': { + selected: 'openai', + button: '#api_button_openai', + source: chat_completion_sources.MAKERSUITE, + }, // OpenRouter special naming, to differentiate between chat comp and text comp 'openrouter': { selected: 'openai', @@ -8465,7 +8475,7 @@ async function disableInstructCallback() { /** * @param {string} text API name */ -async function connectAPISlash(_, text) { +async function connectAPISlash(args, text) { if (!text.trim()) { for (const [key, config] of Object.entries(CONNECT_API_MAP)) { if (config.selected !== main_api) continue; @@ -8488,12 +8498,15 @@ async function connectAPISlash(_, text) { return key; } + + console.error('FIXME: The current API is not in the API map'); + return ''; } const apiConfig = CONNECT_API_MAP[text.toLowerCase()]; if (!apiConfig) { toastr.error(`Error: ${text} is not a valid API`); - return; + return ''; } $(`#main_api option[value='${apiConfig.selected || text}']`).prop('selected', true); @@ -8513,14 +8526,18 @@ async function connectAPISlash(_, text) { $(apiConfig.button).trigger('click'); } - toastr.info(`API set to ${text}, trying to connect..`); + const quiet = isTrueBoolean(args?.quiet); + const toast = quiet ? jQuery() : toastr.info(`API set to ${text}, trying to connect..`); try { await waitUntilCondition(() => online_status !== 'no_connection', 10000, 100); console.log('Connection successful'); } catch { - console.log('Could not connect after 5 seconds, skipping.'); + console.log('Could not connect after 10 seconds, skipping.'); } + + toastr.clear(toast); + return text; } /** @@ -8979,6 +8996,15 @@ jQuery(async function () { name: 'api', callback: connectAPISlash, returns: 'the current API', + namedArgumentList: [ + SlashCommandNamedArgument.fromProps({ + name: 'quiet', + description: 'Suppress the toast message on connection', + typeList: [ARGUMENT_TYPE.BOOLEAN], + defaultValue: 'false', + enumList: commonEnumProviders.boolean('trueFalse')(), + }), + ], unnamedArgumentList: [ SlashCommandArgument.fromProps({ description: 'API to connect to', diff --git a/public/scripts/extensions/caption/settings.html b/public/scripts/extensions/caption/settings.html index 7f6851a10..b30db1f6c 100644 --- a/public/scripts/extensions/caption/settings.html +++ b/public/scripts/extensions/caption/settings.html @@ -20,7 +20,7 @@ - + diff --git a/public/scripts/extensions/memory/index.js b/public/scripts/extensions/memory/index.js index ac8252583..9c9d86a9c 100644 --- a/public/scripts/extensions/memory/index.js +++ b/public/scripts/extensions/memory/index.js @@ -1,4 +1,4 @@ -import { getStringHash, debounce, waitUntilCondition, extractAllWords } from '../../utils.js'; +import { getStringHash, debounce, waitUntilCondition, extractAllWords, isTrueBoolean } from '../../utils.js'; import { getContext, getApiUrl, extension_settings, doExtrasFetch, modules, renderExtensionTemplateAsync } from '../../extensions.js'; import { activateSendButtons, @@ -26,6 +26,7 @@ import { SlashCommand } from '../../slash-commands/SlashCommand.js'; import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; import { MacrosParser } from '../../macros.js'; import { countWebLlmTokens, generateWebLlmChatPrompt, getWebLlmContextSize, isWebLlmSupported } from '../shared.js'; +import { commonEnumProviders } from '../../slash-commands/SlashCommandCommonEnumsProvider.js'; export { MODULE_NAME }; const MODULE_NAME = '1_memory'; @@ -456,7 +457,12 @@ async function onChatEvent() { } } -async function forceSummarizeChat() { +/** + * Forces a summary generation for the current chat. + * @param {boolean} quiet If an informational toast should be displayed + * @returns {Promise} Summarized text + */ +async function forceSummarizeChat(quiet) { if (extension_settings.memory.source === summary_sources.extras) { toastr.warning('Force summarization is not supported for Extras API'); return; @@ -471,7 +477,7 @@ async function forceSummarizeChat() { return ''; } - const toast = toastr.info('Summarizing chat...', 'Please wait', { timeOut: 0, extendedTimeOut: 0 }); + const toast = quiet ? jQuery() : toastr.info('Summarizing chat...', 'Please wait', { timeOut: 0, extendedTimeOut: 0 }); const value = extension_settings.memory.source === summary_sources.main ? await summarizeChatMain(context, true, skipWIAN) : await summarizeChatWebLLM(context, true); @@ -494,9 +500,10 @@ async function forceSummarizeChat() { async function summarizeCallback(args, text) { text = text.trim(); - // Using forceSummarizeChat to summarize the current chat + // Summarize the current chat if no text provided if (!text) { - return await forceSummarizeChat(); + const quiet = isTrueBoolean(args.quiet); + return await forceSummarizeChat(quiet); } const source = args.source || extension_settings.memory.source; @@ -1005,7 +1012,7 @@ function setupListeners() { $('#memory_prompt_words').off('click').on('input', onMemoryPromptWordsInput); $('#memory_prompt_interval').off('click').on('input', onMemoryPromptIntervalInput); $('#memory_prompt').off('click').on('input', onMemoryPromptInput); - $('#memory_force_summarize').off('click').on('click', forceSummarizeChat); + $('#memory_force_summarize').off('click').on('click', () => forceSummarizeChat(false)); $('#memory_template').off('click').on('input', onMemoryTemplateInput); $('#memory_depth').off('click').on('input', onMemoryDepthInput); $('#memory_role').off('click').on('input', onMemoryRoleInput); @@ -1055,6 +1062,13 @@ jQuery(async function () { typeList: [ARGUMENT_TYPE.STRING], defaultValue: '', }), + SlashCommandNamedArgument.fromProps({ + name: 'quiet', + description: 'suppress the toast message when summarizing the chat', + typeList: [ARGUMENT_TYPE.BOOLEAN], + defaultValue: 'false', + enumList: commonEnumProviders.boolean('trueFalse')(), + }), ], unnamedArgumentList: [ new SlashCommandArgument('text to summarize', [ARGUMENT_TYPE.STRING], false, false, ''), diff --git a/public/scripts/extensions/shared.js b/public/scripts/extensions/shared.js index 706acea62..70dbca631 100644 --- a/public/scripts/extensions/shared.js +++ b/public/scripts/extensions/shared.js @@ -141,7 +141,7 @@ function throwIfInvalidModel(useReverseProxy) { } if (extension_settings.caption.multimodal_api === 'google' && !secret_state[SECRET_KEYS.MAKERSUITE] && !useReverseProxy) { - throw new Error('MakerSuite API key is not set.'); + throw new Error('Google AI Studio API key is not set.'); } if (extension_settings.caption.multimodal_api === 'ollama' && !textgenerationwebui_settings.server_urls[textgen_types.OLLAMA]) { diff --git a/public/scripts/extensions/vectors/settings.html b/public/scripts/extensions/vectors/settings.html index 57fd680e2..0dc626e53 100644 --- a/public/scripts/extensions/vectors/settings.html +++ b/public/scripts/extensions/vectors/settings.html @@ -12,7 +12,7 @@