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:
20
public/NovelAI Settings/Chat-Clio.settings
Normal file
20
public/NovelAI Settings/Chat-Clio.settings
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"order": [
|
||||||
|
1,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"temperature": 1.05,
|
||||||
|
"max_length": 90,
|
||||||
|
"min_length": 1,
|
||||||
|
"tail_free_sampling": 0.989,
|
||||||
|
"repetition_penalty": 1.5,
|
||||||
|
"repetition_penalty_range": 8192,
|
||||||
|
"repetition_penalty_frequency": 0.03,
|
||||||
|
"repetition_penalty_presence": 0.005,
|
||||||
|
"top_a": 0.075,
|
||||||
|
"top_k": 79,
|
||||||
|
"top_p": 0.95
|
||||||
|
}
|
@ -945,7 +945,7 @@
|
|||||||
Influences bot behavior in its responses.
|
Influences bot behavior in its responses.
|
||||||
</div>
|
</div>
|
||||||
<div class="wide100p">
|
<div class="wide100p">
|
||||||
<textarea id="poe_nudge_text" class="text_pole textarea_compact" rows="6" maxlength="250"></textarea>
|
<textarea id="poe_nudge_text" class="text_pole textarea_compact" rows="6" maxlength="2500"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block">
|
<div class="range-block">
|
||||||
@ -959,7 +959,7 @@
|
|||||||
Prompt that is used for Impersonation function
|
Prompt that is used for Impersonation function
|
||||||
</div>
|
</div>
|
||||||
<div class="wide100p">
|
<div class="wide100p">
|
||||||
<textarea id="poe_impersonation_prompt" class="text_pole textarea_compact" rows="6" maxlength="250"></textarea>
|
<textarea id="poe_impersonation_prompt" class="text_pole textarea_compact" rows="6" maxlength="2500"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -980,19 +980,65 @@
|
|||||||
<div id="main-API-selector-block">
|
<div id="main-API-selector-block">
|
||||||
<select id="main_api">
|
<select id="main_api">
|
||||||
<option value="kobold">KoboldAI</option>
|
<option value="kobold">KoboldAI</option>
|
||||||
|
<option value="koboldhorde">KoboldAI Horde</option>
|
||||||
<option value="textgenerationwebui">Text Gen WebUI (ooba)</option>
|
<option value="textgenerationwebui">Text Gen WebUI (ooba)</option>
|
||||||
<option value="novel">NovelAI</option>
|
<option value="novel">NovelAI</option>
|
||||||
<option value="openai">OpenAI</option>
|
<option value="openai">OpenAI</option>
|
||||||
<option value="poe">Poe</option>
|
<option value="poe">Poe</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="kobold_api" style="position: relative;"> <!-- shows the kobold settings -->
|
<div id="kobold_horde" style="position: relative;"> <!-- shows the kobold settings -->
|
||||||
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||||
<label for="use_horde" class="checkbox_label">
|
<div id="kobold_horde_block">
|
||||||
<input id="use_horde" type="checkbox" />
|
<ul>
|
||||||
Use Horde
|
<li>
|
||||||
|
<a target="_blank" href="https://horde.koboldai.net/register">Register a Horde account for faster queue times</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a target="_blank" href="https://github.com/db0/AI-Horde-Worker#readme">Learn how to contribute your idle GPU cycles to the Horde</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<label for="horde_auto_adjust_context_length" class="checkbox_label">
|
||||||
|
<input id="horde_auto_adjust_context_length" type="checkbox" />
|
||||||
|
Adjust context size to worker capabilities
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label for="horde_auto_adjust_response_length" class="checkbox_label">
|
||||||
|
<input id="horde_auto_adjust_response_length" type="checkbox" />
|
||||||
|
Adjust response length to worker capabilities
|
||||||
|
</label>
|
||||||
|
<h4>API key</h4>
|
||||||
|
<h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a><br>
|
||||||
|
Enter <span class="monospace">0000000000</span> to use anonymous mode.
|
||||||
|
</h5>
|
||||||
|
<div>
|
||||||
|
<a id="horde_kudos" href="javascript:void(0);">View my Kudos</a>
|
||||||
|
</div>
|
||||||
|
<div class="flex-container">
|
||||||
|
<input id="horde_api_key" name="horde_api_key" class="text_pole flex1" maxlength="500" type="text" placeholder="0000000000" autocomplete="off">
|
||||||
|
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_horde"></div>
|
||||||
|
</div>
|
||||||
|
<div class="neutral_warning">For privacy reasons, your API key will be hidden after you reload the page.</div>
|
||||||
|
<h4 class="horde_model_title">
|
||||||
|
Model
|
||||||
|
<div id="horde_refresh" title="Refresh models" class="right_menu_button">
|
||||||
|
<div class="fa-solid fa-repeat "></div>
|
||||||
|
</div>
|
||||||
|
</h4>
|
||||||
|
<small class="horde_multiple_hint">Hold Control / Command key to select multiple models.</small>
|
||||||
|
<select id="horde_model" multiple>
|
||||||
|
<option>-- Horde models not loaded --</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="online_status_horde">
|
||||||
|
<div id="online_status_indicator_horde"></div>
|
||||||
|
<div id="online_status_text_horde">Not connected</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="kobold_api" style="position: relative;"> <!-- shows the kobold settings -->
|
||||||
|
<form action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||||
<div id="kobold_api_block">
|
<div id="kobold_api_block">
|
||||||
<h4>API url</h4>
|
<h4>API url</h4>
|
||||||
<h5>Example: http://127.0.0.1:5000/api </h5>
|
<h5>Example: http://127.0.0.1:5000/api </h5>
|
||||||
@ -1000,48 +1046,6 @@
|
|||||||
<input id="api_button" class="menu_button" type="submit" value="Connect">
|
<input id="api_button" class="menu_button" type="submit" value="Connect">
|
||||||
<div id="api_loading" class="api-load-icon fa-solid fa-hourglass fa-spin"></div>
|
<div id="api_loading" class="api-load-icon fa-solid fa-hourglass fa-spin"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="kobold_horde_block">
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a target="_blank" href="https://horde.koboldai.net/register">Register a Horde account for faster queue times</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a target="_blank" href="https://github.com/db0/AI-Horde-Worker#readme">Learn how to contribute your idle GPU cycles to the Horde</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<label for="horde_auto_adjust_context_length" class="checkbox_label">
|
|
||||||
<input id="horde_auto_adjust_context_length" type="checkbox" />
|
|
||||||
Adjust context size to worker capabilities
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label for="horde_auto_adjust_response_length" class="checkbox_label">
|
|
||||||
<input id="horde_auto_adjust_response_length" type="checkbox" />
|
|
||||||
Adjust response length to worker capabilities
|
|
||||||
</label>
|
|
||||||
<h4>API key</h4>
|
|
||||||
<h5>Get it here: <a target="_blank" href="https://horde.koboldai.net/register">Register</a><br>
|
|
||||||
Enter <span class="monospace">0000000000</span> to use anonymous mode.
|
|
||||||
</h5>
|
|
||||||
<div>
|
|
||||||
<a id="horde_kudos" href="javascript:void(0);">View my Kudos</a>
|
|
||||||
</div>
|
|
||||||
<div class="flex-container">
|
|
||||||
<input id="horde_api_key" name="horde_api_key" class="text_pole flex1" maxlength="500" type="text" placeholder="0000000000" autocomplete="off">
|
|
||||||
<div title="Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_horde"></div>
|
|
||||||
</div>
|
|
||||||
<div class="neutral_warning">For privacy reasons, your API key will be hidden after you reload the page.</div>
|
|
||||||
<h4 class="horde_model_title">
|
|
||||||
Model
|
|
||||||
<div id="horde_refresh" title="Refresh models" class="right_menu_button">
|
|
||||||
<div class="fa-solid fa-repeat "></div>
|
|
||||||
</div>
|
|
||||||
</h4>
|
|
||||||
<small class="horde_multiple_hint">Hold Control / Command key to select multiple models.</small>
|
|
||||||
<select id="horde_model" multiple>
|
|
||||||
<option>-- Horde models not loaded --</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div id="online_status2">
|
<div id="online_status2">
|
||||||
<div id="online_status_indicator2"></div>
|
<div id="online_status_indicator2"></div>
|
||||||
<div id="online_status_text2">Not connected</div>
|
<div id="online_status_text2">Not connected</div>
|
||||||
@ -1075,6 +1079,7 @@
|
|||||||
<select id="model_novel_select">
|
<select id="model_novel_select">
|
||||||
<option value="euterpe-v2">Euterpe</option>
|
<option value="euterpe-v2">Euterpe</option>
|
||||||
<option value="krake-v2">Krake</option>
|
<option value="krake-v2">Krake</option>
|
||||||
|
<option value="clio-v1">Clio</option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
<div id="online_status3">
|
<div id="online_status3">
|
||||||
|
145
public/script.js
145
public/script.js
@ -105,6 +105,7 @@ import {
|
|||||||
generatePoe,
|
generatePoe,
|
||||||
is_get_status_poe,
|
is_get_status_poe,
|
||||||
setPoeOnlineStatus,
|
setPoeOnlineStatus,
|
||||||
|
appendPoeAnchors,
|
||||||
} from "./scripts/poe.js";
|
} from "./scripts/poe.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -628,6 +629,8 @@ function checkOnlineStatus() {
|
|||||||
if (online_status == "no_connection") {
|
if (online_status == "no_connection") {
|
||||||
$("#online_status_indicator2").css("background-color", "red"); //Kobold
|
$("#online_status_indicator2").css("background-color", "red"); //Kobold
|
||||||
$("#online_status_text2").html("No connection...");
|
$("#online_status_text2").html("No connection...");
|
||||||
|
$("#online_status_indicator_horde").css("background-color", "red"); //Kobold Horde
|
||||||
|
$("#online_status_text_horde").html("No connection...");
|
||||||
$("#online_status_indicator3").css("background-color", "red"); //Novel
|
$("#online_status_indicator3").css("background-color", "red"); //Novel
|
||||||
$("#online_status_text3").html("No connection...");
|
$("#online_status_text3").html("No connection...");
|
||||||
$(".online_status_indicator4").css("background-color", "red"); //OAI / ooba
|
$(".online_status_indicator4").css("background-color", "red"); //OAI / ooba
|
||||||
@ -639,6 +642,8 @@ function checkOnlineStatus() {
|
|||||||
} else {
|
} else {
|
||||||
$("#online_status_indicator2").css("background-color", "green"); //kobold
|
$("#online_status_indicator2").css("background-color", "green"); //kobold
|
||||||
$("#online_status_text2").html(online_status);
|
$("#online_status_text2").html(online_status);
|
||||||
|
$("#online_status_indicator_horde").css("background-color", "green"); //Kobold Horde
|
||||||
|
$("#online_status_text_horde").html(online_status);
|
||||||
$("#online_status_indicator3").css("background-color", "green"); //novel
|
$("#online_status_indicator3").css("background-color", "green"); //novel
|
||||||
$("#online_status_text3").html(online_status);
|
$("#online_status_text3").html(online_status);
|
||||||
$(".online_status_indicator4").css("background-color", "green"); //OAI / ooba
|
$(".online_status_indicator4").css("background-color", "green"); //OAI / ooba
|
||||||
@ -648,7 +653,7 @@ function checkOnlineStatus() {
|
|||||||
|
|
||||||
async function getStatus() {
|
async function getStatus() {
|
||||||
if (is_get_status) {
|
if (is_get_status) {
|
||||||
if (main_api == "kobold" && horde_settings.use_horde) {
|
if (main_api == "koboldhorde") {
|
||||||
try {
|
try {
|
||||||
const hordeStatus = await checkHordeStatus();
|
const hordeStatus = await checkHordeStatus();
|
||||||
online_status = hordeStatus ? 'Connected' : 'no_connection';
|
online_status = hordeStatus ? 'Connected' : 'no_connection';
|
||||||
@ -694,7 +699,7 @@ async function getStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine if we can use stop sequence
|
// determine if we can use stop sequence
|
||||||
if (main_api == "kobold") {
|
if (main_api === "kobold" || main_api === "koboldhorde") {
|
||||||
kai_settings.use_stop_sequence = canUseKoboldStopSequence(data.version);
|
kai_settings.use_stop_sequence = canUseKoboldStopSequence(data.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1896,7 +1901,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
|
|
||||||
// Adjust token limit for Horde
|
// Adjust token limit for Horde
|
||||||
let adjustedParams;
|
let adjustedParams;
|
||||||
if (main_api == 'kobold' && horde_settings.use_horde && (horde_settings.auto_adjust_context_length || horde_settings.auto_adjust_response_length)) {
|
if (main_api == 'koboldhorde' && (horde_settings.auto_adjust_context_length || horde_settings.auto_adjust_response_length)) {
|
||||||
try {
|
try {
|
||||||
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
|
adjustedParams = await adjustHordeGenerationParams(max_context, amount_gen);
|
||||||
}
|
}
|
||||||
@ -1910,11 +1915,17 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extension added strings
|
// Extension added strings
|
||||||
const allAnchors = getAllExtensionPrompts();
|
let allAnchors = getAllExtensionPrompts();
|
||||||
const afterScenarioAnchor = getExtensionPrompt(extension_prompt_types.AFTER_SCENARIO);
|
const afterScenarioAnchor = getExtensionPrompt(extension_prompt_types.AFTER_SCENARIO);
|
||||||
let zeroDepthAnchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, 0, ' ');
|
let zeroDepthAnchor = getExtensionPrompt(extension_prompt_types.IN_CHAT, 0, ' ');
|
||||||
let { worldInfoString, worldInfoBefore, worldInfoAfter } = getWorldInfoPrompt(chat2);
|
let { worldInfoString, worldInfoBefore, worldInfoAfter } = getWorldInfoPrompt(chat2);
|
||||||
|
|
||||||
|
// Moved here to not overflow the Poe context with added prompt bits
|
||||||
|
if (main_api == 'poe') {
|
||||||
|
allAnchors = appendPoeAnchors(type, allAnchors);
|
||||||
|
zeroDepthAnchor = appendPoeAnchors(type, zeroDepthAnchor);
|
||||||
|
}
|
||||||
|
|
||||||
// hack for regeneration of the first message
|
// hack for regeneration of the first message
|
||||||
if (chat2.length == 0) {
|
if (chat2.length == 0) {
|
||||||
chat2.push('');
|
chat2.push('');
|
||||||
@ -2162,7 +2173,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
|
|
||||||
let thisPromptBits = [];
|
let thisPromptBits = [];
|
||||||
|
|
||||||
if (main_api == 'kobold' && horde_settings.use_horde && horde_settings.auto_adjust_response_length) {
|
if (main_api == 'koboldhorde' && horde_settings.auto_adjust_response_length) {
|
||||||
this_amount_gen = Math.min(this_amount_gen, adjustedParams.maxLength);
|
this_amount_gen = Math.min(this_amount_gen, adjustedParams.maxLength);
|
||||||
this_amount_gen = Math.max(this_amount_gen, MIN_AMOUNT_GEN); // prevent validation errors
|
this_amount_gen = Math.max(this_amount_gen, MIN_AMOUNT_GEN); // prevent validation errors
|
||||||
}
|
}
|
||||||
@ -2178,17 +2189,20 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
singleline: kai_settings.single_line,
|
singleline: kai_settings.single_line,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (preset_settings != 'gui' || horde_settings.use_horde) {
|
}
|
||||||
const maxContext = horde_settings.use_horde && horde_settings.auto_adjust_context_length ? adjustedParams.maxContextLength : max_context;
|
else if (main_api == 'koboldhorde') {
|
||||||
|
if (preset_settings != 'gui') {
|
||||||
|
const maxContext = horde_settings.auto_adjust_context_length ? adjustedParams.maxContextLength : max_context;
|
||||||
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, maxContext, isImpersonate);
|
generate_data = getKoboldGenerationData(finalPromt, this_settings, this_amount_gen, maxContext, isImpersonate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (main_api == 'textgenerationwebui') {
|
else if (main_api == 'textgenerationwebui') {
|
||||||
generate_data = getTextGenGenerationData(finalPromt, this_amount_gen, isImpersonate);
|
generate_data = getTextGenGenerationData(finalPromt, this_amount_gen, isImpersonate);
|
||||||
}
|
}
|
||||||
else if (main_api == 'novel') {
|
else if (main_api == 'novel') {
|
||||||
const this_settings = novelai_settings[novelai_setting_names[nai_settings.preset_settings_novel]];
|
const this_settings = novelai_settings[novelai_setting_names[nai_settings.preset_settings_novel]];
|
||||||
generate_data = getNovelGenerationData(finalPromt, this_settings);
|
generate_data = getNovelGenerationData(finalPromt, this_settings, this_amount_gen);
|
||||||
}
|
}
|
||||||
else if (main_api == 'openai') {
|
else if (main_api == 'openai') {
|
||||||
let [prompt, counts] = await prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldInfoAfter, afterScenarioAnchor, promptBias, type, quiet_prompt);
|
let [prompt, counts] = await prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldInfoAfter, afterScenarioAnchor, promptBias, type, quiet_prompt);
|
||||||
@ -2223,7 +2237,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
sendOpenAIRequest(type, generate_data.prompt, abortController.signal).then(onSuccess).catch(onError);
|
sendOpenAIRequest(type, generate_data.prompt, abortController.signal).then(onSuccess).catch(onError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (main_api == 'kobold' && horde_settings.use_horde) {
|
else if (main_api == 'koboldhorde') {
|
||||||
generateHorde(finalPromt, generate_data).then(onSuccess).catch(onError);
|
generateHorde(finalPromt, generate_data).then(onSuccess).catch(onError);
|
||||||
}
|
}
|
||||||
else if (main_api == 'poe') {
|
else if (main_api == 'poe') {
|
||||||
@ -2484,14 +2498,14 @@ function sendMessageAsUser(textareaText, messageBias) {
|
|||||||
|
|
||||||
function getMaxContextSize() {
|
function getMaxContextSize() {
|
||||||
let this_max_context = 1487;
|
let this_max_context = 1487;
|
||||||
if (main_api == 'kobold' || main_api == 'textgenerationwebui') {
|
if (main_api == 'kobold' || main_api == 'koboldhorde' || main_api == 'textgenerationwebui') {
|
||||||
this_max_context = (max_context - amount_gen);
|
this_max_context = (max_context - amount_gen);
|
||||||
}
|
}
|
||||||
if (main_api == 'novel') {
|
if (main_api == 'novel') {
|
||||||
if (novel_tier === 1) {
|
if (novel_tier === 1) {
|
||||||
this_max_context = 1024;
|
this_max_context = 1024;
|
||||||
} else {
|
} else {
|
||||||
this_max_context = 2048 - 60; //fix for fat tokens
|
this_max_context = Number(max_context);
|
||||||
if (nai_settings.model_novel == 'krake-v2') {
|
if (nai_settings.model_novel == 'krake-v2') {
|
||||||
this_max_context -= 160;
|
this_max_context -= 160;
|
||||||
}
|
}
|
||||||
@ -2944,19 +2958,22 @@ function getTextGenGenerationData(finalPromt, this_amount_gen, isImpersonate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to nai-settings.js
|
// TODO: move to nai-settings.js
|
||||||
function getNovelGenerationData(finalPromt, this_settings) {
|
function getNovelGenerationData(finalPromt, this_settings, this_amount_gen) {
|
||||||
return {
|
return {
|
||||||
"input": finalPromt,
|
"input": finalPromt,
|
||||||
"model": nai_settings.model_novel,
|
"model": nai_settings.model_novel,
|
||||||
"use_string": true,
|
"use_string": true,
|
||||||
"temperature": parseFloat(nai_settings.temp_novel),
|
"temperature": parseFloat(nai_settings.temp_novel),
|
||||||
"max_length": this_settings.max_length,
|
"max_length": this_amount_gen, // this_settings.max_length, // <= why?
|
||||||
"min_length": this_settings.min_length,
|
"min_length": this_settings.min_length,
|
||||||
"tail_free_sampling": this_settings.tail_free_sampling,
|
"tail_free_sampling": this_settings.tail_free_sampling,
|
||||||
"repetition_penalty": parseFloat(nai_settings.rep_pen_novel),
|
"repetition_penalty": parseFloat(nai_settings.rep_pen_novel),
|
||||||
"repetition_penalty_range": parseInt(nai_settings.rep_pen_size_novel),
|
"repetition_penalty_range": parseInt(nai_settings.rep_pen_size_novel),
|
||||||
"repetition_penalty_frequency": this_settings.repetition_penalty_frequency,
|
"repetition_penalty_frequency": this_settings.repetition_penalty_frequency,
|
||||||
"repetition_penalty_presence": this_settings.repetition_penalty_presence,
|
"repetition_penalty_presence": this_settings.repetition_penalty_presence,
|
||||||
|
"top_a": this_settings.top_a,
|
||||||
|
"top_p": this_settings.top_p,
|
||||||
|
"top_k": this_settings.top_k,
|
||||||
//"stop_sequences": {{187}},
|
//"stop_sequences": {{187}},
|
||||||
//bad_words_ids = {{50256}, {0}, {1}};
|
//bad_words_ids = {{50256}, {0}, {1}};
|
||||||
//generate_until_sentence = true;
|
//generate_until_sentence = true;
|
||||||
@ -3037,7 +3054,7 @@ function throwCircuitBreakerError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function extractTitleFromData(data) {
|
function extractTitleFromData(data) {
|
||||||
if (main_api == 'kobold' && horde_settings.use_horde) {
|
if (main_api == 'koboldhorde') {
|
||||||
return data.workerName;
|
return data.workerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3047,11 +3064,11 @@ function extractTitleFromData(data) {
|
|||||||
function extractMessageFromData(data) {
|
function extractMessageFromData(data) {
|
||||||
let getMessage = "";
|
let getMessage = "";
|
||||||
|
|
||||||
if (main_api == 'kobold' && !horde_settings.use_horde) {
|
if (main_api == 'kobold') {
|
||||||
getMessage = data.results[0].text;
|
getMessage = data.results[0].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main_api == 'kobold' && horde_settings.use_horde) {
|
if (main_api == 'koboldhorde') {
|
||||||
getMessage = data.text;
|
getMessage = data.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3247,7 +3264,7 @@ function extractImageFromMessage(getMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isMultigenEnabled() {
|
export function isMultigenEnabled() {
|
||||||
return power_user.multigen && (main_api == 'textgenerationwebui' || main_api == 'kobold' || main_api == 'novel');
|
return power_user.multigen && (main_api == 'textgenerationwebui' || main_api == 'kobold' || main_api == 'koboldhorde' || main_api == 'novel');
|
||||||
}
|
}
|
||||||
|
|
||||||
function activateSendButtons() {
|
function activateSendButtons() {
|
||||||
@ -3559,6 +3576,15 @@ function changeMainAPI() {
|
|||||||
const selectedVal = $("#main_api").val();
|
const selectedVal = $("#main_api").val();
|
||||||
//console.log(selectedVal);
|
//console.log(selectedVal);
|
||||||
const apiElements = {
|
const apiElements = {
|
||||||
|
"koboldhorde": {
|
||||||
|
apiSettings: $("#kobold_api-settings"),
|
||||||
|
apiConnector: $("#kobold_horde"),
|
||||||
|
apiPresets: $('#kobold_api-presets'),
|
||||||
|
apiRanges: $("#range_block"),
|
||||||
|
maxContextElem: $("#max_context_block"),
|
||||||
|
amountGenElem: $("#amount_gen_block"),
|
||||||
|
softPromptElem: $("#softprompt_block")
|
||||||
|
},
|
||||||
"kobold": {
|
"kobold": {
|
||||||
apiSettings: $("#kobold_api-settings"),
|
apiSettings: $("#kobold_api-settings"),
|
||||||
apiConnector: $("#kobold_api"),
|
apiConnector: $("#kobold_api"),
|
||||||
@ -3608,49 +3634,62 @@ function changeMainAPI() {
|
|||||||
//console.log('--- apiElements--- ');
|
//console.log('--- apiElements--- ');
|
||||||
//console.log(apiElements);
|
//console.log(apiElements);
|
||||||
|
|
||||||
|
//first, disable everything so the old elements stop showing
|
||||||
for (const apiName in apiElements) {
|
for (const apiName in apiElements) {
|
||||||
const apiObj = apiElements[apiName];
|
const apiObj = apiElements[apiName];
|
||||||
const isCurrentApi = selectedVal === apiName;
|
//do not hide items to then proceed to immediately show them.
|
||||||
|
if (selectedVal === apiName) {
|
||||||
apiObj.apiSettings.css("display", isCurrentApi ? "block" : "none");
|
continue;
|
||||||
apiObj.apiConnector.css("display", isCurrentApi ? "block" : "none");
|
|
||||||
apiObj.apiRanges.css("display", isCurrentApi ? "block" : "none");
|
|
||||||
apiObj.apiPresets.css("display", isCurrentApi ? "block" : "none");
|
|
||||||
|
|
||||||
if (isCurrentApi && apiName === "openai") {
|
|
||||||
apiObj.apiPresets.css("display", "flex");
|
|
||||||
}
|
}
|
||||||
|
apiObj.apiSettings.css("display", "none");
|
||||||
|
apiObj.apiConnector.css("display", "none");
|
||||||
|
apiObj.apiRanges.css("display", "none");
|
||||||
|
apiObj.apiPresets.css("display", "none");
|
||||||
|
}
|
||||||
|
|
||||||
if (isCurrentApi && apiName === "kobold") {
|
//then, find and enable the active item.
|
||||||
//console.log("enabling SP for kobold");
|
//This is split out of the loop so that different apis can share settings divs
|
||||||
$("#softprompt_block").css("display", "block");
|
let activeItem = apiElements[selectedVal];
|
||||||
}
|
|
||||||
|
|
||||||
if (isCurrentApi && (apiName === "textgenerationwebui" || apiName === "novel")) {
|
activeItem.apiSettings.css("display", "block");
|
||||||
console.log("enabling amount_gen for ooba/novel");
|
activeItem.apiConnector.css("display", "block");
|
||||||
apiObj.amountGenElem.find('input').prop("disabled", false);
|
activeItem.apiRanges.css("display", "block");
|
||||||
apiObj.amountGenElem.css("opacity", 1.0);
|
activeItem.apiPresets.css("display", "block");
|
||||||
}
|
|
||||||
|
|
||||||
// Hide common settings for OpenAI
|
if (selectedVal === "openai") {
|
||||||
if (selectedVal == "openai") {
|
activeItem.apiPresets.css("display", "flex");
|
||||||
$("#common-gen-settings-block").css("display", "none");
|
}
|
||||||
} else {
|
|
||||||
$("#common-gen-settings-block").css("display", "block");
|
|
||||||
}
|
|
||||||
// Hide amount gen for poe
|
|
||||||
if (selectedVal == "poe") {
|
|
||||||
$("#amount_gen_block").css("display", "none");
|
|
||||||
} else {
|
|
||||||
$("#amount_gen_block").css("display", "flex");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (selectedVal === "kobold" || selectedVal === 'koboldhorde') {
|
||||||
|
//console.log("enabling SP for kobold");
|
||||||
|
$("#softprompt_block").css("display", "block");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedVal === "textgenerationwebui" || selectedVal === "novel") {
|
||||||
|
console.log("enabling amount_gen for ooba/novel");
|
||||||
|
activeItem.amountGenElem.find('input').prop("disabled", false);
|
||||||
|
activeItem.amountGenElem.css("opacity", 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide common settings for OpenAI
|
||||||
|
console.log('value?', selectedVal);
|
||||||
|
if (selectedVal == "openai") {
|
||||||
|
console.log('hiding settings?');
|
||||||
|
$("#common-gen-settings-block").css("display", "none");
|
||||||
|
} else {
|
||||||
|
$("#common-gen-settings-block").css("display", "block");
|
||||||
|
}
|
||||||
|
// Hide amount gen for poe
|
||||||
|
if (selectedVal == "poe") {
|
||||||
|
$("#amount_gen_block").css("display", "none");
|
||||||
|
} else {
|
||||||
|
$("#amount_gen_block").css("display", "flex");
|
||||||
}
|
}
|
||||||
|
|
||||||
main_api = selectedVal;
|
main_api = selectedVal;
|
||||||
online_status = "no_connection";
|
online_status = "no_connection";
|
||||||
|
|
||||||
if (main_api == "kobold" && horde_settings.use_horde) {
|
if (main_api == "koboldhorde") {
|
||||||
is_get_status = true;
|
is_get_status = true;
|
||||||
getStatus();
|
getStatus();
|
||||||
getHordeModels();
|
getHordeModels();
|
||||||
@ -4592,7 +4631,7 @@ function setGenerationProgress(progress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isHordeGenerationNotAllowed() {
|
function isHordeGenerationNotAllowed() {
|
||||||
if (main_api == "kobold" && horde_settings.use_horde && preset_settings == "gui") {
|
if (main_api == "koboldhorde" && preset_settings == "gui") {
|
||||||
toastr.error('GUI Settings preset is not supported for Horde. Please select another preset.');
|
toastr.error('GUI Settings preset is not supported for Horde. Please select another preset.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -5696,7 +5735,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$("#api_button").click(function (e) {
|
$("#api_button").click(function (e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if ($("#api_url_text").val() != "" && !horde_settings.use_horde) {
|
if ($("#api_url_text").val() != "") {
|
||||||
let value = formatKoboldUrl($.trim($("#api_url_text").val()));
|
let value = formatKoboldUrl($.trim($("#api_url_text").val()));
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@ -5717,12 +5756,6 @@ $(document).ready(function () {
|
|||||||
clearSoftPromptsList();
|
clearSoftPromptsList();
|
||||||
getSoftPromptsList();
|
getSoftPromptsList();
|
||||||
}
|
}
|
||||||
else if (horde_settings.use_horde) {
|
|
||||||
main_api = "kobold";
|
|
||||||
is_get_status = true;
|
|
||||||
getStatus();
|
|
||||||
clearSoftPromptsList();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#api_button_textgenerationwebui").click(function (e) {
|
$("#api_button_textgenerationwebui").click(function (e) {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { saveSettingsDebounced, getCurrentChatId, system_message_types } from "../../../script.js";
|
import { saveSettingsDebounced, getCurrentChatId, system_message_types } from "../../../script.js";
|
||||||
import { humanizedDateTime } from "../../RossAscends-mods.js";
|
import { humanizedDateTime } from "../../RossAscends-mods.js";
|
||||||
import { getApiUrl, extension_settings } from "../../extensions.js";
|
import { getApiUrl, extension_settings, getContext } from "../../extensions.js";
|
||||||
import { getFileText, onlyUnique, splitRecursive } from "../../utils.js";
|
import { getFileText, onlyUnique, splitRecursive } from "../../utils.js";
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
|
|
||||||
const MODULE_NAME = 'chromadb';
|
const MODULE_NAME = 'chromadb';
|
||||||
|
|
||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
|
strategy: 'original',
|
||||||
|
|
||||||
keep_context: 10,
|
keep_context: 10,
|
||||||
keep_context_min: 1,
|
keep_context_min: 1,
|
||||||
keep_context_max: 100,
|
keep_context_max: 100,
|
||||||
@ -38,12 +40,25 @@ async function loadSettings() {
|
|||||||
Object.assign(extension_settings.chromadb, defaultSettings);
|
Object.assign(extension_settings.chromadb, defaultSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`loading chromadb strat:${extension_settings.chromadb.strategy}`);
|
||||||
|
$("#chromadb_strategy option[value=" + extension_settings.chromadb.strategy + "]").attr(
|
||||||
|
"selected",
|
||||||
|
"true"
|
||||||
|
);
|
||||||
$('#chromadb_keep_context').val(extension_settings.chromadb.keep_context).trigger('input');
|
$('#chromadb_keep_context').val(extension_settings.chromadb.keep_context).trigger('input');
|
||||||
$('#chromadb_n_results').val(extension_settings.chromadb.n_results).trigger('input');
|
$('#chromadb_n_results').val(extension_settings.chromadb.n_results).trigger('input');
|
||||||
$('#chromadb_split_length').val(extension_settings.chromadb.split_length).trigger('input');
|
$('#chromadb_split_length').val(extension_settings.chromadb.split_length).trigger('input');
|
||||||
$('#chromadb_file_split_length').val(extension_settings.chromadb.file_split_length).trigger('input');
|
$('#chromadb_file_split_length').val(extension_settings.chromadb.file_split_length).trigger('input');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onStrategyChange() {
|
||||||
|
console.log('changing chromadb strat');
|
||||||
|
extension_settings.chromadb.strategy = $('#chromadb_strategy').val();
|
||||||
|
|
||||||
|
//$('#chromadb_strategy').select(extension_settings.chromadb.strategy);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
function onKeepContextInput() {
|
function onKeepContextInput() {
|
||||||
extension_settings.chromadb.keep_context = Number($('#chromadb_keep_context').val());
|
extension_settings.chromadb.keep_context = Number($('#chromadb_keep_context').val());
|
||||||
$('#chromadb_keep_context_value').text(extension_settings.chromadb.keep_context);
|
$('#chromadb_keep_context_value').text(extension_settings.chromadb.keep_context);
|
||||||
@ -158,7 +173,7 @@ async function onSelectInjectFile(e) {
|
|||||||
|
|
||||||
const split = splitRecursive(text, extension_settings.chromadb.file_split_length).filter(onlyUnique);
|
const split = splitRecursive(text, extension_settings.chromadb.file_split_length).filter(onlyUnique);
|
||||||
|
|
||||||
const messages = split.map(m => ({
|
const messages = split.map(m => ({
|
||||||
id: `${file.name}-${split.indexOf(m)}`,
|
id: `${file.name}-${split.indexOf(m)}`,
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: m,
|
content: m,
|
||||||
@ -205,7 +220,7 @@ async function onSelectInjectFile(e) {
|
|||||||
|
|
||||||
window.chromadb_interceptGeneration = async (chat) => {
|
window.chromadb_interceptGeneration = async (chat) => {
|
||||||
const currentChatId = getCurrentChatId();
|
const currentChatId = getCurrentChatId();
|
||||||
|
const selectedStrategy = extension_settings.chromadb.strategy;
|
||||||
if (currentChatId) {
|
if (currentChatId) {
|
||||||
const messagesToStore = chat.slice(0, -extension_settings.chromadb.keep_context);
|
const messagesToStore = chat.slice(0, -extension_settings.chromadb.keep_context);
|
||||||
|
|
||||||
@ -219,10 +234,41 @@ window.chromadb_interceptGeneration = async (chat) => {
|
|||||||
|
|
||||||
queriedMessages.sort((a, b) => a.date - b.date);
|
queriedMessages.sort((a, b) => a.date - b.date);
|
||||||
|
|
||||||
const newChat = queriedMessages.map(m => JSON.parse(m.meta));
|
const newChat = [];
|
||||||
|
|
||||||
chat.splice(0, messagesToStore.length, ...newChat);
|
if (selectedStrategy === 'ross') {
|
||||||
|
//adds chroma to the end of chat and allows Generate() to cull old messages naturally.
|
||||||
|
const context = getContext();
|
||||||
|
const charname = context.name2;
|
||||||
|
newChat.push(
|
||||||
|
{
|
||||||
|
is_name: false,
|
||||||
|
is_user: false,
|
||||||
|
mes: `[Use these past chat exchanges to inform ${charname}'s next response:`,
|
||||||
|
name: "system",
|
||||||
|
send_date: 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
newChat.push(...queriedMessages.map(m => JSON.parse(m.meta)));
|
||||||
|
newChat.push(
|
||||||
|
{
|
||||||
|
is_name: false,
|
||||||
|
is_user: false,
|
||||||
|
mes: `]\n`,
|
||||||
|
name: "system",
|
||||||
|
send_date: 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
chat.splice(chat.length, 0, ...newChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedStrategy === 'original') {
|
||||||
|
//removes .length # messages from the start of 'kept messages'
|
||||||
|
//replaces them with chromaDB results (with no separator)
|
||||||
|
newChat.push(...queriedMessages.map(m => JSON.parse(m.meta)));
|
||||||
|
chat.splice(0, messagesToStore.length, ...newChat);
|
||||||
|
|
||||||
|
}
|
||||||
console.log('ChromaDB chat after injection', chat);
|
console.log('ChromaDB chat after injection', chat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,13 +284,18 @@ jQuery(async () => {
|
|||||||
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
|
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-drawer-content">
|
<div class="inline-drawer-content">
|
||||||
<label for="chromadb_keep_context">How many messages to keep (<span id="chromadb_keep_context_value"></span>)</label>
|
<span>Memory Injection Strategy</span>
|
||||||
|
<select id="chromadb_strategy">
|
||||||
|
<option value="original">Replace non-kept chat items with memories</option>
|
||||||
|
<option value="ross">Add memories after chat with a header tag</option>
|
||||||
|
</select>
|
||||||
|
<label for="chromadb_keep_context">How many original chat messages to keep: (<span id="chromadb_keep_context_value"></span>) messages</label>
|
||||||
<input id="chromadb_keep_context" type="range" min="${defaultSettings.keep_context_min}" max="${defaultSettings.keep_context_max}" step="${defaultSettings.keep_context_step}" value="${defaultSettings.keep_context}" />
|
<input id="chromadb_keep_context" type="range" min="${defaultSettings.keep_context_min}" max="${defaultSettings.keep_context_max}" step="${defaultSettings.keep_context_step}" value="${defaultSettings.keep_context}" />
|
||||||
<label for="chromadb_n_results">Max messages to inject (<span id="chromadb_n_results_value"></span>)</label>
|
<label for="chromadb_n_results">Maximum number of ChromaDB 'memories' to inject: (<span id="chromadb_n_results_value"></span>) messages</label>
|
||||||
<input id="chromadb_n_results" type="range" min="${defaultSettings.n_results_min}" max="${defaultSettings.n_results_max}" step="${defaultSettings.n_results_step}" value="${defaultSettings.n_results}" />
|
<input id="chromadb_n_results" type="range" min="${defaultSettings.n_results_min}" max="${defaultSettings.n_results_max}" step="${defaultSettings.n_results_step}" value="${defaultSettings.n_results}" />
|
||||||
<label for="chromadb_split_length">Max length for message chunks (<span id="chromadb_split_length_value"></span>)</label>
|
<label for="chromadb_split_length">Max length for each 'memory' pulled from the current chat history: (<span id="chromadb_split_length_value"></span>) characters</label>
|
||||||
<input id="chromadb_split_length" type="range" min="${defaultSettings.split_length_min}" max="${defaultSettings.split_length_max}" step="${defaultSettings.split_length_step}" value="${defaultSettings.split_length}" />
|
<input id="chromadb_split_length" type="range" min="${defaultSettings.split_length_min}" max="${defaultSettings.split_length_max}" step="${defaultSettings.split_length_step}" value="${defaultSettings.split_length}" />
|
||||||
<label for="chromadb_file_split_length">Max length for injected file chunks (<span id="chromadb_file_split_length_value"></span>)</label>
|
<label for="chromadb_file_split_length">Max length for each 'memory' pulled from imported text files: (<span id="chromadb_file_split_length_value"></span>) characters</label>
|
||||||
<input id="chromadb_file_split_length" type="range" min="${defaultSettings.file_split_length_min}" max="${defaultSettings.file_split_length_max}" step="${defaultSettings.file_split_length_step}" value="${defaultSettings.file_split_length}" />
|
<input id="chromadb_file_split_length" type="range" min="${defaultSettings.file_split_length_min}" max="${defaultSettings.file_split_length_max}" step="${defaultSettings.file_split_length_step}" value="${defaultSettings.file_split_length}" />
|
||||||
<div class="flex-container spaceEvenly">
|
<div class="flex-container spaceEvenly">
|
||||||
<div id="chromadb_inject" title="Upload custom textual data to use in the context of the current chat" class="menu_button">
|
<div id="chromadb_inject" title="Upload custom textual data to use in the context of the current chat" class="menu_button">
|
||||||
@ -262,6 +313,7 @@ jQuery(async () => {
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
$('#extensions_settings').append(settingsHtml);
|
$('#extensions_settings').append(settingsHtml);
|
||||||
|
$('#chromadb_strategy').on('change', onStrategyChange);
|
||||||
$('#chromadb_keep_context').on('input', onKeepContextInput);
|
$('#chromadb_keep_context').on('input', onKeepContextInput);
|
||||||
$('#chromadb_n_results').on('input', onNResultsInput);
|
$('#chromadb_n_results').on('input', onNResultsInput);
|
||||||
$('#chromadb_split_length').on('input', onSplitLengthInput);
|
$('#chromadb_split_length').on('input', onSplitLengthInput);
|
||||||
|
@ -16,7 +16,6 @@ let models = [];
|
|||||||
|
|
||||||
let horde_settings = {
|
let horde_settings = {
|
||||||
models: [],
|
models: [],
|
||||||
use_horde: false,
|
|
||||||
auto_adjust_response_length: true,
|
auto_adjust_response_length: true,
|
||||||
auto_adjust_context_length: false,
|
auto_adjust_context_length: false,
|
||||||
};
|
};
|
||||||
@ -180,7 +179,6 @@ function loadHordeSettings(settings) {
|
|||||||
Object.assign(horde_settings, settings.horde_settings);
|
Object.assign(horde_settings, settings.horde_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#use_horde').prop("checked", horde_settings.use_horde).trigger('input');
|
|
||||||
$('#horde_auto_adjust_response_length').prop("checked", horde_settings.auto_adjust_response_length);
|
$('#horde_auto_adjust_response_length').prop("checked", horde_settings.auto_adjust_response_length);
|
||||||
$('#horde_auto_adjust_context_length').prop("checked", horde_settings.auto_adjust_context_length);
|
$('#horde_auto_adjust_context_length').prop("checked", horde_settings.auto_adjust_context_length);
|
||||||
}
|
}
|
||||||
@ -208,23 +206,6 @@ async function showKudos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
$("#use_horde").on("input", async function () {
|
|
||||||
horde_settings.use_horde = !!$(this).prop("checked");
|
|
||||||
|
|
||||||
if (horde_settings.use_horde) {
|
|
||||||
$('#kobold_api_block').hide();
|
|
||||||
$('#kobold_horde_block').show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#kobold_api_block').show();
|
|
||||||
$('#kobold_horde_block').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger status check
|
|
||||||
changeMainAPI();
|
|
||||||
saveSettingsDebounced();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#horde_model").on("change", function () {
|
$("#horde_model").on("change", function () {
|
||||||
horde_settings.models = $('#horde_model').val();
|
horde_settings.models = $('#horde_model').val();
|
||||||
console.log('Updated Horde models', horde_settings.models);
|
console.log('Updated Horde models', horde_settings.models);
|
||||||
|
@ -86,6 +86,23 @@ function onBotChange() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function appendPoeAnchors(type, prompt) {
|
||||||
|
const isImpersonate = type === 'impersonate';
|
||||||
|
const isQuiet = type === 'quiet';
|
||||||
|
|
||||||
|
if (poe_settings.character_nudge && !isQuiet && !isImpersonate) {
|
||||||
|
let characterNudge = '\n' + substituteParams(poe_settings.character_nudge_message);
|
||||||
|
prompt += characterNudge;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (poe_settings.impersonation_prompt && isImpersonate) {
|
||||||
|
let impersonationNudge = '\n' + substituteParams(poe_settings.impersonation_prompt);
|
||||||
|
prompt += impersonationNudge;
|
||||||
|
}
|
||||||
|
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
|
||||||
async function generatePoe(type, finalPrompt, signal) {
|
async function generatePoe(type, finalPrompt, signal) {
|
||||||
if (poe_settings.auto_purge) {
|
if (poe_settings.auto_purge) {
|
||||||
let count_to_delete = -1;
|
let count_to_delete = -1;
|
||||||
@ -115,28 +132,7 @@ async function generatePoe(type, finalPrompt, signal) {
|
|||||||
console.log('Could not jailbreak the bot');
|
console.log('Could not jailbreak the bot');
|
||||||
}
|
}
|
||||||
|
|
||||||
const isImpersonate = type === 'impersonate';
|
|
||||||
const isQuiet = type === 'quiet';
|
const isQuiet = type === 'quiet';
|
||||||
|
|
||||||
if (poe_settings.character_nudge && !isQuiet && !isImpersonate) {
|
|
||||||
let characterNudge = '\n' + substituteParams(poe_settings.character_nudge_message);
|
|
||||||
finalPrompt += characterNudge;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (poe_settings.impersonation_prompt && isImpersonate) {
|
|
||||||
let impersonationNudge = '\n' + substituteParams(poe_settings.impersonation_prompt);
|
|
||||||
finalPrompt += impersonationNudge;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If prompt overflows the max context, reduce it (or the generation would fail)
|
|
||||||
// Split by sentence boundary and remove sentence-by-sentence from the beginning
|
|
||||||
while (getTokenCount(finalPrompt) > max_context) {
|
|
||||||
const sentences = finalPrompt.split(/([.?!])\s+/);
|
|
||||||
const removed = sentences.shift();
|
|
||||||
console.log(`Reducing Poe context due to overflow. Sentence dropped from prompt: "${removed}"`);
|
|
||||||
finalPrompt = sentences.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
const reply = await sendMessage(finalPrompt, !isQuiet, signal);
|
const reply = await sendMessage(finalPrompt, !isQuiet, signal);
|
||||||
got_reply = true;
|
got_reply = true;
|
||||||
return reply;
|
return reply;
|
||||||
|
@ -1719,6 +1719,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
|||||||
|
|
||||||
/* ------ online status indicators and texts. 2 = kobold AI, 3 = Novel AI ----------*/
|
/* ------ online status indicators and texts. 2 = kobold AI, 3 = Novel AI ----------*/
|
||||||
#online_status2,
|
#online_status2,
|
||||||
|
#online_status_horde,
|
||||||
.online_status4 {
|
.online_status4 {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
@ -1726,6 +1727,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#online_status_indicator2,
|
#online_status_indicator2,
|
||||||
|
#online_status_indicator_horde,
|
||||||
.online_status_indicator4 {
|
.online_status_indicator4 {
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
width: 14px;
|
width: 14px;
|
||||||
@ -1735,6 +1737,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#online_status_text2,
|
#online_status_text2,
|
||||||
|
#online_status_text_horde,
|
||||||
.online_status_text4 {
|
.online_status_text4 {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
Reference in New Issue
Block a user