mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/Cohee1207/SillyTavern into dev
This commit is contained in:
@@ -873,6 +873,36 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title">
|
||||
Epsilon Cutoff
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="epsilon_cutoff_textgenerationwebui" name="volume" min="0" max="9" step="0.01">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="epsilon_cutoff_textgenerationwebui" id="epsilon_cutoff_counter_textgenerationwebui">
|
||||
select
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div class="range-block-title">
|
||||
Eta Cutoff
|
||||
</div>
|
||||
<div class="range-block-range-and-counter">
|
||||
<div class="range-block-range">
|
||||
<input type="range" id="eta_cutoff_textgenerationwebui" name="volume" min="0" max="20" step="0.01">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<div contenteditable="true" data-for="eta_cutoff_textgenerationwebui" id="eta_cutoff_counter_textgenerationwebui">
|
||||
select
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<label class="checkbox_label" for="streaming_textgenerationwebui">
|
||||
<input type="checkbox" id="streaming_textgenerationwebui" />
|
||||
@@ -1943,7 +1973,7 @@
|
||||
<div id="world_popup_new" class="menu_button fa-solid fa-plus" title="New Entry"></div>
|
||||
<div class="flex-container">
|
||||
<form id="form_world_import" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<input type="file" id="world_import_file" accept=".json" name="avatar" hidden>
|
||||
<input type="file" id="world_import_file" accept=".json,.lorebook" name="avatar" hidden>
|
||||
</form>
|
||||
<form id="form_rename_world" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<div id="world_create_button" class="menu_button fa-solid fa-globe fa-fw" title="Create"></div>
|
||||
|
@@ -17,6 +17,8 @@ let textgenerationwebui_settings = {
|
||||
top_k: 40,
|
||||
top_a: 0,
|
||||
tfs: 1,
|
||||
epsilon_cutoff: 0,
|
||||
eta_cutoff: 0,
|
||||
typical_p: 1,
|
||||
rep_pen: 1.2,
|
||||
no_repeat_ngram_size: 0,
|
||||
@@ -49,6 +51,8 @@ const setting_names = [
|
||||
"top_p",
|
||||
"top_a",
|
||||
"tfs",
|
||||
"epsilon_cutoff",
|
||||
"eta_cutoff",
|
||||
"typical_p",
|
||||
"penalty_alpha",
|
||||
"num_beams",
|
||||
@@ -218,5 +222,7 @@ export function getTextGenGenerationData(finalPromt, this_amount_gen, isImperson
|
||||
'skip_special_tokens': textgenerationwebui_settings.skip_special_tokens,
|
||||
'top_a': textgenerationwebui_settings.top_a,
|
||||
'tfs': textgenerationwebui_settings.tfs,
|
||||
'epsilon_cutoff': textgenerationwebui_settings.epsilon_cutoff,
|
||||
'eta_cutoff': textgenerationwebui_settings.eta_cutoff,
|
||||
};
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters } from "../script.js";
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight } from "./utils.js";
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile } from "./utils.js";
|
||||
import { getContext } from "./extensions.js";
|
||||
import { metadata_keys, shouldWIAddPrompt } from "./extensions/floating-prompt/index.js";
|
||||
import { registerSlashCommand } from "./slash-commands.js";
|
||||
@@ -823,6 +823,35 @@ function matchKeys(haystack, needle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function convertNovelLorebook(inputObj) {
|
||||
const outputObj = {
|
||||
entries: {}
|
||||
};
|
||||
|
||||
inputObj.entries.forEach((entry, index) => {
|
||||
const displayName = entry.displayName;
|
||||
const addMemo = displayName !== undefined && displayName.trim() !== '';
|
||||
|
||||
outputObj.entries[index] = {
|
||||
uid: index,
|
||||
key: entry.keys,
|
||||
keysecondary: [],
|
||||
comment: displayName || '',
|
||||
content: entry.text,
|
||||
constant: false,
|
||||
selective: false,
|
||||
order: entry.contextConfig?.budgetPriority ?? 0,
|
||||
position: 0,
|
||||
disable: !entry.enabled,
|
||||
addMemo: addMemo,
|
||||
excludeRecursion: false,
|
||||
displayIndex: index,
|
||||
};
|
||||
});
|
||||
|
||||
return outputObj;
|
||||
}
|
||||
|
||||
function convertCharacterBook(characterBook) {
|
||||
const result = { entries: {} };
|
||||
|
||||
@@ -913,20 +942,29 @@ jQuery(() => {
|
||||
$("#world_import_file").trigger('click');
|
||||
});
|
||||
|
||||
$("#world_import_file").on("change", function (e) {
|
||||
var file = e.target.files[0];
|
||||
$("#world_import_file").on("change", async function (e) {
|
||||
const file = e.target.files[0];
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ext = file.name.match(/\.(\w+)$/);
|
||||
if (!ext || ext[1].toLowerCase() !== "json") {
|
||||
const formData = new FormData($("#form_world_import").get(0));
|
||||
|
||||
try {
|
||||
// File should be a JSON file
|
||||
const jsonData = await parseJsonFile(file);
|
||||
|
||||
// Convert Novel Lorebook
|
||||
if (jsonData.lorebookVersion !== undefined) {
|
||||
formData.append('convertedData', JSON.stringify(convertNovelLorebook(jsonData)));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
toastr.error(`Error parsing file: ${error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData($("#form_world_import").get(0));
|
||||
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: "/importworldinfo",
|
||||
|
14
server.js
14
server.js
@@ -2105,15 +2105,17 @@ app.post("/importchat", urlencodedParser, function (request, response) {
|
||||
app.post('/importworldinfo', urlencodedParser, (request, response) => {
|
||||
if (!request.file) return response.sendStatus(400);
|
||||
|
||||
const filename = sanitize(request.file.originalname);
|
||||
const filename = `${path.parse(sanitize(request.file.originalname)).name}.json`;
|
||||
|
||||
if (path.parse(filename).ext.toLowerCase() !== '.json') {
|
||||
return response.status(400).send('Only JSON files are supported.')
|
||||
let fileContents = null;
|
||||
|
||||
if (request.body.convertedData) {
|
||||
fileContents = request.body.convertedData;
|
||||
} else {
|
||||
const pathToUpload = path.join('./uploads/', request.file.filename);
|
||||
fileContents = fs.readFileSync(pathToUpload, 'utf8');
|
||||
}
|
||||
|
||||
const pathToUpload = path.join('./uploads/', request.file.filename);
|
||||
const fileContents = fs.readFileSync(pathToUpload, 'utf8');
|
||||
|
||||
try {
|
||||
const worldContent = json5.parse(fileContents);
|
||||
if (!('entries' in worldContent)) {
|
||||
|
Reference in New Issue
Block a user