Merge branch 'staging' into webpack
| @@ -6,6 +6,10 @@ function sanitizeInlineQuotationOnCopy() { | |||
| 6 | // STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied. | 6 | // STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied. |
| 7 | // To work around this, take the selection and transform <q> to <span> before calling toString(). | 7 | // To work around this, take the selection and transform <q> to <span> before calling toString(). |
| 8 | document.addEventListener('copy', function (event) { | 8 | document.addEventListener('copy', function (event) { |
| 9 | if (document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement) { | ||
| 10 | return; | ||
| 11 | } | ||
| 12 | |||
| 9 | const selection = window.getSelection(); | 13 | const selection = window.getSelection(); |
| 10 | if (!selection.anchorNode?.parentElement.closest('.mes_text')) { | 14 | if (!selection.anchorNode?.parentElement.closest('.mes_text')) { |
| 11 | return; | 15 | return; |
| @@ -14,8 +18,13 @@ function sanitizeInlineQuotationOnCopy() { | |||
| 14 | const range = selection.getRangeAt(0).cloneContents(); | 18 | const range = selection.getRangeAt(0).cloneContents(); |
| 15 | const tempDOM = document.createDocumentFragment(); | 19 | const tempDOM = document.createDocumentFragment(); |
| 16 | 20 | ||
| 21 | /** | ||
| 22 | * Process a node, transforming <q> elements to <span> elements and preserving children. | ||
| 23 | * @param {Node} node Input node | ||
| 24 | * @returns {Node} Processed node | ||
| 25 | */ | ||
| 17 | function processNode(node) { | 26 | function processNode(node) { |
| 18 | if (node.nodeType === Node.ELEMENT_NODE && node.tagName.toLowerCase() === 'q') { | 27 | if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === 'q') { |
| 19 | // Transform <q> to <span>, preserve children | 28 | // Transform <q> to <span>, preserve children |
| 20 | const span = document.createElement('span'); | 29 | const span = document.createElement('span'); |
| 21 | 30 | ||
| @@ -83,9 +83,9 @@ export function setNovelData(data) { | |||
| 83 | export function getKayraMaxContextTokens() { | 83 | export function getKayraMaxContextTokens() { |
| 84 | switch (novel_data?.tier) { | 84 | switch (novel_data?.tier) { |
| 85 | case 1: | 85 | case 1: |
| 86 | return 3072; | 86 | return 4096; |
| 87 | case 2: | 87 | case 2: |
| 88 | return 6144; | 88 | return 8192; |
| 89 | case 3: | 89 | case 3: |
| 90 | return 8192; | 90 | return 8192; |
| 91 | } | 91 | } |
| @@ -93,14 +93,14 @@ export function getKayraMaxContextTokens() { | |||
| 93 | return null; | 93 | return null; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | export function getKayraMaxResponseTokens() { | 96 | export function getNovelMaxResponseTokens() { |
| 97 | switch (novel_data?.tier) { | 97 | switch (novel_data?.tier) { |
| 98 | case 1: | 98 | case 1: |
| 99 | return 100; | 99 | return 150; |
| 100 | case 2: | 100 | case 2: |
| 101 | return 100; | ||
| 102 | case 3: | ||
| 103 | return 150; | 101 | return 150; |
| 102 | case 3: | ||
| 103 | return 250; | ||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | return maximum_output_length; | 106 | return maximum_output_length; |
| @@ -546,7 +546,7 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper | |||
| 546 | finalPrompt = '<|startoftext|><|reserved_special_token81|>' + finalPrompt; | 546 | finalPrompt = '<|startoftext|><|reserved_special_token81|>' + finalPrompt; |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | const adjustedMaxLength = (isKayra || isErato) ? getKayraMaxResponseTokens() : maximum_output_length; | 549 | const adjustedMaxLength = (isKayra || isErato) ? getNovelMaxResponseTokens() : maximum_output_length; |
| 550 | 550 | ||
| 551 | return { | 551 | return { |
| 552 | 'input': finalPrompt, | 552 | 'input': finalPrompt, |
| @@ -289,15 +289,19 @@ export async function loadFeatherlessModels(data) { | |||
| 289 | originalModels = data; // Store the original data for search | 289 | originalModels = data; // Store the original data for search |
| 290 | featherlessModels = data; | 290 | featherlessModels = data; |
| 291 | 291 | ||
| 292 | if (!data.find(x => x.id === textgen_settings.featherless_model)) { | ||
| 293 | textgen_settings.featherless_model = data[0]?.id || ''; | ||
| 294 | } | ||
| 295 | |||
| 292 | // Populate class select options with unique classes | 296 | // Populate class select options with unique classes |
| 293 | populateClassSelection(data); | 297 | populateClassSelection(data); |
| 294 | 298 | ||
| 295 | // Retrieve the stored number of items per page or default to 5 | 299 | // Retrieve the stored number of items per page or default to 10 |
| 296 | const perPage = Number(localStorage.getItem(storageKey)) || 10; | 300 | const perPage = Number(localStorage.getItem(storageKey)) || 10; |
| 297 | 301 | ||
| 298 | // Initialize pagination with the full set of models | 302 | // Initialize pagination with the full set of models |
| 299 | const selectedModelPage = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1; | 303 | const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model); |
| 300 | featherlessCurrentPage = selectedModelPage > 0 ? selectedModelPage : 1; | 304 | featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1; |
| 301 | setupPagination(originalModels, perPage); | 305 | setupPagination(originalModels, perPage); |
| 302 | 306 | ||
| 303 | // Function to set up pagination (also used for filtered results) | 307 | // Function to set up pagination (also used for filtered results) |