mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-12 09:26:33 +01:00
Vector Storage: change NomicAI key input
This commit is contained in:
parent
1842a8ee6d
commit
d0b368f29c
@ -30,6 +30,7 @@ import { textgen_types, textgenerationwebui_settings } from '../../textgen-setti
|
|||||||
import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
|
import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
|
||||||
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
||||||
|
import { callGenericPopup, POPUP_RESULT, POPUP_TYPE } from '../../popup.js';
|
||||||
|
|
||||||
const MODULE_NAME = 'vectors';
|
const MODULE_NAME = 'vectors';
|
||||||
|
|
||||||
@ -1299,11 +1300,30 @@ jQuery(async () => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
toggleSettings();
|
toggleSettings();
|
||||||
});
|
});
|
||||||
$('#api_key_nomicai').on('change', () => {
|
$('#api_key_nomicai').on('click', async () => {
|
||||||
const nomicKey = String($('#api_key_nomicai').val()).trim();
|
const popupText = 'NomicAI API Key:';
|
||||||
if (nomicKey.length) {
|
const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT, '', {
|
||||||
writeSecret(SECRET_KEYS.NOMICAI, nomicKey);
|
customButtons: [{
|
||||||
|
text: 'Remove Key',
|
||||||
|
appendAtEnd: true,
|
||||||
|
result: POPUP_RESULT.NEGATIVE,
|
||||||
|
action: async () => {
|
||||||
|
await writeSecret(SECRET_KEYS.NOMICAI, '');
|
||||||
|
toastr.success('API Key removed');
|
||||||
|
$('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await writeSecret(SECRET_KEYS.NOMICAI, String(key));
|
||||||
|
$('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]);
|
||||||
|
|
||||||
|
toastr.success('API Key saved');
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
$('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => {
|
$('#vectors_togetherai_model').val(settings.togetherai_model).on('change', () => {
|
||||||
@ -1531,9 +1551,7 @@ jQuery(async () => {
|
|||||||
$('#dialogue_popup_input').val(presetModel);
|
$('#dialogue_popup_input').val(presetModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
const validSecret = !!secret_state[SECRET_KEYS.NOMICAI];
|
$('#api_key_nomicai').toggleClass('success', !!secret_state[SECRET_KEYS.NOMICAI]);
|
||||||
const placeholder = validSecret ? '✔️ Key saved' : '❌ Missing key';
|
|
||||||
$('#api_key_nomicai').attr('placeholder', placeholder);
|
|
||||||
|
|
||||||
toggleSettings();
|
toggleSettings();
|
||||||
eventSource.on(event_types.MESSAGE_DELETED, onChatEvent);
|
eventSource.on(event_types.MESSAGE_DELETED, onChatEvent);
|
||||||
|
@ -103,17 +103,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</small>
|
</small>
|
||||||
|
|
||||||
<div class="flex-container flexFlowColumn" id="nomicai_apiKey">
|
<div class="flex-container alignItemsCenter" id="nomicai_apiKey">
|
||||||
<label for="api_key_nomicai">
|
<label for="api_key_nomicai" class="flex1">
|
||||||
<span data-i18n="NomicAI API Key">NomicAI API Key</span>
|
<span data-i18n="NomicAI API Key">NomicAI API Key</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="flex-container">
|
<div id="api_key_nomicai" class="menu_button menu_button_icon">
|
||||||
<input id="api_key_nomicai" name="api_key_nomicai" class="text_pole flex1 wide100p" maxlength="500" size="35" type="text" autocomplete="off">
|
<i class="fa-solid fa-key"></i>
|
||||||
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_nomicai">
|
<span data-i18n="Click to set">Click to set</span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<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.">
|
|
||||||
For privacy reasons, your API key will be hidden after you reload the page.
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user