Merge branch 'staging' of https://github.com/Cohee1207/SillyTavern into staging
| @@ -5,7 +5,7 @@ | |||
| 5 | <title>SillyTavern</title> | 5 | <title>SillyTavern</title> |
| 6 | <base href="/"> | 6 | <base href="/"> |
| 7 | <meta charset="utf-8"> | 7 | <meta charset="utf-8"> |
| 8 | <meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | 8 | <meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content"> |
| 9 | <meta name="apple-mobile-web-app-capable" content="yes"> | 9 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| 10 | <meta name="darkreader-lock"> | 10 | <meta name="darkreader-lock"> |
| 11 | <meta name="robots" content="noindex, nofollow" /> | 11 | <meta name="robots" content="noindex, nofollow" /> |
| @@ -1278,6 +1278,28 @@ | |||
| 1278 | </div> | 1278 | </div> |
| 1279 | </div> | 1279 | </div> |
| 1280 | </div> | 1280 | </div> |
| 1281 | |||
| 1282 | <div data-newbie-hidden data-tg-type="koboldcpp" id="xtc_block" class="wide100p"> | ||
| 1283 | <h4 class="wide100p textAlignCenter"> | ||
| 1284 | <label data-i18n="Exclude Top Choices (XTC)">Exclude Top Choices (XTC)</label> | ||
| 1285 | <a href="https://github.com/oobabooga/text-generation-webui/pull/6335" target="_blank"> | ||
| 1286 | <div class=" fa-solid fa-circle-info opacity50p"></div> | ||
| 1287 | </a> | ||
| 1288 | </h4> | ||
| 1289 | <div class="flex-container flexFlowRow gap10px flexShrink"> | ||
| 1290 | <div class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0"> | ||
| 1291 | <small data-i18n="Threshold">Threshold</small> | ||
| 1292 | <input class="neo-range-slider" type="range" id="xtc_threshold_textgenerationwebui" name="volume" min="0" max="0.5" step="0.01" /> | ||
| 1293 | <input class="neo-range-input" type="number" min="0" max="0.5" step="0.01" data-for="xtc_threshold_textgenerationwebui" id="xtc_threshold_counter_textgenerationwebui"> | ||
| 1294 | </div> | ||
| 1295 | <div class="alignitemscenter flex-container flexFlowColumn flexBasis48p flexGrow flexShrink gap0"> | ||
| 1296 | <small data-i18n="Probability">Probability</small> | ||
| 1297 | <input class="neo-range-slider" type="range" id="xtc_probability_textgenerationwebui" name="volume" min="0" max="1" step="0.01" /> | ||
| 1298 | <input class="neo-range-input" type="number" min="0" max="1" step="0.01" data-for="xtc_probability_textgenerationwebui" id="xtc_probability_counter_textgenerationwebui"> | ||
| 1299 | </div> | ||
| 1300 | </div> | ||
| 1301 | </div> | ||
| 1302 | |||
| 1281 | <!-- Enable for llama.cpp when the PR is merged: https://github.com/ggerganov/llama.cpp/pull/6839 --> | 1303 | <!-- Enable for llama.cpp when the PR is merged: https://github.com/ggerganov/llama.cpp/pull/6839 --> |
| 1282 | <div data-newbie-hidden data-tg-type="ooba, koboldcpp" id="dryBlock" class="wide100p"> | 1304 | <div data-newbie-hidden data-tg-type="ooba, koboldcpp" id="dryBlock" class="wide100p"> |
| 1283 | <h4 class="wide100p textAlignCenter" title="DRY penalizes tokens that would extend the end of the input into a sequence that has previously occurred in the input. Set multiplier to 0 to disable." data-i18n="[title]DRY_Repetition_Penalty_desc"> | 1305 | <h4 class="wide100p textAlignCenter" title="DRY penalizes tokens that would extend the end of the input into a sequence that has previously occurred in the input. Set multiplier to 0 to disable." data-i18n="[title]DRY_Repetition_Penalty_desc"> |
| @@ -1823,7 +1845,7 @@ | |||
| 1823 | <div class="fa-solid fa-clock-rotate-left"></div> | 1845 | <div class="fa-solid fa-clock-rotate-left"></div> |
| 1824 | </div> | 1846 | </div> |
| 1825 | </div> | 1847 | </div> |
| 1826 | <textarea id="claude_human_sysprompt_textarea" class="text_pole textarea_compact" rows="4" maxlength="10000" data-i18n="[placeholder]Human message" placeholder="Human message, instruction, etc. Adds nothing when empty, i.e. requires a new prompt with the role 'user'."></textarea> | 1848 | <textarea id="claude_human_sysprompt_textarea" class="text_pole textarea_compact" rows="4" data-i18n="[placeholder]Human message" placeholder="Human message, instruction, etc. Adds nothing when empty, i.e. requires a new prompt with the role 'user'."></textarea> |
| 1827 | </div> | 1849 | </div> |
| 1828 | </div> | 1850 | </div> |
| 1829 | </div> | 1851 | </div> |
| @@ -2931,6 +2953,8 @@ | |||
| 2931 | <option value="command">command</option> | 2953 | <option value="command">command</option> |
| 2932 | <option value="command-r">command-r</option> | 2954 | <option value="command-r">command-r</option> |
| 2933 | <option value="command-r-plus">command-r-plus</option> | 2955 | <option value="command-r-plus">command-r-plus</option> |
| 2956 | <option value="command-r-08-2024">command-r-08-2024</option> | ||
| 2957 | <option value="command-r-plus-08-2024">command-r-plus-08-2024</option> | ||
| 2934 | </optgroup> | 2958 | </optgroup> |
| 2935 | <optgroup label="Nightly"> | 2959 | <optgroup label="Nightly"> |
| 2936 | <option value="command-light-nightly">command-light-nightly</option> | 2960 | <option value="command-light-nightly">command-light-nightly</option> |
| @@ -488,14 +488,6 @@ let default_user_name = 'User'; | |||
| 488 | export let name1 = default_user_name; | 488 | export let name1 = default_user_name; |
| 489 | export let name2 = 'SillyTavern System'; | 489 | export let name2 = 'SillyTavern System'; |
| 490 | export let chat = []; | 490 | export let chat = []; |
| 491 | let safetychat = [ | ||
| 492 | { | ||
| 493 | name: systemUserName, | ||
| 494 | is_user: false, | ||
| 495 | create_date: 0, | ||
| 496 | mes: 'You deleted a character/chat and arrived back here for safety reasons! Pick another character!', | ||
| 497 | }, | ||
| 498 | ]; | ||
| 499 | let chatSaveTimeout; | 491 | let chatSaveTimeout; |
| 500 | let importFlashTimeout; | 492 | let importFlashTimeout; |
| 501 | export let isChatSaving = false; | 493 | export let isChatSaving = false; |
| @@ -594,6 +586,17 @@ export const extension_prompt_roles = { | |||
| 594 | 586 | ||
| 595 | export const MAX_INJECTION_DEPTH = 1000; | 587 | export const MAX_INJECTION_DEPTH = 1000; |
| 596 | 588 | ||
| 589 | const SAFETY_CHAT = [ | ||
| 590 | { | ||
| 591 | name: systemUserName, | ||
| 592 | force_avatar: system_avatar, | ||
| 593 | is_system: true, | ||
| 594 | is_user: false, | ||
| 595 | create_date: 0, | ||
| 596 | mes: 'You deleted a character/chat and arrived back here for safety reasons! Pick another character!', | ||
| 597 | }, | ||
| 598 | ]; | ||
| 599 | |||
| 597 | export let system_messages = {}; | 600 | export let system_messages = {}; |
| 598 | 601 | ||
| 599 | async function getSystemMessages() { | 602 | async function getSystemMessages() { |
| @@ -3760,7 +3763,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3760 | } | 3763 | } |
| 3761 | 3764 | ||
| 3762 | let examplesString = ''; | 3765 | let examplesString = ''; |
| 3763 | let chatString = ''; | 3766 | let chatString = addChatsPreamble(addChatsSeparator('')); |
| 3764 | let cyclePrompt = ''; | 3767 | let cyclePrompt = ''; |
| 3765 | 3768 | ||
| 3766 | async function getMessagesTokenCount() { | 3769 | async function getMessagesTokenCount() { |
| @@ -3769,10 +3772,10 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3769 | storyString, | 3772 | storyString, |
| 3770 | afterScenarioAnchor, | 3773 | afterScenarioAnchor, |
| 3771 | examplesString, | 3774 | examplesString, |
| 3775 | userAlignmentMessage, | ||
| 3772 | chatString, | 3776 | chatString, |
| 3773 | quiet_prompt, | 3777 | modifyLastPromptLine(''), |
| 3774 | cyclePrompt, | 3778 | cyclePrompt, |
| 3775 | userAlignmentMessage, | ||
| 3776 | ].join('').replace(/\r/gm, ''); | 3779 | ].join('').replace(/\r/gm, ''); |
| 3777 | return getTokenCountAsync(encodeString, power_user.token_padding); | 3780 | return getTokenCountAsync(encodeString, power_user.token_padding); |
| 3778 | } | 3781 | } |
| @@ -3803,8 +3806,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3803 | } | 3806 | } |
| 3804 | 3807 | ||
| 3805 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); | 3808 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); |
| 3806 | chatString = item + chatString; | ||
| 3807 | if (tokenCount < this_max_context) { | 3809 | if (tokenCount < this_max_context) { |
| 3810 | chatString = chatString + item; | ||
| 3808 | arrMes[index] = item; | 3811 | arrMes[index] = item; |
| 3809 | lastAddedIndex = Math.max(lastAddedIndex, index); | 3812 | lastAddedIndex = Math.max(lastAddedIndex, index); |
| 3810 | } else { | 3813 | } else { |
| @@ -3830,8 +3833,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3830 | } | 3833 | } |
| 3831 | 3834 | ||
| 3832 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); | 3835 | tokenCount += await getTokenCountAsync(item.replace(/\r/gm, '')); |
| 3833 | chatString = item + chatString; | ||
| 3834 | if (tokenCount < this_max_context) { | 3836 | if (tokenCount < this_max_context) { |
| 3837 | chatString = chatString + item; | ||
| 3835 | arrMes[i] = item; | 3838 | arrMes[i] = item; |
| 3836 | lastAddedIndex = Math.max(lastAddedIndex, i); | 3839 | lastAddedIndex = Math.max(lastAddedIndex, i); |
| 3837 | } else { | 3840 | } else { |
| @@ -4028,15 +4031,16 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 4028 | async function checkPromptSize() { | 4031 | async function checkPromptSize() { |
| 4029 | console.debug('---checking Prompt size'); | 4032 | console.debug('---checking Prompt size'); |
| 4030 | setPromptString(); | 4033 | setPromptString(); |
| 4034 | const jointMessages = mesSend.map((e) => `${e.extensionPrompts.join('')}${e.message}`).join(''); | ||
| 4031 | const prompt = [ | 4035 | const prompt = [ |
| 4032 | beforeScenarioAnchor, | 4036 | beforeScenarioAnchor, |
| 4033 | storyString, | 4037 | storyString, |
| 4034 | afterScenarioAnchor, | 4038 | afterScenarioAnchor, |
| 4035 | mesExmString, | 4039 | mesExmString, |
| 4036 | mesSend.map((e) => `${e.extensionPrompts.join('')}${e.message}`).join(''), | 4040 | addChatsPreamble(addChatsSeparator(jointMessages)), |
| 4037 | '\n', | 4041 | '\n', |
| 4042 | modifyLastPromptLine(''), | ||
| 4038 | generatedPromptCache, | 4043 | generatedPromptCache, |
| 4039 | quiet_prompt, | ||
| 4040 | ].join('').replace(/\r/gm, ''); | 4044 | ].join('').replace(/\r/gm, ''); |
| 4041 | let thisPromptContextSize = await getTokenCountAsync(prompt, power_user.token_padding); | 4045 | let thisPromptContextSize = await getTokenCountAsync(prompt, power_user.token_padding); |
| 4042 | 4046 | ||
| @@ -5679,7 +5683,7 @@ export function resetChatState() { | |||
| 5679 | // replaces deleted charcter name with system user since it will be displayed next. | 5683 | // replaces deleted charcter name with system user since it will be displayed next. |
| 5680 | name2 = systemUserName; | 5684 | name2 = systemUserName; |
| 5681 | // sets up system user to tell user about having deleted a character | 5685 | // sets up system user to tell user about having deleted a character |
| 5682 | chat = [...safetychat]; | 5686 | chat.splice(0, chat.length, ...SAFETY_CHAT); |
| 5683 | // resets chat metadata | 5687 | // resets chat metadata |
| 5684 | chat_metadata = {}; | 5688 | chat_metadata = {}; |
| 5685 | // resets the characters array, forcing getcharacters to reset | 5689 | // resets the characters array, forcing getcharacters to reset |
| @@ -8840,16 +8844,21 @@ export async function handleDeleteCharacter(this_chid, delete_chats) { | |||
| 8840 | /** | 8844 | /** |
| 8841 | * Deletes a character completely, including associated chats if specified | 8845 | * Deletes a character completely, including associated chats if specified |
| 8842 | * | 8846 | * |
| 8843 | * @param {string} characterKey - The key (avatar) of the character to be deleted | 8847 | * @param {string|string[]} characterKey - The key (avatar) of the character to be deleted |
| 8844 | * @param {Object} [options] - Optional parameters for the deletion | 8848 | * @param {Object} [options] - Optional parameters for the deletion |
| 8845 | * @param {boolean} [options.deleteChats=true] - Whether to delete associated chats or not | 8849 | * @param {boolean} [options.deleteChats=true] - Whether to delete associated chats or not |
| 8846 | * @return {Promise<void>} - A promise that resolves when the character is successfully deleted | 8850 | * @return {Promise<void>} - A promise that resolves when the character is successfully deleted |
| 8847 | */ | 8851 | */ |
| 8848 | export async function deleteCharacter(characterKey, { deleteChats = true } = {}) { | 8852 | export async function deleteCharacter(characterKey, { deleteChats = true } = {}) { |
| 8849 | const character = characters.find(x => x.avatar == characterKey); | 8853 | if (!Array.isArray(characterKey)) { |
| 8854 | characterKey = [characterKey]; | ||
| 8855 | } | ||
| 8856 | |||
| 8857 | for (const key of characterKey) { | ||
| 8858 | const character = characters.find(x => x.avatar == key); | ||
| 8850 | if (!character) { | 8859 | if (!character) { |
| 8851 | toastr.warning(`Character ${characterKey} not found. Cannot be deleted.`); | 8860 | toastr.warning(`Character ${key} not found. Skipping deletion.`); |
| 8852 | return; | 8861 | continue; |
| 8853 | } | 8862 | } |
| 8854 | 8863 | ||
| 8855 | const chid = characters.indexOf(character); | 8864 | const chid = characters.indexOf(character); |
| @@ -8865,10 +8874,12 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {}) | |||
| 8865 | }); | 8874 | }); |
| 8866 | 8875 | ||
| 8867 | if (!response.ok) { | 8876 | if (!response.ok) { |
| 8868 | throw new Error(`Failed to delete character: ${response.status} ${response.statusText}`); | 8877 | toastr.error(`${response.status} ${response.statusText}`, 'Failed to delete character'); |
| 8878 | continue; | ||
| 8869 | } | 8879 | } |
| 8870 | 8880 | ||
| 8871 | await removeCharacterFromUI(character.name, character.avatar); | 8881 | delete tag_map[character.avatar]; |
| 8882 | select_rm_info('char_delete', character.name); | ||
| 8872 | 8883 | ||
| 8873 | if (deleteChats) { | 8884 | if (deleteChats) { |
| 8874 | for (const chat of pastChats) { | 8885 | for (const chat of pastChats) { |
| @@ -8877,35 +8888,30 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {}) | |||
| 8877 | } | 8888 | } |
| 8878 | } | 8889 | } |
| 8879 | 8890 | ||
| 8880 | eventSource.emit(event_types.CHARACTER_DELETED, { id: this_chid, character: characters[this_chid] }); | 8891 | await eventSource.emit(event_types.CHARACTER_DELETED, { id: chid, character: character }); |
| 8892 | } | ||
| 8893 | |||
| 8894 | await removeCharacterFromUI(); | ||
| 8881 | } | 8895 | } |
| 8882 | 8896 | ||
| 8883 | /** | 8897 | /** |
| 8884 | * Function to delete a character from UI after character deletion API success. | 8898 | * Function to delete a character from UI after character deletion API success. |
| 8885 | * It manages necessary UI changes such as closing advanced editing popup, unsetting | 8899 | * It manages necessary UI changes such as closing advanced editing popup, unsetting |
| 8886 | * character ID, resetting characters array and chat metadata, deselecting character's tab | 8900 | * character ID, resetting characters array and chat metadata, deselecting character's tab |
| 8887 | * panel, removing character name from navigation tabs, clearing chat, removing character's | 8901 | * panel, removing character name from navigation tabs, clearing chat, fetching updated list of characters. |
| 8888 | * avatar from tag_map, fetching updated list of characters and updating the 'deleted | ||
| 8889 | * character' message. | ||
| 8890 | * It also ensures to save the settings after all the operations. | 8902 | * It also ensures to save the settings after all the operations. |
| 8891 | * | ||
| 8892 | * @param {string} name - The name of the character to be deleted. | ||
| 8893 | * @param {string} avatar - The avatar URL of the character to be deleted. | ||
| 8894 | * @param {boolean} reloadCharacters - Whether the character list should be refreshed after deletion. | ||
| 8895 | */ | 8903 | */ |
| 8896 | async function removeCharacterFromUI(name, avatar, reloadCharacters = true) { | 8904 | async function removeCharacterFromUI() { |
| 8897 | await clearChat(); | 8905 | await clearChat(); |
| 8898 | $('#character_cross').click(); | 8906 | $('#character_cross').click(); |
| 8899 | this_chid = undefined; | 8907 | this_chid = undefined; |
| 8900 | characters.length = 0; | 8908 | characters.length = 0; |
| 8901 | name2 = systemUserName; | 8909 | name2 = systemUserName; |
| 8902 | chat = [...safetychat]; | 8910 | chat.splice(0, chat.length, ...SAFETY_CHAT); |
| 8903 | chat_metadata = {}; | 8911 | chat_metadata = {}; |
| 8904 | $(document.getElementById('rm_button_selected_ch')).children('h2').text(''); | 8912 | $(document.getElementById('rm_button_selected_ch')).children('h2').text(''); |
| 8905 | this_chid = undefined; | 8913 | this_chid = undefined; |
| 8906 | delete tag_map[avatar]; | 8914 | await getCharacters(); |
| 8907 | if (reloadCharacters) await getCharacters(); | ||
| 8908 | select_rm_info('char_delete', name); | ||
| 8909 | await printMessages(); | 8915 | await printMessages(); |
| 8910 | saveSettingsDebounced(); | 8916 | saveSettingsDebounced(); |
| 8911 | } | 8917 | } |
| @@ -108,14 +108,12 @@ class CharacterContextMenu { | |||
| 108 | * Delete one or more characters, | 108 | * Delete one or more characters, |
| 109 | * opens a popup. | 109 | * opens a popup. |
| 110 | * | 110 | * |
| 111 | * @param {number} characterId | 111 | * @param {string|string[]} characterKey |
| 112 | * @param {boolean} [deleteChats] | 112 | * @param {boolean} [deleteChats] |
| 113 | * @returns {Promise<void>} | 113 | * @returns {Promise<void>} |
| 114 | */ | 114 | */ |
| 115 | static delete = async (characterId, deleteChats = false) => { | 115 | static delete = async (characterKey, deleteChats = false) => { |
| 116 | const character = CharacterContextMenu.#getCharacter(characterId); | 116 | await deleteCharacter(characterKey, { deleteChats: deleteChats }); |
| 117 | |||
| 118 | await deleteCharacter(character.avatar, { deleteChats: deleteChats }); | ||
| 119 | }; | 117 | }; |
| 120 | 118 | ||
| 121 | static #getCharacter = (characterId) => characters[characterId] ?? null; | 119 | static #getCharacter = (characterId) => characters[characterId] ?? null; |
| @@ -599,8 +597,7 @@ class BulkEditOverlay { | |||
| 599 | 597 | ||
| 600 | this.container.removeEventListener('mouseup', cancelHold); | 598 | this.container.removeEventListener('mouseup', cancelHold); |
| 601 | this.container.removeEventListener('touchend', cancelHold); | 599 | this.container.removeEventListener('touchend', cancelHold); |
| 602 | }, | 600 | }, BulkEditOverlay.longPressDelay); |
| 603 | BulkEditOverlay.longPressDelay); | ||
| 604 | }; | 601 | }; |
| 605 | 602 | ||
| 606 | handleLongPressEnd = (event) => { | 603 | handleLongPressEnd = (event) => { |
| @@ -847,11 +844,14 @@ class BulkEditOverlay { | |||
| 847 | const deleteChats = document.getElementById('del_char_checkbox').checked ?? false; | 844 | const deleteChats = document.getElementById('del_char_checkbox').checked ?? false; |
| 848 | 845 | ||
| 849 | showLoader(); | 846 | showLoader(); |
| 850 | toastr.info('We\'re deleting your characters, please wait...', 'Working on it'); | 847 | const toast = toastr.info('We\'re deleting your characters, please wait...', 'Working on it'); |
| 851 | return Promise.allSettled(characterIds.map(async characterId => CharacterContextMenu.delete(characterId, deleteChats))) | 848 | const avatarList = characterIds.map(id => characters[id]?.avatar).filter(a => a); |
| 852 | .then(() => getCharacters()) | 849 | return CharacterContextMenu.delete(avatarList, deleteChats) |
| 853 | .then(() => this.browseState()) | 850 | .then(() => this.browseState()) |
| 854 | .finally(() => hideLoader()); | 851 | .finally(() => { |
| 852 | toastr.clear(toast); | ||
| 853 | hideLoader(); | ||
| 854 | }); | ||
| 855 | }); | 855 | }); |
| 856 | 856 | ||
| 857 | // At this moment the popup is already changed in the dom, but not yet closed/resolved. We build the avatar list here | 857 | // At this moment the popup is already changed in the dom, but not yet closed/resolved. We build the avatar list here |
| @@ -78,6 +78,19 @@ export function getKayraMaxContextTokens() { | |||
| 78 | return null; | 78 | return null; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | export function getKayraMaxResponseTokens() { | ||
| 82 | switch (novel_data?.tier) { | ||
| 83 | case 1: | ||
| 84 | return 100; | ||
| 85 | case 2: | ||
| 86 | return 100; | ||
| 87 | case 3: | ||
| 88 | return 150; | ||
| 89 | } | ||
| 90 | |||
| 91 | return maximum_output_length; | ||
| 92 | } | ||
| 93 | |||
| 81 | export function getNovelTier() { | 94 | export function getNovelTier() { |
| 82 | return nai_tiers[novel_data?.tier] ?? 'no_connection'; | 95 | return nai_tiers[novel_data?.tier] ?? 'no_connection'; |
| 83 | } | 96 | } |
| @@ -438,12 +451,14 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper | |||
| 438 | console.log(finalPrompt); | 451 | console.log(finalPrompt); |
| 439 | } | 452 | } |
| 440 | 453 | ||
| 454 | const adjustedMaxLength = nai_settings.model_novel.includes('kayra') ? getKayraMaxResponseTokens() : maximum_output_length; | ||
| 455 | |||
| 441 | return { | 456 | return { |
| 442 | 'input': finalPrompt, | 457 | 'input': finalPrompt, |
| 443 | 'model': nai_settings.model_novel, | 458 | 'model': nai_settings.model_novel, |
| 444 | 'use_string': true, | 459 | 'use_string': true, |
| 445 | 'temperature': Number(nai_settings.temperature), | 460 | 'temperature': Number(nai_settings.temperature), |
| 446 | 'max_length': maxLength < maximum_output_length ? maxLength : maximum_output_length, | 461 | 'max_length': maxLength < adjustedMaxLength ? maxLength : adjustedMaxLength, |
| 447 | 'min_length': Number(nai_settings.min_length), | 462 | 'min_length': Number(nai_settings.min_length), |
| 448 | 'tail_free_sampling': Number(nai_settings.tail_free_sampling), | 463 | 'tail_free_sampling': Number(nai_settings.tail_free_sampling), |
| 449 | 'repetition_penalty': Number(nai_settings.repetition_penalty), | 464 | 'repetition_penalty': Number(nai_settings.repetition_penalty), |
| @@ -133,7 +133,7 @@ const max_2mil = 2000 * 1000; | |||
| 133 | const scale_max = 8191; | 133 | const scale_max = 8191; |
| 134 | const claude_max = 9000; // We have a proper tokenizer, so theoretically could be larger (up to 9k) | 134 | const claude_max = 9000; // We have a proper tokenizer, so theoretically could be larger (up to 9k) |
| 135 | const claude_100k_max = 99000; | 135 | const claude_100k_max = 99000; |
| 136 | const unlocked_max = max_200k; | 136 | const unlocked_max = max_2mil; |
| 137 | const oai_max_temp = 2.0; | 137 | const oai_max_temp = 2.0; |
| 138 | const claude_max_temp = 1.0; | 138 | const claude_max_temp = 1.0; |
| 139 | const openrouter_website_model = 'OR_Website'; | 139 | const openrouter_website_model = 'OR_Website'; |
| @@ -4191,7 +4191,7 @@ async function onModelChange() { | |||
| 4191 | else if (['command-light-nightly', 'command-nightly'].includes(oai_settings.cohere_model)) { | 4191 | else if (['command-light-nightly', 'command-nightly'].includes(oai_settings.cohere_model)) { |
| 4192 | $('#openai_max_context').attr('max', max_8k); | 4192 | $('#openai_max_context').attr('max', max_8k); |
| 4193 | } | 4193 | } |
| 4194 | else if (['command-r', 'command-r-plus'].includes(oai_settings.cohere_model)) { | 4194 | else if (oai_settings.cohere_model.includes('command-r')) { |
| 4195 | $('#openai_max_context').attr('max', max_128k); | 4195 | $('#openai_max_context').attr('max', max_128k); |
| 4196 | } | 4196 | } |
| 4197 | else if (['c4ai-aya-23'].includes(oai_settings.cohere_model)) { | 4197 | else if (['c4ai-aya-23'].includes(oai_settings.cohere_model)) { |
| @@ -188,6 +188,8 @@ const settings = { | |||
| 188 | custom_model: '', | 188 | custom_model: '', |
| 189 | bypass_status_check: false, | 189 | bypass_status_check: false, |
| 190 | openrouter_allow_fallbacks: true, | 190 | openrouter_allow_fallbacks: true, |
| 191 | xtc_threshold: 0.1, | ||
| 192 | xtc_probability: 0, | ||
| 191 | }; | 193 | }; |
| 192 | 194 | ||
| 193 | export let textgenerationwebui_banned_in_macros = []; | 195 | export let textgenerationwebui_banned_in_macros = []; |
| @@ -263,6 +265,8 @@ export const setting_names = [ | |||
| 263 | 'custom_model', | 265 | 'custom_model', |
| 264 | 'bypass_status_check', | 266 | 'bypass_status_check', |
| 265 | 'openrouter_allow_fallbacks', | 267 | 'openrouter_allow_fallbacks', |
| 268 | 'xtc_threshold', | ||
| 269 | 'xtc_probability', | ||
| 266 | ]; | 270 | ]; |
| 267 | 271 | ||
| 268 | const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba'); | 272 | const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba'); |
| @@ -718,6 +722,8 @@ jQuery(function () { | |||
| 718 | 'dry_multiplier_textgenerationwebui': 0, | 722 | 'dry_multiplier_textgenerationwebui': 0, |
| 719 | 'dry_base_textgenerationwebui': 1.75, | 723 | 'dry_base_textgenerationwebui': 1.75, |
| 720 | 'dry_penalty_last_n_textgenerationwebui': 0, | 724 | 'dry_penalty_last_n_textgenerationwebui': 0, |
| 725 | 'xtc_threshold_textgenerationwebui': 0.1, | ||
| 726 | 'xtc_probability_textgenerationwebui': 0, | ||
| 721 | }; | 727 | }; |
| 722 | 728 | ||
| 723 | for (const [id, value] of Object.entries(inputs)) { | 729 | for (const [id, value] of Object.entries(inputs)) { |
| @@ -1156,6 +1162,8 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, | |||
| 1156 | 'api_server': getTextGenServer(), | 1162 | 'api_server': getTextGenServer(), |
| 1157 | 'legacy_api': settings.legacy_api && (settings.type === OOBA || settings.type === APHRODITE), | 1163 | 'legacy_api': settings.legacy_api && (settings.type === OOBA || settings.type === APHRODITE), |
| 1158 | 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, | 1164 | 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, |
| 1165 | 'xtc_threshold': settings.xtc_threshold, | ||
| 1166 | 'xtc_probability': settings.xtc_probability, | ||
| 1159 | }; | 1167 | }; |
| 1160 | const nonAphroditeParams = { | 1168 | const nonAphroditeParams = { |
| 1161 | 'rep_pen': settings.rep_pen, | 1169 | 'rep_pen': settings.rep_pen, |
| @@ -4777,8 +4777,10 @@ jQuery(() => { | |||
| 4777 | world_info_min_activations = Number($(this).val()); | 4777 | world_info_min_activations = Number($(this).val()); |
| 4778 | $('#world_info_min_activations_counter').val(world_info_min_activations); | 4778 | $('#world_info_min_activations_counter').val(world_info_min_activations); |
| 4779 | 4779 | ||
| 4780 | if (world_info_min_activations !== 0) { | 4780 | if (world_info_min_activations !== 0 && world_info_max_recursion_steps !== 0) { |
| 4781 | $('#world_info_max_recursion_steps').val(0).trigger('input'); | 4781 | $('#world_info_max_recursion_steps').val(0).trigger('input'); |
| 4782 | flashHighlight($('#world_info_max_recursion_steps').parent()); // flash the other control to show it has changed | ||
| 4783 | console.info('[WI] Max recursion steps set to 0, as min activations is set to', world_info_min_activations); | ||
| 4782 | } else { | 4784 | } else { |
| 4783 | saveSettings(); | 4785 | saveSettings(); |
| 4784 | } | 4786 | } |
| @@ -4840,8 +4842,10 @@ jQuery(() => { | |||
| 4840 | $('#world_info_max_recursion_steps').on('input', function () { | 4842 | $('#world_info_max_recursion_steps').on('input', function () { |
| 4841 | world_info_max_recursion_steps = Number($(this).val()); | 4843 | world_info_max_recursion_steps = Number($(this).val()); |
| 4842 | $('#world_info_max_recursion_steps_counter').val(world_info_max_recursion_steps); | 4844 | $('#world_info_max_recursion_steps_counter').val(world_info_max_recursion_steps); |
| 4843 | if (world_info_max_recursion_steps !== 0) { | 4845 | if (world_info_max_recursion_steps !== 0 && world_info_min_activations !== 0) { |
| 4844 | $('#world_info_min_activations').val(0).trigger('input'); | 4846 | $('#world_info_min_activations').val(0).trigger('input'); |
| 4847 | flashHighlight($('#world_info_min_activations').parent()); // flash the other control to show it has changed | ||
| 4848 | console.info('[WI] Min activations set to 0, as max recursion steps is set to', world_info_max_recursion_steps); | ||
| 4845 | } else { | 4849 | } else { |
| 4846 | saveSettings(); | 4850 | saveSettings(); |
| 4847 | } | 4851 | } |
| @@ -572,6 +572,11 @@ async function sendCohereRequest(request, response) { | |||
| 572 | search_queries_only: false, | 572 | search_queries_only: false, |
| 573 | }; | 573 | }; |
| 574 | 574 | ||
| 575 | const canDoSafetyMode = String(request.body.model).endsWith('08-2024'); | ||
| 576 | if (canDoSafetyMode) { | ||
| 577 | requestBody.safety_mode = 'NONE'; | ||
| 578 | } | ||
| 579 | |||
| 575 | console.log('Cohere request:', requestBody); | 580 | console.log('Cohere request:', requestBody); |
| 576 | 581 | ||
| 577 | const config = { | 582 | const config = { |
| @@ -6,6 +6,7 @@ const { readAllChunks, extractFileFromZipBuffer, forwardFetchResponse } = requir | |||
| 6 | const { jsonParser } = require('../express-common'); | 6 | const { jsonParser } = require('../express-common'); |
| 7 | 7 | ||
| 8 | const API_NOVELAI = 'https://api.novelai.net'; | 8 | const API_NOVELAI = 'https://api.novelai.net'; |
| 9 | const TEXT_NOVELAI = 'https://text.novelai.net'; | ||
| 9 | const IMAGE_NOVELAI = 'https://image.novelai.net'; | 10 | const IMAGE_NOVELAI = 'https://image.novelai.net'; |
| 10 | 11 | ||
| 11 | // Ban bracket generation, plus defaults | 12 | // Ban bracket generation, plus defaults |
| @@ -155,7 +156,7 @@ router.post('/generate', jsonParser, async function (req, res) { | |||
| 155 | 'repetition_penalty_slope': req.body.repetition_penalty_slope, | 156 | 'repetition_penalty_slope': req.body.repetition_penalty_slope, |
| 156 | 'repetition_penalty_frequency': req.body.repetition_penalty_frequency, | 157 | 'repetition_penalty_frequency': req.body.repetition_penalty_frequency, |
| 157 | 'repetition_penalty_presence': req.body.repetition_penalty_presence, | 158 | 'repetition_penalty_presence': req.body.repetition_penalty_presence, |
| 158 | 'repetition_penalty_whitelist': isNewModel ? repPenaltyAllowList : null, | 159 | 'repetition_penalty_whitelist': isNewModel ? repPenaltyAllowList.flat() : null, |
| 159 | 'top_a': req.body.top_a, | 160 | 'top_a': req.body.top_a, |
| 160 | 'top_p': req.body.top_p, | 161 | 'top_p': req.body.top_p, |
| 161 | 'top_k': req.body.top_k, | 162 | 'top_k': req.body.top_k, |
| @@ -178,9 +179,7 @@ router.post('/generate', jsonParser, async function (req, res) { | |||
| 178 | }; | 179 | }; |
| 179 | 180 | ||
| 180 | // Tells the model to stop generation at '>' | 181 | // Tells the model to stop generation at '>' |
| 181 | if ('theme_textadventure' === req.body.prefix && | 182 | if ('theme_textadventure' === req.body.prefix && isNewModel) { |
| 182 | (true === req.body.model.includes('clio') || | ||
| 183 | true === req.body.model.includes('kayra'))) { | ||
| 184 | data.parameters.eos_token_id = 49405; | 183 | data.parameters.eos_token_id = 49405; |
| 185 | } | 184 | } |
| 186 | 185 | ||
| @@ -193,7 +192,8 @@ router.post('/generate', jsonParser, async function (req, res) { | |||
| 193 | }; | 192 | }; |
| 194 | 193 | ||
| 195 | try { | 194 | try { |
| 196 | const url = req.body.streaming ? `${API_NOVELAI}/ai/generate-stream` : `${API_NOVELAI}/ai/generate`; | 195 | const baseURL = req.body.model.includes('kayra') ? TEXT_NOVELAI : API_NOVELAI; |
| 196 | const url = req.body.streaming ? `${baseURL}/ai/generate-stream` : `${baseURL}/ai/generate`; | ||
| 197 | const response = await fetch(url, { method: 'POST', timeout: 0, ...args }); | 197 | const response = await fetch(url, { method: 'POST', timeout: 0, ...args }); |
| 198 | 198 | ||
| 199 | if (req.body.streaming) { | 199 | if (req.body.streaming) { |