Vector Storage: change NomicAI key input
| @@ -30,6 +30,7 @@ import { textgen_types, textgenerationwebui_settings } from '../../textgen-setti | ||
| 30 | 30 | import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js'; |
| 31 | 31 | import { SlashCommand } from '../../slash-commands/SlashCommand.js'; |
| 32 | 32 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; |
| 33 | +import { callGenericPopup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js'; | |
| 33 | 34 | |
| 34 | 35 | const MODULE_NAME = 'vectors'; |
| 35 | 36 | |
| @@ -1299,11 +1300,30 @@ jQuery(async () => { | ||
| 1299 | 1300 | saveSettingsDebounced(); |
| 1300 | 1301 | toggleSettings(); |
| 1301 | 1302 | }); |
| 1302 | 1303 | $('#api_key_nomicai').on('changeclick', async () => { |
| 1303 | - const nomicKey = String($('#api_key_nomicai').val()).trim(); | |
| 1304 | + const popupText = 'NomicAI API Key:'; | |
| 1304 | - if (nomicKey.length) { | |
| 1305 | + const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT, '', { | |
| 1305 | - writeSecret(SECRET_KEYS.NOMICAI, nomicKey); | |
| 1306 | + customButtons: [{ | |
| 1307 | + text: 'Remove Key', | |
| 1308 | + appendAtEnd: true, | |
| 1309 | + result: POPUP_RESULT.NEGATIVE, | |
| 1310 | + action: async () => { | |
| 1311 | + await writeSecret(SECRET_KEYS.NOMICAI, ''); | |
| 1312 | + toastr.success('API Key removed'); | |
| 1313 | + $('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]); | |
| 1314 | + saveSettingsDebounced(); | |
| 1315 | + }, | |
| 1316 | + }], | |
| 1317 | + }); | |
| 1318 | + | |
| 1319 | + if (!key) { | |
| 1320 | + return; | |
| 1306 | 1321 | } |
| 1322 | + | |
| 1323 | + await writeSecret(SECRET_KEYS.NOMICAI, String(key)); | |
| 1324 | + $('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]); | |
| 1325 | + | |
| 1326 | + toastr.success('API Key saved'); | |
| 1307 | 1327 | saveSettingsDebounced(); |
| 1308 | 1328 | }); |
| 1309 | 1329 | $('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => { |
| @@ -1531,9 +1551,7 @@ jQuery(async () => { | ||
| 1531 | 1551 | $('#dialogue_popup_input').val(presetModel); |
| 1532 | 1552 | }); |
| 1533 | 1553 | |
| 1534 | 1554 | const validSecret =$('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]); |
| 1535 | - const placeholder = validSecret ? '✔️ Key saved' : '❌ Missing key'; | |
| 1536 | - $('#api_key_nomicai').attr('placeholder', placeholder); | |
| 1537 | 1555 | |
| 1538 | 1556 | toggleSettings(); |
| 1539 | 1557 | eventSource.on(event_types.MESSAGE_DELETED, onChatEvent); |
| @@ -103,17 +103,13 @@ | ||
| 103 | 103 | </span> |
| 104 | 104 | </small> |
| 105 | 105 | |
| 106 | 106 | <div class="flex-container flexFlowColumnalignItemsCenter" id="nomicai_apiKey"> |
| 107 | 107 | <label for="api_key_nomicai" class="flex1"> |
| 108 | 108 | <span data-i18n="NomicAI API Key">NomicAI API Key</span> |
| 109 | 109 | </label> |
| 110 | 110 | <div id="api_key_nomicai" class="flex-containermenu_button menu_button_icon"> |
| 111 | - <input id="api_key_nomicai" name="api_key_nomicai" class="text_pole flex1 wide100p" maxlength="500" size="35" type="text" autocomplete="off"> | |
| 111 | + <i class="fa-solid fa-key"></i> | |
| 112 | - <div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_nomicai"> | |
| 112 | + <span data-i18n="Click to set">Click to set</span> | |
| 113 | - </div> | |
| 114 | - </div> | |
| 115 | - <div data-for="api_key_nomicai" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you reload the page."> | |
| 116 | - For privacy reasons, your API key will be hidden after you reload the page. | |
| 117 | 113 | </div> |
| 118 | 114 | </div> |
| 119 | 115 | |