mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/SillyLossy/TavernAI into dev
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
<script type="module" src="scripts/group-chats.js"></script>
|
<script type="module" src="scripts/group-chats.js"></script>
|
||||||
<script type="module" src="scripts/power-user.js"></script>
|
<script type="module" src="scripts/power-user.js"></script>
|
||||||
<script type="module" src="scripts/kai-settings.js"></script>
|
<script type="module" src="scripts/kai-settings.js"></script>
|
||||||
|
<script type="module" src="scripts/textgen-settings.js"></script>
|
||||||
|
|
||||||
<title>Tavern.AI</title>
|
<title>Tavern.AI</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -122,7 +123,7 @@
|
|||||||
<h4>API key</h4>
|
<h4>API key</h4>
|
||||||
<h5>Where to get (<a href="/notes/6" target="_blank">?</a>)</h5>
|
<h5>Where to get (<a href="/notes/6" target="_blank">?</a>)</h5>
|
||||||
<input id="api_key_novel" name="api_key_novel" class="text_pole" maxlength="500" size="35" value="" autocomplete="off">
|
<input id="api_key_novel" name="api_key_novel" class="text_pole" maxlength="500" size="35" value="" autocomplete="off">
|
||||||
<input id="api_button_novel" type="submit" value="Connect">
|
<input id="api_button_novel" class="menu_button" type="submit" value="Connect">
|
||||||
<img id="api_loading_novel" src="img/load.svg">
|
<img id="api_loading_novel" src="img/load.svg">
|
||||||
</form>
|
</form>
|
||||||
<div id="online_status3">
|
<div id="online_status3">
|
||||||
@@ -137,11 +138,13 @@
|
|||||||
<select id="model_novel_select" class="option_select_right_menu" style='margin-bottom: 16px;'>
|
<select id="model_novel_select" class="option_select_right_menu" style='margin-bottom: 16px;'>
|
||||||
<option value="euterpe-v2">Euterpe</option>
|
<option value="euterpe-v2">Euterpe</option>
|
||||||
<option value="krake-v2">Krake</option>
|
<option value="krake-v2">Krake</option>
|
||||||
</select><br>
|
</select>
|
||||||
|
<h4>
|
||||||
Preset settings
|
Preset settings
|
||||||
<a href="/notes/7" class="notes-link" target="_blank">
|
<a href="/notes/7" class="notes-link" target="_blank">
|
||||||
<span class="note-link-span">?</span>
|
<span class="note-link-span">?</span>
|
||||||
</a><br>
|
</a>
|
||||||
|
</h4>
|
||||||
<select id="settings_perset_novel" class="option_select_right_menu">
|
<select id="settings_perset_novel" class="option_select_right_menu">
|
||||||
<option value="gui">Default</option>
|
<option value="gui">Default</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -152,12 +155,15 @@
|
|||||||
oobabooga/text-generation-webui
|
oobabooga/text-generation-webui
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<span>Make sure you run it:
|
<span>
|
||||||
|
Make sure you run it:
|
||||||
<ul>
|
<ul>
|
||||||
<li>with
|
<li>
|
||||||
|
with
|
||||||
<pre>--no-stream</pre> option
|
<pre>--no-stream</pre> option
|
||||||
</li>
|
</li>
|
||||||
<li>in notebook mode (not
|
<li>
|
||||||
|
in notebook mode (not
|
||||||
<pre>--cai-chat</pre> or
|
<pre>--cai-chat</pre> or
|
||||||
<pre>--chat</pre>)
|
<pre>--chat</pre>)
|
||||||
</li>
|
</li>
|
||||||
@@ -1040,8 +1046,8 @@
|
|||||||
<div class=mes_edit_done><img src=img/done.png></div>
|
<div class=mes_edit_done><img src=img/done.png></div>
|
||||||
</div>
|
</div>
|
||||||
<div class=mes_text></div>
|
<div class=mes_text></div>
|
||||||
|
<div class="mes_bias"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mes_bias">${bias}</div>
|
|
||||||
<div class="swipe_right">
|
<div class="swipe_right">
|
||||||
<img src="img/swipe_right.png">
|
<img src="img/swipe_right.png">
|
||||||
<div class="swipes-counter"></div>
|
<div class="swipes-counter"></div>
|
||||||
|
@@ -6,6 +6,11 @@ import {
|
|||||||
loadKoboldSettings,
|
loadKoboldSettings,
|
||||||
} from "./scripts/kai-settings.js";
|
} from "./scripts/kai-settings.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
textgenerationwebui_settings,
|
||||||
|
loadTextGenSettings,
|
||||||
|
} from "./scripts/textgen-settings.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
world_info_budget,
|
world_info_budget,
|
||||||
world_info_data,
|
world_info_data,
|
||||||
@@ -246,16 +251,6 @@ var user_avatar = "you.png";
|
|||||||
var amount_gen = 80; //default max length of AI generated responses
|
var amount_gen = 80; //default max length of AI generated responses
|
||||||
var max_context = 2048;
|
var max_context = 2048;
|
||||||
|
|
||||||
var textgenerationwebui_settings = {
|
|
||||||
temp: 0.5,
|
|
||||||
top_p: 0.9,
|
|
||||||
top_k: 0,
|
|
||||||
typical_p: 1,
|
|
||||||
rep_pen: 1.1,
|
|
||||||
rep_pen_size: 0,
|
|
||||||
penalty_alpha: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
var is_pygmalion = false;
|
var is_pygmalion = false;
|
||||||
var tokens_already_generated = 0;
|
var tokens_already_generated = 0;
|
||||||
var message_already_generated = "";
|
var message_already_generated = "";
|
||||||
@@ -1974,8 +1969,7 @@ async function getSettings(type) {
|
|||||||
|
|
||||||
//Load AI model config settings (temp, context length, anchors, and anchor order)
|
//Load AI model config settings (temp, context length, anchors, and anchor order)
|
||||||
|
|
||||||
textgenerationwebui_settings =
|
loadTextGenSettings(settings.textgenerationwebui_settings);
|
||||||
settings.textgenerationwebui_settings || textgenerationwebui_settings;
|
|
||||||
|
|
||||||
amount_gen = settings.amount_gen;
|
amount_gen = settings.amount_gen;
|
||||||
if (settings.max_context !== undefined)
|
if (settings.max_context !== undefined)
|
||||||
@@ -2085,23 +2079,6 @@ async function getSettings(type) {
|
|||||||
api_server_textgenerationwebui
|
api_server_textgenerationwebui
|
||||||
);
|
);
|
||||||
|
|
||||||
for (var i of [
|
|
||||||
"temp",
|
|
||||||
"rep_pen",
|
|
||||||
"rep_pen_size",
|
|
||||||
"top_k",
|
|
||||||
"top_p",
|
|
||||||
"typical_p",
|
|
||||||
"penalty_alpha",
|
|
||||||
]) {
|
|
||||||
$("#" + i + "_textgenerationwebui").val(
|
|
||||||
textgenerationwebui_settings[i]
|
|
||||||
);
|
|
||||||
$("#" + i + "_counter_textgenerationwebui").html(
|
|
||||||
textgenerationwebui_settings[i]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
selected_button = settings.selected_button;
|
selected_button = settings.selected_button;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3713,31 +3690,6 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (var i of [
|
|
||||||
"temp",
|
|
||||||
"rep_pen",
|
|
||||||
"rep_pen_size",
|
|
||||||
"top_k",
|
|
||||||
"top_p",
|
|
||||||
"typical_p",
|
|
||||||
"penalty_alpha",
|
|
||||||
]) {
|
|
||||||
$("#" + i + "_textgenerationwebui").attr("x-setting-id", i);
|
|
||||||
$(document).on("input", "#" + i + "_textgenerationwebui", function () {
|
|
||||||
var i = $(this).attr("x-setting-id");
|
|
||||||
var val = $(this).val();
|
|
||||||
if (isInt(val)) {
|
|
||||||
$("#" + i + "_counter_textgenerationwebui").html($(this).val() + ".00");
|
|
||||||
} else {
|
|
||||||
$("#" + i + "_counter_textgenerationwebui").html($(this).val());
|
|
||||||
}
|
|
||||||
textgenerationwebui_settings[i] = parseFloat(val);
|
|
||||||
saveSettingsDebounced();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////// OPTIMIZED RANGE SLIDER LISTENERS////////////////
|
////////////////// OPTIMIZED RANGE SLIDER LISTENERS////////////////
|
||||||
|
|
||||||
const sliders = [
|
const sliders = [
|
||||||
|
@@ -8,7 +8,7 @@ import {
|
|||||||
online_status,
|
online_status,
|
||||||
main_api,
|
main_api,
|
||||||
api_server,
|
api_server,
|
||||||
api_key_novel,
|
nai_settings,
|
||||||
api_server_textgenerationwebui,
|
api_server_textgenerationwebui,
|
||||||
is_send_press,
|
is_send_press,
|
||||||
|
|
||||||
|
108
public/scripts/nai-settings.js
Normal file
108
public/scripts/nai-settings.js
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
import {
|
||||||
|
saveSettingsDebounced,
|
||||||
|
} from "../script.js";
|
||||||
|
|
||||||
|
export {
|
||||||
|
nai_settings,
|
||||||
|
loadNovelPreset,
|
||||||
|
loadNovelSettings,
|
||||||
|
getNovelTier,
|
||||||
|
};
|
||||||
|
|
||||||
|
const nai_settings = {
|
||||||
|
temp_novel: 0.5,
|
||||||
|
rep_pen_novel: 1,
|
||||||
|
rep_pen_size_novel: 100,
|
||||||
|
model_novel: "euterpe-v2",
|
||||||
|
api_key_novel: "",
|
||||||
|
preset_settings_novel: "Classic-Euterpe",
|
||||||
|
};
|
||||||
|
|
||||||
|
const nai_tiers = {
|
||||||
|
0: 'Paper',
|
||||||
|
1: 'Tablet',
|
||||||
|
2: 'Scroll',
|
||||||
|
3: 'Opus',
|
||||||
|
};
|
||||||
|
|
||||||
|
function getNovelTier(tier) {
|
||||||
|
return nai_tiers[tier] ?? 'no_connection';
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadNovelPreset(preset) {
|
||||||
|
nai_settings.temp_novel = preset.temperature;
|
||||||
|
nai_settings.rep_pen_novel = preset.repetition_penalty;
|
||||||
|
nai_settings.rep_pen_size_novel = preset.repetition_penalty_range;
|
||||||
|
$("#temp_novel").val(nai_settings.temp_novel);
|
||||||
|
$("#temp_counter_novel").html(nai_settings.temp_novel);
|
||||||
|
|
||||||
|
$("#rep_pen_novel").val(nai_settings.rep_pen_novel);
|
||||||
|
$("#rep_pen_counter_novel").html(nai_settings.rep_pen_novel);
|
||||||
|
|
||||||
|
$("#rep_pen_size_novel").val(nai_settings.rep_pen_size_novel);
|
||||||
|
$("#rep_pen_size_counter_novel").html(`${nai_settings.rep_pen_size_novel} Tokens`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadNovelSettings(settings){
|
||||||
|
//load Novel API KEY is exists
|
||||||
|
if (settings.api_key_novel != undefined) {
|
||||||
|
nai_settings.api_key_novel = settings.api_key_novel;
|
||||||
|
$("#api_key_novel").val(nai_settings.api_key_novel);
|
||||||
|
}
|
||||||
|
|
||||||
|
//load the rest of the Novel settings without any checks
|
||||||
|
nai_settings.model_novel = settings.model_novel;
|
||||||
|
$(`#model_novel_select option[value=${nai_settings.model_novel}]`).attr("selected", true);
|
||||||
|
|
||||||
|
nai_settings.temp_novel = settings.temp_novel;
|
||||||
|
nai_settings.rep_pen_novel = settings.rep_pen_novel;
|
||||||
|
nai_settings.rep_pen_size_novel = settings.rep_pen_size_novel;
|
||||||
|
|
||||||
|
$("#temp_novel").val(nai_settings.temp_novel);
|
||||||
|
$("#temp_counter_novel").text(Number(nai_settings.temp_novel).toFixed(2));
|
||||||
|
|
||||||
|
$("#rep_pen_novel").val(nai_settings.rep_pen_novel);
|
||||||
|
$("#rep_pen_counter_novel").text(Number(nai_settings.rep_pen_novel).toFixed(2));
|
||||||
|
|
||||||
|
$("#rep_pen_size_novel").val(nai_settings.rep_pen_size_novel);
|
||||||
|
$("#rep_pen_size_counter_novel").text(`${nai_settings.rep_pen_size_novel} Tokens`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const sliders = [
|
||||||
|
{
|
||||||
|
sliderId: "#temp_novel",
|
||||||
|
counterId: "#temp_counter_novel",
|
||||||
|
format: (val) => Number(val).toFixed(2),
|
||||||
|
setValue: (val) => { nai_settings.temp_novel = Number(val); },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sliderId: "#rep_pen_novel",
|
||||||
|
counterId: "#rep_pen_counter_novel",
|
||||||
|
format: (val) => Number(val).toFixed(2),
|
||||||
|
setValue: (val) => { nai_settings.rep_pen_novel = Number(val); },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sliderId: "#rep_pen_size_novel",
|
||||||
|
counterId: "#rep_pen_size_counter_novel",
|
||||||
|
format: (val) => `${val} Tokens`,
|
||||||
|
setValue: (val) => { nai_settings.rep_pen_size_novel = Number(val); },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
sliders.forEach(slider => {
|
||||||
|
$(document).on("input", slider.sliderId, function () {
|
||||||
|
const value = $(this).val();
|
||||||
|
const formattedValue = slider.format(value);
|
||||||
|
slider.setValue(value);
|
||||||
|
$(slider.counterId).html(formattedValue);
|
||||||
|
console.log('saving');
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#model_novel_select").change(function () {
|
||||||
|
nai_settings.model_novel = $("#model_novel_select").find(":selected").val();
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
});
|
51
public/scripts/textgen-settings.js
Normal file
51
public/scripts/textgen-settings.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import {
|
||||||
|
saveSettingsDebounced,
|
||||||
|
} from "../script.js";
|
||||||
|
|
||||||
|
export {
|
||||||
|
textgenerationwebui_settings,
|
||||||
|
loadTextGenSettings,
|
||||||
|
}
|
||||||
|
|
||||||
|
let textgenerationwebui_settings = {
|
||||||
|
temp: 0.5,
|
||||||
|
top_p: 0.9,
|
||||||
|
top_k: 0,
|
||||||
|
typical_p: 1,
|
||||||
|
rep_pen: 1.1,
|
||||||
|
rep_pen_size: 0,
|
||||||
|
penalty_alpha: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const setting_names = [
|
||||||
|
"temp",
|
||||||
|
"rep_pen",
|
||||||
|
"rep_pen_size",
|
||||||
|
"top_k",
|
||||||
|
"top_p",
|
||||||
|
"typical_p",
|
||||||
|
"penalty_alpha",
|
||||||
|
];
|
||||||
|
|
||||||
|
function loadTextGenSettings(settings) {
|
||||||
|
textgenerationwebui_settings = settings ? settings : textgenerationwebui_settings;
|
||||||
|
|
||||||
|
for (const i of setting_names) {
|
||||||
|
const val = parseFloat(textgenerationwebui_settings[i]);
|
||||||
|
$(`#${i}_textgenerationwebui`).val(val);
|
||||||
|
$(`#${i}_counter_textgenerationwebui`).text(val.toFixed(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
for (const i of setting_names) {
|
||||||
|
$(`#${i}_textgenerationwebui`).attr("x-setting-id", i);
|
||||||
|
$(document).on("input", `#${i}_textgenerationwebui`, function () {
|
||||||
|
const id = $(this).attr("x-setting-id");
|
||||||
|
const val = parseFloat($(this).val());
|
||||||
|
$(`#${id}_counter_textgenerationwebui`).text(val.toFixed(2));
|
||||||
|
textgenerationwebui_settings[id] = parseFloat(val);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
@@ -787,7 +787,8 @@ img[src*="user-slash-solid.svg"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#api_button:hover,
|
#api_button:hover,
|
||||||
#api_button_novel:hover {
|
#api_button_novel:hover,
|
||||||
|
#api_button_textgenerationwebui {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
server.js
14
server.js
@@ -88,6 +88,11 @@ const directories = {
|
|||||||
avatars: 'public/User Avatars',
|
avatars: 'public/User Avatars',
|
||||||
groups: 'public/groups/',
|
groups: 'public/groups/',
|
||||||
groupChats: 'public/group chats',
|
groupChats: 'public/group chats',
|
||||||
|
chats: 'public/chats/',
|
||||||
|
characters: 'public/characters/',
|
||||||
|
backgrounds: 'public/backgrounds',
|
||||||
|
novelAI_Settings: 'public/NovelAI Settings',
|
||||||
|
koboldAI_Settings: 'public/KoboldAI Settings',
|
||||||
};
|
};
|
||||||
|
|
||||||
// CSRF Protection //
|
// CSRF Protection //
|
||||||
@@ -1597,6 +1602,7 @@ app.listen(server_port, (listen ? '0.0.0.0' : '127.0.0.1'), function () {
|
|||||||
is_colab = true;
|
is_colab = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ensurePublicDirectoriesExist();
|
||||||
console.log('Launching...');
|
console.log('Launching...');
|
||||||
if (autorun) open('http:127.0.0.1:' + server_port);
|
if (autorun) open('http:127.0.0.1:' + server_port);
|
||||||
console.log('TavernAI started: http://127.0.0.1:' + server_port);
|
console.log('TavernAI started: http://127.0.0.1:' + server_port);
|
||||||
@@ -1791,3 +1797,11 @@ function getCharacterFile2(directories, i) {
|
|||||||
convertStage2();
|
convertStage2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensurePublicDirectoriesExist() {
|
||||||
|
for (const dir of Object.values(directories)) {
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user