Merge branch 'staging' into webpack

This commit is contained in:
Cohee 2024-10-18 20:12:51 +03:00
commit a1d3b7f3ef
3 changed files with 25 additions and 12 deletions

View File

@ -6,6 +6,10 @@ function sanitizeInlineQuotationOnCopy() {
// STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied.
// To work around this, take the selection and transform <q> to <span> before calling toString().
document.addEventListener('copy', function (event) {
if (document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement) {
return;
}
const selection = window.getSelection();
if (!selection.anchorNode?.parentElement.closest('.mes_text')) {
return;
@ -14,8 +18,13 @@ function sanitizeInlineQuotationOnCopy() {
const range = selection.getRangeAt(0).cloneContents();
const tempDOM = document.createDocumentFragment();
/**
* Process a node, transforming <q> elements to <span> elements and preserving children.
* @param {Node} node Input node
* @returns {Node} Processed node
*/
function processNode(node) {
if (node.nodeType === Node.ELEMENT_NODE && node.tagName.toLowerCase() === 'q') {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === 'q') {
// Transform <q> to <span>, preserve children
const span = document.createElement('span');

View File

@ -83,9 +83,9 @@ export function setNovelData(data) {
export function getKayraMaxContextTokens() {
switch (novel_data?.tier) {
case 1:
return 3072;
return 4096;
case 2:
return 6144;
return 8192;
case 3:
return 8192;
}
@ -93,14 +93,14 @@ export function getKayraMaxContextTokens() {
return null;
}
export function getKayraMaxResponseTokens() {
export function getNovelMaxResponseTokens() {
switch (novel_data?.tier) {
case 1:
return 100;
case 2:
return 100;
case 3:
return 150;
case 2:
return 150;
case 3:
return 250;
}
return maximum_output_length;
@ -546,7 +546,7 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper
finalPrompt = '<|startoftext|><|reserved_special_token81|>' + finalPrompt;
}
const adjustedMaxLength = (isKayra || isErato) ? getKayraMaxResponseTokens() : maximum_output_length;
const adjustedMaxLength = (isKayra || isErato) ? getNovelMaxResponseTokens() : maximum_output_length;
return {
'input': finalPrompt,

View File

@ -289,15 +289,19 @@ export async function loadFeatherlessModels(data) {
originalModels = data; // Store the original data for search
featherlessModels = data;
if (!data.find(x => x.id === textgen_settings.featherless_model)) {
textgen_settings.featherless_model = data[0]?.id || '';
}
// Populate class select options with unique classes
populateClassSelection(data);
// Retrieve the stored number of items per page or default to 5
// Retrieve the stored number of items per page or default to 10
const perPage = Number(localStorage.getItem(storageKey)) || 10;
// Initialize pagination with the full set of models
const selectedModelPage = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1;
featherlessCurrentPage = selectedModelPage > 0 ? selectedModelPage : 1;
const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model);
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
setupPagination(originalModels, perPage);
// Function to set up pagination (also used for filtered results)