import { callPopup, getRequestHeaders } from '../script.js'; export const SECRET_KEYS = { HORDE: 'api_key_horde', MANCER: 'api_key_mancer', VLLM: 'api_key_vllm', APHRODITE: 'api_key_aphrodite', TABBY: 'api_key_tabby', OPENAI: 'api_key_openai', NOVEL: 'api_key_novel', CLAUDE: 'api_key_claude', OPENROUTER: 'api_key_openrouter', SCALE: 'api_key_scale', AI21: 'api_key_ai21', SCALE_COOKIE: 'scale_cookie', MAKERSUITE: 'api_key_makersuite', SERPAPI: 'api_key_serpapi', MISTRALAI: 'api_key_mistralai', TOGETHERAI: 'api_key_togetherai', INFERMATICAI: 'api_key_infermaticai', DREAMGEN: 'api_key_dreamgen', CUSTOM: 'api_key_custom', OOBA: 'api_key_ooba', NOMICAI: 'api_key_nomicai', KOBOLDCPP: 'api_key_koboldcpp', LLAMACPP: 'api_key_llamacpp', COHERE: 'api_key_cohere', PERPLEXITY: 'api_key_perplexity', GROQ: 'api_key_groq', AZURE_TTS: 'api_key_azure_tts', FEATHERLESS: 'api_key_featherless', ZEROONEAI: 'api_key_01ai', HUGGINGFACE: 'api_key_huggingface', STABILITY: 'api_key_stability', BLOCKENTROPY: 'api_key_blockentropy', CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', }; const INPUT_MAP = { [SECRET_KEYS.HORDE]: '#horde_api_key', [SECRET_KEYS.MANCER]: '#api_key_mancer', [SECRET_KEYS.OPENAI]: '#api_key_openai', [SECRET_KEYS.NOVEL]: '#api_key_novel', [SECRET_KEYS.CLAUDE]: '#api_key_claude', [SECRET_KEYS.OPENROUTER]: '.api_key_openrouter', [SECRET_KEYS.SCALE]: '#api_key_scale', [SECRET_KEYS.AI21]: '#api_key_ai21', [SECRET_KEYS.SCALE_COOKIE]: '#scale_cookie', [SECRET_KEYS.MAKERSUITE]: '#api_key_makersuite', [SECRET_KEYS.VLLM]: '#api_key_vllm', [SECRET_KEYS.APHRODITE]: '#api_key_aphrodite', [SECRET_KEYS.TABBY]: '#api_key_tabby', [SECRET_KEYS.MISTRALAI]: '#api_key_mistralai', [SECRET_KEYS.CUSTOM]: '#api_key_custom', [SECRET_KEYS.TOGETHERAI]: '#api_key_togetherai', [SECRET_KEYS.OOBA]: '#api_key_ooba', [SECRET_KEYS.INFERMATICAI]: '#api_key_infermaticai', [SECRET_KEYS.DREAMGEN]: '#api_key_dreamgen', [SECRET_KEYS.NOMICAI]: '#api_key_nomicai', [SECRET_KEYS.KOBOLDCPP]: '#api_key_koboldcpp', [SECRET_KEYS.LLAMACPP]: '#api_key_llamacpp', [SECRET_KEYS.COHERE]: '#api_key_cohere', [SECRET_KEYS.PERPLEXITY]: '#api_key_perplexity', [SECRET_KEYS.GROQ]: '#api_key_groq', [SECRET_KEYS.FEATHERLESS]: '#api_key_featherless', [SECRET_KEYS.ZEROONEAI]: '#api_key_01ai', [SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface', [SECRET_KEYS.BLOCKENTROPY]: '#api_key_blockentropy', }; async function clearSecret() { const key = $(this).data('key'); await writeSecret(key, ''); secret_state[key] = false; updateSecretDisplay(); $(INPUT_MAP[key]).val('').trigger('input'); $('#main_api').trigger('change'); } export function updateSecretDisplay() { for (const [secret_key, input_selector] of Object.entries(INPUT_MAP)) { const validSecret = !!secret_state[secret_key]; const placeholder = $('#viewSecrets').attr(validSecret ? 'key_saved_text' : 'missing_key_text'); $(input_selector).attr('placeholder', placeholder); } } async function viewSecrets() { const response = await fetch('/api/secrets/view', { method: 'POST', headers: getRequestHeaders(), }); if (response.status == 403) { callPopup('
To view your API keys here, set the value of allowKeysExposure to true in config.yaml file and restart the SillyTavern server.
', 'text'); return; } if (!response.ok) { return; } $('#dialogue_popup').addClass('wide_dialogue_popup'); const data = await response.json(); const table = document.createElement('table'); table.classList.add('responsiveTable'); $(table).append('