mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into webpack
This commit is contained in:
@ -6,6 +6,10 @@ function sanitizeInlineQuotationOnCopy() {
|
|||||||
// STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied.
|
// 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().
|
// To work around this, take the selection and transform <q> to <span> before calling toString().
|
||||||
document.addEventListener('copy', function (event) {
|
document.addEventListener('copy', function (event) {
|
||||||
|
if (document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
if (!selection.anchorNode?.parentElement.closest('.mes_text')) {
|
if (!selection.anchorNode?.parentElement.closest('.mes_text')) {
|
||||||
return;
|
return;
|
||||||
@ -14,8 +18,13 @@ function sanitizeInlineQuotationOnCopy() {
|
|||||||
const range = selection.getRangeAt(0).cloneContents();
|
const range = selection.getRangeAt(0).cloneContents();
|
||||||
const tempDOM = document.createDocumentFragment();
|
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) {
|
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
|
// Transform <q> to <span>, preserve children
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ export function setNovelData(data) {
|
|||||||
export function getKayraMaxContextTokens() {
|
export function getKayraMaxContextTokens() {
|
||||||
switch (novel_data?.tier) {
|
switch (novel_data?.tier) {
|
||||||
case 1:
|
case 1:
|
||||||
return 3072;
|
return 4096;
|
||||||
case 2:
|
case 2:
|
||||||
return 6144;
|
return 8192;
|
||||||
case 3:
|
case 3:
|
||||||
return 8192;
|
return 8192;
|
||||||
}
|
}
|
||||||
@ -93,14 +93,14 @@ export function getKayraMaxContextTokens() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getKayraMaxResponseTokens() {
|
export function getNovelMaxResponseTokens() {
|
||||||
switch (novel_data?.tier) {
|
switch (novel_data?.tier) {
|
||||||
case 1:
|
case 1:
|
||||||
return 100;
|
|
||||||
case 2:
|
|
||||||
return 100;
|
|
||||||
case 3:
|
|
||||||
return 150;
|
return 150;
|
||||||
|
case 2:
|
||||||
|
return 150;
|
||||||
|
case 3:
|
||||||
|
return 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
return maximum_output_length;
|
return maximum_output_length;
|
||||||
@ -546,7 +546,7 @@ export function getNovelGenerationData(finalPrompt, settings, maxLength, isImper
|
|||||||
finalPrompt = '<|startoftext|><|reserved_special_token81|>' + finalPrompt;
|
finalPrompt = '<|startoftext|><|reserved_special_token81|>' + finalPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const adjustedMaxLength = (isKayra || isErato) ? getKayraMaxResponseTokens() : maximum_output_length;
|
const adjustedMaxLength = (isKayra || isErato) ? getNovelMaxResponseTokens() : maximum_output_length;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'input': finalPrompt,
|
'input': finalPrompt,
|
||||||
|
@ -289,15 +289,19 @@ export async function loadFeatherlessModels(data) {
|
|||||||
originalModels = data; // Store the original data for search
|
originalModels = data; // Store the original data for search
|
||||||
featherlessModels = data;
|
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
|
// Populate class select options with unique classes
|
||||||
populateClassSelection(data);
|
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;
|
const perPage = Number(localStorage.getItem(storageKey)) || 10;
|
||||||
|
|
||||||
// Initialize pagination with the full set of models
|
// Initialize pagination with the full set of models
|
||||||
const selectedModelPage = (data.findIndex(x => x.id === textgen_settings.featherless_model) / perPage) + 1;
|
const currentModelIndex = data.findIndex(x => x.id === textgen_settings.featherless_model);
|
||||||
featherlessCurrentPage = selectedModelPage > 0 ? selectedModelPage : 1;
|
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
|
||||||
setupPagination(originalModels, perPage);
|
setupPagination(originalModels, perPage);
|
||||||
|
|
||||||
// Function to set up pagination (also used for filtered results)
|
// Function to set up pagination (also used for filtered results)
|
||||||
|
Reference in New Issue
Block a user