mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Compare commits
49 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
29d841a50b | ||
|
18e6e578dd | ||
|
d5e40e0271 | ||
|
6b85f10818 | ||
|
73ea029acd | ||
|
27c6e5ecff | ||
|
40f466b2c3 | ||
|
02667d3d1a | ||
|
9cb70817c7 | ||
|
e172f50d4f | ||
|
49f7185c8c | ||
|
638050a3de | ||
|
a0f369d100 | ||
|
f9239c860d | ||
|
41a08fed2b | ||
|
95d43712d3 | ||
|
4f76a8b0ce | ||
|
3fc2b81433 | ||
|
23a514bba8 | ||
|
51449c4913 | ||
|
18bb362578 | ||
|
6d9c2ec365 | ||
|
ad26a1968b | ||
|
52289acc62 | ||
|
b970c69844 | ||
|
c8e456d773 | ||
|
d00fbacec3 | ||
|
ccbec7715a | ||
|
1b7973ec13 | ||
|
1f63fd9344 | ||
|
d8d5118283 | ||
|
11226ff7d6 | ||
|
844d9c86a4 | ||
|
0aee97ccca | ||
|
fa06e5ee5a | ||
|
6794be4d1e | ||
|
4316396880 | ||
|
fd93bc7736 | ||
|
0cc88c17c7 | ||
|
6829f5308f | ||
|
1689913b43 | ||
|
33b7e8fad1 | ||
|
17eb55731e | ||
|
9dba57dc85 | ||
|
dddc49c235 | ||
|
faf9c4445f | ||
|
a646aaa125 | ||
|
80a0cb2bc4 | ||
|
ac4fa0e035 |
3
.github/readme-zh_cn.md
vendored
3
.github/readme-zh_cn.md
vendored
@@ -291,7 +291,6 @@ SillyTavern 会将 API 密钥保存在目录中的 `secrets.json` 文件内。
|
|||||||
* RossAscends' additions: AGPL v3
|
* RossAscends' additions: AGPL v3
|
||||||
* Portions of CncAnon's TavernAITurbo mod: Unknown license
|
* Portions of CncAnon's TavernAITurbo mod: Unknown license
|
||||||
* kingbri's various commits and suggestions (https://github.com/bdashore3)
|
* kingbri's various commits and suggestions (https://github.com/bdashore3)
|
||||||
* BlipRanger's miscellaneous UI & extension modifications (https://github.com/BlipRanger)
|
|
||||||
* Waifu mode inspired by the work of PepperTaco (https://github.com/peppertaco/Tavern/)
|
* Waifu mode inspired by the work of PepperTaco (https://github.com/peppertaco/Tavern/)
|
||||||
* Thanks Pygmalion University for being awesome testers and suggesting cool features!
|
* Thanks Pygmalion University for being awesome testers and suggesting cool features!
|
||||||
* Thanks oobabooga for compiling presets for TextGen
|
* Thanks oobabooga for compiling presets for TextGen
|
||||||
@@ -303,4 +302,4 @@ SillyTavern 会将 API 密钥保存在目录中的 `secrets.json` 文件内。
|
|||||||
* Thanks paniphons for providing a FAQ document
|
* Thanks paniphons for providing a FAQ document
|
||||||
* 10K Discord Users Celebratory Background by @kallmeflocc
|
* 10K Discord Users Celebratory Background by @kallmeflocc
|
||||||
* Default content (characters and lore books) provided by @OtisAlejandro, @RossAscends and @kallmeflocc
|
* Default content (characters and lore books) provided by @OtisAlejandro, @RossAscends and @kallmeflocc
|
||||||
* Korean translation by @doloroushyeonse
|
* Korean translation by @doloroushyeonse
|
||||||
|
1
.github/readme.md
vendored
1
.github/readme.md
vendored
@@ -293,7 +293,6 @@ GNU Affero General Public License for more details.**
|
|||||||
* RossAscends' additions: AGPL v3
|
* RossAscends' additions: AGPL v3
|
||||||
* Portions of CncAnon's TavernAITurbo mod: Unknown license
|
* Portions of CncAnon's TavernAITurbo mod: Unknown license
|
||||||
* kingbri's various commits and suggestions (<https://github.com/bdashore3>)
|
* kingbri's various commits and suggestions (<https://github.com/bdashore3>)
|
||||||
* BlipRanger's miscellaneous UI & extension modifications (<https://github.com/BlipRanger>)
|
|
||||||
* Waifu mode inspired by the work of PepperTaco (<https://github.com/peppertaco/Tavern/>)
|
* Waifu mode inspired by the work of PepperTaco (<https://github.com/peppertaco/Tavern/>)
|
||||||
* Thanks Pygmalion University for being awesome testers and suggesting cool features!
|
* Thanks Pygmalion University for being awesome testers and suggesting cool features!
|
||||||
* Thanks oobabooga for compiling presets for TextGen
|
* Thanks oobabooga for compiling presets for TextGen
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,4 +26,5 @@ secrets.json
|
|||||||
/dist
|
/dist
|
||||||
/backups/
|
/backups/
|
||||||
public/movingUI/
|
public/movingUI/
|
||||||
|
public/QuickReplies/
|
||||||
content.log
|
content.log
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sillytavern",
|
"name": "sillytavern",
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sillytavern",
|
"name": "sillytavern",
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dqbd/tiktoken": "^1.0.2",
|
"@dqbd/tiktoken": "^1.0.2",
|
||||||
|
@@ -51,7 +51,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
||||||
},
|
},
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js",
|
"start": "node server.js",
|
||||||
"pkg": "pkg --compress Gzip --no-bytecode --public ."
|
"pkg": "pkg --compress Gzip --no-bytecode --public ."
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
"phrase_rep_pen": "aggressive",
|
"phrase_rep_pen": "aggressive",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
"phrase_rep_pen": "aggressive",
|
"phrase_rep_pen": "aggressive",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"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,
|
|
||||||
"repetition_penalty_slope": 0,
|
|
||||||
"top_a": 0.075,
|
|
||||||
"top_k": 79,
|
|
||||||
"top_p": 0.95,
|
|
||||||
"typical_p": 1,
|
|
||||||
"max_context": 8192
|
|
||||||
}
|
|
@@ -15,6 +15,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
"phrase_rep_pen": "very_light",
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"order": [6, 0, 1, 2, 3],
|
"order": [0, 1, 2, 3],
|
||||||
"temperature": 1,
|
"temperature": 1,
|
||||||
"max_length": 300,
|
"max_length": 300,
|
||||||
"min_length": 1,
|
"min_length": 1,
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
"phrase_rep_pen": "off",
|
"phrase_rep_pen": "off",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
"phrase_rep_pen": "very_light",
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
@@ -16,5 +16,7 @@
|
|||||||
"use_cache": false,
|
"use_cache": false,
|
||||||
"return_full_text": false,
|
"return_full_text": false,
|
||||||
"prefix": "vanilla",
|
"prefix": "vanilla",
|
||||||
|
"cfg_scale": 1,
|
||||||
|
"phrase_rep_pen": "very_light",
|
||||||
"max_context": 8192
|
"max_context": 8192
|
||||||
}
|
}
|
||||||
|
23
public/QuickReplies/Default.json
Normal file
23
public/QuickReplies/Default.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "Default",
|
||||||
|
"quickReplyEnabled": true,
|
||||||
|
"quickReplySlots": [
|
||||||
|
{
|
||||||
|
"mes": "/?",
|
||||||
|
"label": "HELP",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mes": "/newchat",
|
||||||
|
"label": "New Chat",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mes": "/bgcol",
|
||||||
|
"label": "Match UI to Background",
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"numberOfSlots": 3,
|
||||||
|
"selectedPreset": "Default"
|
||||||
|
}
|
@@ -253,7 +253,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="range-block-range-and-counter">
|
<div class="range-block-range-and-counter">
|
||||||
<div class="range-block-range">
|
<div class="range-block-range">
|
||||||
<input type="range" id="temp" name="volume" min="0.1" max="2.0" step="0.01">
|
<input type="range" id="temp" name="volume" min="0.0" max="2.0" step="0.01">
|
||||||
</div>
|
</div>
|
||||||
<div class="range-block-counter">
|
<div class="range-block-counter">
|
||||||
<div contenteditable="true" data-for="temp" id="temp_counter">
|
<div contenteditable="true" data-for="temp" id="temp_counter">
|
||||||
@@ -1319,6 +1319,14 @@
|
|||||||
<textarea id="jailbreak_prompt_textarea" class="text_pole textarea_compact" name="jailbreak_prompt" rows="6" placeholder=""></textarea>
|
<textarea id="jailbreak_prompt_textarea" class="text_pole textarea_compact" name="jailbreak_prompt" rows="6" placeholder=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="range-block" data-source="claude">
|
||||||
|
<div class="range-block-title" data-i18n="Assistant Prefill">
|
||||||
|
Assistant Prefill
|
||||||
|
</div>
|
||||||
|
<div class="wide100p">
|
||||||
|
<input type="text" id="claude_assistant_prefill" class="text_pole" placeholder="Start Claude's answer with...">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="inline-drawer wide100p">
|
<div class="inline-drawer wide100p">
|
||||||
<div class="inline-drawer-toggle inline-drawer-header margin-bot-10px">
|
<div class="inline-drawer-toggle inline-drawer-header margin-bot-10px">
|
||||||
@@ -1863,7 +1871,7 @@
|
|||||||
<span data-i18n="Input Sequence">Input Sequence</span>
|
<span data-i18n="Input Sequence">Input Sequence</span>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<input id="instruct_input_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
<input id="instruct_input_sequence" class="text_pole textarea_compact" type="text" maxlength="500" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
@@ -1871,7 +1879,7 @@
|
|||||||
<span data-i18n="Output Sequence">Output Sequence</span>
|
<span data-i18n="Output Sequence">Output Sequence</span>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<input id="instruct_output_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
<input id="instruct_output_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="500" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1881,7 +1889,7 @@
|
|||||||
<small data-i18n="System Sequence">System Sequence</small>
|
<small data-i18n="System Sequence">System Sequence</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<input id="instruct_system_sequence" class="text_pole textarea_compact" type="text" maxlength="100" />
|
<input id="instruct_system_sequence" class="text_pole textarea_compact" type="text" maxlength="500" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
@@ -1889,7 +1897,7 @@
|
|||||||
<small data-i18n="Stop Sequence">Stop Sequence</small>
|
<small data-i18n="Stop Sequence">Stop Sequence</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<input id="instruct_stop_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
<input id="instruct_stop_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="500" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex1">
|
<div class="flex1">
|
||||||
@@ -1897,7 +1905,7 @@
|
|||||||
<small data-i18n="Separator">Separator</small>
|
<small data-i18n="Separator">Separator</small>
|
||||||
</label>
|
</label>
|
||||||
<div>
|
<div>
|
||||||
<input id="instruct_separator_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="100" />
|
<input id="instruct_separator_sequence" class="text_pole wide100p textarea_compact" type="text" maxlength="500" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2137,6 +2145,14 @@
|
|||||||
Match whole words
|
Match whole words
|
||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
|
<label title="Alert if your world info is greater than the allocated budget."
|
||||||
|
data-i18n="[title]Alert if your world info is greater than the allocated budget."
|
||||||
|
class="checkbox_label">
|
||||||
|
<input id="world_info_overflow_alert" type="checkbox" />
|
||||||
|
<small data-i18n="Alert On Overflow">
|
||||||
|
Alert On Overflow
|
||||||
|
</small>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -3766,6 +3782,14 @@
|
|||||||
<!-- popups live outside sheld to avoid blur conflicts -->
|
<!-- popups live outside sheld to avoid blur conflicts -->
|
||||||
<div id="options" class="font-family-reset" style="display: none;">
|
<div id="options" class="font-family-reset" style="display: none;">
|
||||||
<div class="options-content">
|
<div class="options-content">
|
||||||
|
<a id="option_close_chat">
|
||||||
|
<i class="fa-lg fa-solid fa-times"></i>
|
||||||
|
<span data-i18n="Close chat">Close chat</span>
|
||||||
|
</a>
|
||||||
|
<a id="option_settings">
|
||||||
|
<i class="fa-lg fa-solid fa-cog"></i>
|
||||||
|
<span data-i18n="Toggle Panels">Toggle Panels</span>
|
||||||
|
</a>
|
||||||
<a id="option_toggle_AN">
|
<a id="option_toggle_AN">
|
||||||
<i class="fa-lg fa-solid fa-note-sticky"></i>
|
<i class="fa-lg fa-solid fa-note-sticky"></i>
|
||||||
<span data-i18n="Author's Note">Author's Note</span>
|
<span data-i18n="Author's Note">Author's Note</span>
|
||||||
|
@@ -26,6 +26,7 @@ import {
|
|||||||
getWorldInfoPrompt,
|
getWorldInfoPrompt,
|
||||||
setWorldInfoSettings,
|
setWorldInfoSettings,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
|
world_info_overflow_alert,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
world_info_match_whole_words,
|
world_info_match_whole_words,
|
||||||
world_names,
|
world_names,
|
||||||
@@ -737,6 +738,9 @@ let token;
|
|||||||
|
|
||||||
var PromptArrayItemForRawPromptDisplay;
|
var PromptArrayItemForRawPromptDisplay;
|
||||||
|
|
||||||
|
export let active_character = ""
|
||||||
|
export let active_group = ""
|
||||||
|
|
||||||
export function getRequestHeaders() {
|
export function getRequestHeaders() {
|
||||||
return {
|
return {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -786,6 +790,14 @@ function checkOnlineStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setActiveCharacter(character) {
|
||||||
|
active_character = character;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setActiveGroup(group) {
|
||||||
|
active_group = group;
|
||||||
|
}
|
||||||
|
|
||||||
async function getStatus() {
|
async function getStatus() {
|
||||||
if (is_get_status) {
|
if (is_get_status) {
|
||||||
if (main_api == "koboldhorde") {
|
if (main_api == "koboldhorde") {
|
||||||
@@ -5009,6 +5021,10 @@ async function getSettings(type) {
|
|||||||
highlightSelectedAvatar();
|
highlightSelectedAvatar();
|
||||||
setPersonaDescription();
|
setPersonaDescription();
|
||||||
|
|
||||||
|
//Load the active character and group
|
||||||
|
active_character = settings.active_character;
|
||||||
|
active_group = settings.active_group;
|
||||||
|
|
||||||
//Load the API server URL from settings
|
//Load the API server URL from settings
|
||||||
api_server = settings.api_server;
|
api_server = settings.api_server;
|
||||||
$("#api_url_text").val(api_server);
|
$("#api_url_text").val(api_server);
|
||||||
@@ -5049,6 +5065,8 @@ async function saveSettings(type) {
|
|||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
firstRun: firstRun,
|
firstRun: firstRun,
|
||||||
username: name1,
|
username: name1,
|
||||||
|
active_character: active_character,
|
||||||
|
active_group: active_group,
|
||||||
api_server: api_server,
|
api_server: api_server,
|
||||||
api_server_textgenerationwebui: api_server_textgenerationwebui,
|
api_server_textgenerationwebui: api_server_textgenerationwebui,
|
||||||
preset_settings: preset_settings,
|
preset_settings: preset_settings,
|
||||||
@@ -5060,6 +5078,7 @@ async function saveSettings(type) {
|
|||||||
world_info_depth: world_info_depth,
|
world_info_depth: world_info_depth,
|
||||||
world_info_budget: world_info_budget,
|
world_info_budget: world_info_budget,
|
||||||
world_info_recursive: world_info_recursive,
|
world_info_recursive: world_info_recursive,
|
||||||
|
world_info_overflow_alert: world_info_overflow_alert,
|
||||||
world_info_case_sensitive: world_info_case_sensitive,
|
world_info_case_sensitive: world_info_case_sensitive,
|
||||||
world_info_match_whole_words: world_info_match_whole_words,
|
world_info_match_whole_words: world_info_match_whole_words,
|
||||||
world_info_character_strategy: world_info_character_strategy,
|
world_info_character_strategy: world_info_character_strategy,
|
||||||
@@ -7732,6 +7751,51 @@ $(document).ready(function () {
|
|||||||
else if (id == "option_delete_mes") {
|
else if (id == "option_delete_mes") {
|
||||||
setTimeout(openMessageDelete, animation_duration);
|
setTimeout(openMessageDelete, animation_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (id == "option_close_chat") {
|
||||||
|
if (is_send_press == false) {
|
||||||
|
clearChat();
|
||||||
|
chat.length = 0;
|
||||||
|
resetSelectedGroup();
|
||||||
|
setCharacterId(undefined);
|
||||||
|
setCharacterName('');
|
||||||
|
setActiveCharacter(null);
|
||||||
|
setActiveGroup(null);
|
||||||
|
this_edit_mes_id = undefined;
|
||||||
|
chat_metadata = {};
|
||||||
|
selected_button = "characters";
|
||||||
|
$("#rm_button_selected_ch").children("h2").text('');
|
||||||
|
select_rm_characters();
|
||||||
|
sendSystemMessage(system_message_types.WELCOME);
|
||||||
|
} else {
|
||||||
|
toastr.info("Please stop the message generation first.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (id === "option_settings") {
|
||||||
|
//var checkBox = document.getElementById("waifuMode");
|
||||||
|
var topBar = document.getElementById("top-bar");
|
||||||
|
var topSettingsHolder = document.getElementById("top-settings-holder");
|
||||||
|
var divchat = document.getElementById("chat");
|
||||||
|
|
||||||
|
//if (checkBox.checked) {
|
||||||
|
if (topBar.style.display === "none") {
|
||||||
|
topBar.style.display = ""; // or "inline-block" if that's the original display value
|
||||||
|
topSettingsHolder.style.display = ""; // or "inline-block" if that's the original display value
|
||||||
|
|
||||||
|
divchat.style.borderRadius = "";
|
||||||
|
divchat.style.backgroundColor = "";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
divchat.style.borderRadius = "10px"; // Adjust the value to control the roundness of the corners
|
||||||
|
divchat.style.backgroundColor = ""; // Set the background color to your preference
|
||||||
|
|
||||||
|
topBar.style.display = "none";
|
||||||
|
topSettingsHolder.style.display = "none";
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
hideMenu();
|
hideMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -13,6 +13,10 @@ import {
|
|||||||
menu_type,
|
menu_type,
|
||||||
max_context,
|
max_context,
|
||||||
saveSettingsDebounced,
|
saveSettingsDebounced,
|
||||||
|
active_group,
|
||||||
|
active_character,
|
||||||
|
setActiveGroup,
|
||||||
|
setActiveCharacter,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -330,11 +334,21 @@ export function RA_CountCharTokens() {
|
|||||||
characterStatsHandler(characters, this_chid);
|
characterStatsHandler(characters, this_chid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Auto Load Last Charcter -- (fires when active_character is defined and auto_load_chat is true)
|
/**
|
||||||
|
* Auto load chat with the last active character or group.
|
||||||
|
* Fires when active_character is defined and auto_load_chat is true.
|
||||||
|
* The function first tries to find a character with a specific ID from the global settings.
|
||||||
|
* If it doesn't exist, it tries to find a group with a specific grid from the global settings.
|
||||||
|
* If the character list hadn't been loaded yet, it calls itself again after 100ms delay.
|
||||||
|
* The character or group is selected (clicked) if it is found.
|
||||||
|
*/
|
||||||
async function RA_autoloadchat() {
|
async function RA_autoloadchat() {
|
||||||
if (document.getElementById('CharID0') !== null) {
|
if (document.getElementById('CharID0') !== null) {
|
||||||
var charToAutoLoad = document.getElementById('CharID' + LoadLocal('ActiveChar'));
|
// active character is the name, we should look it up in the character list and get the id
|
||||||
let groupToAutoLoad = document.querySelector(`.group_select[grid="${LoadLocal('ActiveGroup')}"]`);
|
let active_character_id = Object.keys(characters).find(key => characters[key].avatar === active_character);
|
||||||
|
|
||||||
|
var charToAutoLoad = document.getElementById('CharID' + active_character_id);
|
||||||
|
let groupToAutoLoad = document.querySelector(`.group_select[grid="${active_group}"]`);
|
||||||
if (charToAutoLoad != null) {
|
if (charToAutoLoad != null) {
|
||||||
$(charToAutoLoad).click();
|
$(charToAutoLoad).click();
|
||||||
}
|
}
|
||||||
@@ -342,7 +356,7 @@ async function RA_autoloadchat() {
|
|||||||
$(groupToAutoLoad).click();
|
$(groupToAutoLoad).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the charcter list hadn't been loaded yet, try again.
|
// if the character list hadn't been loaded yet, try again.
|
||||||
} else { setTimeout(RA_autoloadchat, 100); }
|
} else { setTimeout(RA_autoloadchat, 100); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -903,16 +917,22 @@ $("document").ready(function () {
|
|||||||
$("#rm_button_characters").click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
$("#rm_button_characters").click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
||||||
|
|
||||||
// when a char is selected from the list, save them as the auto-load character for next page load
|
// when a char is selected from the list, save them as the auto-load character for next page load
|
||||||
|
|
||||||
|
// when a char is selected from the list, save their name as the auto-load character for next page load
|
||||||
$(document).on("click", ".character_select", function () {
|
$(document).on("click", ".character_select", function () {
|
||||||
SaveLocal('ActiveChar', $(this).attr('chid'));
|
setActiveCharacter($(this).find('.avatar').attr('title'));
|
||||||
SaveLocal('ActiveGroup', null);
|
setActiveGroup(null);
|
||||||
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".group_select", function () {
|
$(document).on("click", ".group_select", function () {
|
||||||
SaveLocal('ActiveChar', null);
|
setActiveCharacter(null);
|
||||||
SaveLocal('ActiveGroup', $(this).data('id'));
|
setActiveGroup($(this).data('id'));
|
||||||
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
//this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height)
|
||||||
$('#send_textarea').on('input', function () {
|
$('#send_textarea').on('input', function () {
|
||||||
this.style.height = '40px';
|
this.style.height = '40px';
|
||||||
@@ -1028,11 +1048,10 @@ $("document").ready(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.ctrlKey && event.key == "ArrowUp") { //edits last USER message if chatbar is empty and focused
|
if (event.ctrlKey && event.key == "ArrowUp") { //edits last USER message if chatbar is empty and focused
|
||||||
console.debug('got ctrl+uparrow input');
|
|
||||||
if (
|
if (
|
||||||
$("#send_textarea").val() === '' &&
|
$("#send_textarea").val() === '' &&
|
||||||
chatbarInFocus === true &&
|
chatbarInFocus === true &&
|
||||||
$(".swipe_right:last").css('display') === 'flex' &&
|
($(".swipe_right:last").css('display') === 'flex' || $('.last_mes').attr('is_system') === 'true') &&
|
||||||
$("#character_popup").css("display") === "none" &&
|
$("#character_popup").css("display") === "none" &&
|
||||||
$("#shadow_select_chat_popup").css("display") === "none"
|
$("#shadow_select_chat_popup").css("display") === "none"
|
||||||
) {
|
) {
|
||||||
@@ -1040,7 +1059,7 @@ $("document").ready(function () {
|
|||||||
const lastIsUserMes = isUserMesList[isUserMesList.length - 1];
|
const lastIsUserMes = isUserMesList[isUserMesList.length - 1];
|
||||||
const editMes = lastIsUserMes.querySelector('.mes_block .mes_edit');
|
const editMes = lastIsUserMes.querySelector('.mes_block .mes_edit');
|
||||||
if (editMes !== null) {
|
if (editMes !== null) {
|
||||||
$(editMes).click();
|
$(editMes).trigger('click');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1061,5 +1080,59 @@ $("document").ready(function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.key == "Escape") { //closes various panels
|
||||||
|
if ($("#curEditTextarea").is(":visible")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#dialogue_popup").is(":visible")) {
|
||||||
|
if ($("#dialogue_popup_cancel").is(":visible")) {
|
||||||
|
$("#dialogue_popup_cancel").trigger('click');
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
$("#dialogue_popup_ok").trigger('click')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($("#select_chat_popup").is(":visible")) {
|
||||||
|
$("#select_chat_cross").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($("#character_popup").is(":visible")) {
|
||||||
|
$("#character_cross").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(".drawer-content")
|
||||||
|
.not('#WorldInfo')
|
||||||
|
.not('#left-nav-panel')
|
||||||
|
.not('#right-nav-panel')
|
||||||
|
.is(":visible")) {
|
||||||
|
let visibleDrawerContent = $(".drawer-content:visible")
|
||||||
|
.not('#WorldInfo')
|
||||||
|
.not('#left-nav-panel')
|
||||||
|
.not('#right-nav-panel')
|
||||||
|
$(visibleDrawerContent).parent().find('.drawer-icon').trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($("#floatingPrompt").is(":visible")) {
|
||||||
|
$("#ANClose").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($("#WorldInfo").is(":visible")) {
|
||||||
|
$("#WIDrawerIcon").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($("#left-nav-panel").is(":visible")) {
|
||||||
|
$("#leftNavDrawerIcon").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ($("#right-nav-panel").is(":visible")) {
|
||||||
|
$("#rightNavDrawerIcon").trigger('click');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { getStringHash, debounce, waitUntilCondition } from "../../utils.js";
|
import { getStringHash, debounce, waitUntilCondition, extractAllWords } from "../../utils.js";
|
||||||
import { getContext, getApiUrl, extension_settings, doExtrasFetch, modules } from "../../extensions.js";
|
import { getContext, getApiUrl, extension_settings, doExtrasFetch, modules } from "../../extensions.js";
|
||||||
import { eventSource, event_types, extension_prompt_types, generateQuietPrompt, is_send_press, saveSettingsDebounced, substituteParams } from "../../../script.js";
|
import { eventSource, event_types, extension_prompt_types, generateQuietPrompt, is_send_press, saveSettingsDebounced, substituteParams } from "../../../script.js";
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
@@ -12,7 +12,21 @@ let lastMessageHash = null;
|
|||||||
let lastMessageId = null;
|
let lastMessageId = null;
|
||||||
let inApiCall = false;
|
let inApiCall = false;
|
||||||
|
|
||||||
const formatMemoryValue = (value) => value ? `Summary: ${value.trim()}` : '';
|
const formatMemoryValue = function (value) {
|
||||||
|
if (!value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value.trim();
|
||||||
|
|
||||||
|
if (extension_settings.memory.template) {
|
||||||
|
let result = extension_settings.memory.template.replace(/{{summary}}/i, value);
|
||||||
|
return substituteParams(result);
|
||||||
|
} else {
|
||||||
|
return `Summary: ${value}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const saveChatDebounced = debounce(() => getContext().saveChat(), 2000);
|
const saveChatDebounced = debounce(() => getContext().saveChat(), 2000);
|
||||||
|
|
||||||
const summary_sources = {
|
const summary_sources = {
|
||||||
@@ -21,6 +35,7 @@ const summary_sources = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const defaultPrompt = '[Pause your roleplay. Summarize the most important facts and events that have happened in the chat so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]';
|
const defaultPrompt = '[Pause your roleplay. Summarize the most important facts and events that have happened in the chat so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]';
|
||||||
|
const defaultTemplate = '[Summary: {{summary}}]';
|
||||||
|
|
||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
minLongMemory: 16,
|
minLongMemory: 16,
|
||||||
@@ -46,6 +61,9 @@ const defaultSettings = {
|
|||||||
memoryFrozen: false,
|
memoryFrozen: false,
|
||||||
source: summary_sources.extras,
|
source: summary_sources.extras,
|
||||||
prompt: defaultPrompt,
|
prompt: defaultPrompt,
|
||||||
|
template: defaultTemplate,
|
||||||
|
position: extension_prompt_types.AFTER_SCENARIO,
|
||||||
|
depth: 2,
|
||||||
promptWords: 200,
|
promptWords: 200,
|
||||||
promptMinWords: 25,
|
promptMinWords: 25,
|
||||||
promptMaxWords: 1000,
|
promptMaxWords: 1000,
|
||||||
@@ -54,6 +72,10 @@ const defaultSettings = {
|
|||||||
promptMinInterval: 1,
|
promptMinInterval: 1,
|
||||||
promptMaxInterval: 100,
|
promptMaxInterval: 100,
|
||||||
promptIntervalStep: 1,
|
promptIntervalStep: 1,
|
||||||
|
promptForceWords: 0,
|
||||||
|
promptForceWordsStep: 100,
|
||||||
|
promptMinForceWords: 0,
|
||||||
|
promptMaxForceWords: 10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
@@ -61,20 +83,10 @@ function loadSettings() {
|
|||||||
Object.assign(extension_settings.memory, defaultSettings);
|
Object.assign(extension_settings.memory, defaultSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension_settings.memory.source === undefined) {
|
for (const key of Object.keys(defaultSettings)) {
|
||||||
extension_settings.memory.source = defaultSettings.source;
|
if (extension_settings.memory[key] === undefined) {
|
||||||
}
|
extension_settings.memory[key] = defaultSettings[key];
|
||||||
|
}
|
||||||
if (extension_settings.memory.prompt === undefined) {
|
|
||||||
extension_settings.memory.prompt = defaultSettings.prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_settings.memory.promptWords === undefined) {
|
|
||||||
extension_settings.memory.promptWords = defaultSettings.promptWords;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_settings.memory.promptInterval === undefined) {
|
|
||||||
extension_settings.memory.promptInterval = defaultSettings.promptInterval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#summary_source').val(extension_settings.memory.source).trigger('change');
|
$('#summary_source').val(extension_settings.memory.source).trigger('change');
|
||||||
@@ -87,6 +99,10 @@ function loadSettings() {
|
|||||||
$('#memory_prompt').val(extension_settings.memory.prompt).trigger('input');
|
$('#memory_prompt').val(extension_settings.memory.prompt).trigger('input');
|
||||||
$('#memory_prompt_words').val(extension_settings.memory.promptWords).trigger('input');
|
$('#memory_prompt_words').val(extension_settings.memory.promptWords).trigger('input');
|
||||||
$('#memory_prompt_interval').val(extension_settings.memory.promptInterval).trigger('input');
|
$('#memory_prompt_interval').val(extension_settings.memory.promptInterval).trigger('input');
|
||||||
|
$('#memory_template').val(extension_settings.memory.template).trigger('input');
|
||||||
|
$('#memory_depth').val(extension_settings.memory.depth).trigger('input');
|
||||||
|
$(`input[name="memory_position"][value="${extension_settings.memory.position}"]`).prop('checked', true).trigger('input');
|
||||||
|
$('#memory_prompt_words_force').val(extension_settings.memory.promptForceWords).trigger('input');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSummarySourceChange(event) {
|
function onSummarySourceChange(event) {
|
||||||
@@ -170,6 +186,31 @@ function onMemoryPromptInput() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onMemoryTemplateInput() {
|
||||||
|
const value = $(this).val();
|
||||||
|
extension_settings.memory.template = value;
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMemoryDepthInput() {
|
||||||
|
const value = $(this).val();
|
||||||
|
extension_settings.memory.depth = Number(value);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMemoryPositionChange(e) {
|
||||||
|
const value = e.target.value;
|
||||||
|
extension_settings.memory.position = value;
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMemoryPromptWordsForceInput() {
|
||||||
|
const value = $(this).val();
|
||||||
|
extension_settings.memory.promptForceWords = Number(value);
|
||||||
|
$('#memory_prompt_words_force_value').text(extension_settings.memory.promptForceWords);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
function saveLastValues() {
|
function saveLastValues() {
|
||||||
const context = getContext();
|
const context = getContext();
|
||||||
lastGroupId = context.groupId;
|
lastGroupId = context.groupId;
|
||||||
@@ -310,19 +351,30 @@ async function summarizeChatMain(context, force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let messagesSinceLastSummary = 0;
|
let messagesSinceLastSummary = 0;
|
||||||
|
let wordsSinceLastSummary = 0;
|
||||||
|
let conditionSatisfied = false;
|
||||||
for (let i = context.chat.length - 1; i >= 0; i--) {
|
for (let i = context.chat.length - 1; i >= 0; i--) {
|
||||||
if (context.chat[i].extra && context.chat[i].extra.memory) {
|
if (context.chat[i].extra && context.chat[i].extra.memory) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
messagesSinceLastSummary++;
|
messagesSinceLastSummary++;
|
||||||
|
wordsSinceLastSummary += extractAllWords(context.chat[i].mes).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messagesSinceLastSummary < extension_settings.memory.promptInterval && !force) {
|
if (messagesSinceLastSummary >= extension_settings.memory.promptInterval) {
|
||||||
console.debug(`Not enough messages since last summary (messages: ${messagesSinceLastSummary}, interval: ${extension_settings.memory.promptInterval}`);
|
conditionSatisfied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension_settings.memory.promptForceWords && wordsSinceLastSummary >= extension_settings.memory.promptForceWords) {
|
||||||
|
conditionSatisfied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conditionSatisfied && !force) {
|
||||||
|
console.debug(`Summary conditions not satisfied (messages: ${messagesSinceLastSummary}, interval: ${extension_settings.memory.promptInterval}, words: ${wordsSinceLastSummary}, force words: ${extension_settings.memory.promptForceWords})`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Summarizing chat, messages since last summary: ' + messagesSinceLastSummary);
|
console.log('Summarizing chat, messages since last summary: ' + messagesSinceLastSummary, 'words since last summary: ' + wordsSinceLastSummary);
|
||||||
const prompt = substituteParams(extension_settings.memory.prompt)
|
const prompt = substituteParams(extension_settings.memory.prompt)
|
||||||
.replace(/{{words}}/gi, extension_settings.memory.promptWords);
|
.replace(/{{words}}/gi, extension_settings.memory.promptWords);
|
||||||
|
|
||||||
@@ -458,9 +510,11 @@ function onMemoryContentInput() {
|
|||||||
|
|
||||||
function setMemoryContext(value, saveToMessage) {
|
function setMemoryContext(value, saveToMessage) {
|
||||||
const context = getContext();
|
const context = getContext();
|
||||||
context.setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_prompt_types.AFTER_SCENARIO);
|
context.setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_settings.memory.position, extension_settings.memory.depth);
|
||||||
$('#memory_contents').val(value);
|
$('#memory_contents').val(value);
|
||||||
console.log('Memory set to: ' + value);
|
console.log('Summary set to: ' + value);
|
||||||
|
console.debug('Position: ' + extension_settings.memory.position);
|
||||||
|
console.debug('Depth: ' + extension_settings.memory.depth);
|
||||||
|
|
||||||
if (saveToMessage && context.chat.length) {
|
if (saveToMessage && context.chat.length) {
|
||||||
const idx = context.chat.length - 2;
|
const idx = context.chat.length - 2;
|
||||||
@@ -496,6 +550,21 @@ jQuery(function () {
|
|||||||
<input id="memory_restore" class="menu_button" type="button" value="Restore previous state" />
|
<input id="memory_restore" class="menu_button" type="button" value="Restore previous state" />
|
||||||
<label for="memory_frozen"><input id="memory_frozen" type="checkbox" />Pause summarization</label>
|
<label for="memory_frozen"><input id="memory_frozen" type="checkbox" />Pause summarization</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="memory_template">
|
||||||
|
<label for="memory_template">Injection template:</label>
|
||||||
|
<textarea id="memory_template" class="text_pole textarea_compact" rows="1" placeholder="Use {{summary}} macro to specify the position of summarized text."></textarea>
|
||||||
|
</div>
|
||||||
|
<label for="memory_position">Injection position:</label>
|
||||||
|
<div class="radio_group">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="memory_position" value="0" />
|
||||||
|
After scenario
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="memory_position" value="1" />
|
||||||
|
In-chat @ Depth <input id="memory_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div data-source="main" class="memory_contents_controls">
|
<div data-source="main" class="memory_contents_controls">
|
||||||
</div>
|
</div>
|
||||||
<div data-source="main">
|
<div data-source="main">
|
||||||
@@ -511,6 +580,9 @@ jQuery(function () {
|
|||||||
<input id="memory_prompt_words" type="range" value="${defaultSettings.promptWords}" min="${defaultSettings.promptMinWords}" max="${defaultSettings.promptMaxWords}" step="${defaultSettings.promptWordsStep}" />
|
<input id="memory_prompt_words" type="range" value="${defaultSettings.promptWords}" min="${defaultSettings.promptMinWords}" max="${defaultSettings.promptMaxWords}" step="${defaultSettings.promptWordsStep}" />
|
||||||
<label for="memory_prompt_interval">Update interval (<span id="memory_prompt_interval_value"></span> messages)</label>
|
<label for="memory_prompt_interval">Update interval (<span id="memory_prompt_interval_value"></span> messages)</label>
|
||||||
<input id="memory_prompt_interval" type="range" value="${defaultSettings.promptInterval}" min="${defaultSettings.promptMinInterval}" max="${defaultSettings.promptMaxInterval}" step="${defaultSettings.promptIntervalStep}" />
|
<input id="memory_prompt_interval" type="range" value="${defaultSettings.promptInterval}" min="${defaultSettings.promptMinInterval}" max="${defaultSettings.promptMaxInterval}" step="${defaultSettings.promptIntervalStep}" />
|
||||||
|
<label for="memory_prompt_words_force">Force update after (<span id="memory_prompt_words_force_value"></span> words)</label>
|
||||||
|
<small>Set to 0 to disable</small>
|
||||||
|
<input id="memory_prompt_words_force" type="range" value="${defaultSettings.promptForceWords}" min="${defaultSettings.promptMinForceWords}" max="${defaultSettings.promptMaxForceWords}" step="${defaultSettings.promptForceWordsStep}" />
|
||||||
</div>
|
</div>
|
||||||
<div data-source="extras">
|
<div data-source="extras">
|
||||||
<label for="memory_short_length">Chat to Summarize buffer length (<span id="memory_short_length_tokens"></span> tokens)</label>
|
<label for="memory_short_length">Chat to Summarize buffer length (<span id="memory_short_length_tokens"></span> tokens)</label>
|
||||||
@@ -542,6 +614,10 @@ jQuery(function () {
|
|||||||
$('#memory_prompt_interval').on('input', onMemoryPromptIntervalInput);
|
$('#memory_prompt_interval').on('input', onMemoryPromptIntervalInput);
|
||||||
$('#memory_prompt').on('input', onMemoryPromptInput);
|
$('#memory_prompt').on('input', onMemoryPromptInput);
|
||||||
$('#memory_force_summarize').on('click', forceSummarizeChat);
|
$('#memory_force_summarize').on('click', forceSummarizeChat);
|
||||||
|
$('#memory_template').on('input', onMemoryTemplateInput);
|
||||||
|
$('#memory_depth').on('input', onMemoryDepthInput);
|
||||||
|
$('input[name="memory_position"]').on('change', onMemoryPositionChange);
|
||||||
|
$('#memory_prompt_words_force').on('input', onMemoryPromptWordsForceInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
addExtensionControls();
|
addExtensionControls();
|
||||||
|
@@ -1,34 +1,26 @@
|
|||||||
#memory_settings {
|
#memory_settings {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
#memory_settings textarea {
|
#memory_settings textarea {
|
||||||
font-size: calc(var(--mainFontSize) * 0.9);
|
font-size: calc(var(--mainFontSize) * 0.9);
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#memory_settings input[type="range"] {
|
label[for="memory_frozen"] {
|
||||||
margin-bottom: 20px;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
|
margin: 0 !important;
|
||||||
#memory_settings label {
|
}
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
label[for="memory_frozen"] input {
|
||||||
|
margin-right: 10px;
|
||||||
label[for="memory_frozen"] {
|
}
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
.memory_contents_controls {
|
||||||
margin: 0 !important;
|
display: flex;
|
||||||
}
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
label[for="memory_frozen"] input {
|
justify-content: space-between;
|
||||||
margin-right: 10px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.memory_contents_controls {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
@@ -69,14 +69,21 @@ function getTaskByIdRecurse(taskId, task) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function substituteParamsPrompts(content) {
|
||||||
|
content = content.replace(/{{objective}}/gi, currentObjective.description)
|
||||||
|
content = content.replace(/{{task}}/gi, currentTask.description)
|
||||||
|
content = substituteParams(content)
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
// Call Quiet Generate to create task list using character context, then convert to tasks. Should not be called much.
|
// Call Quiet Generate to create task list using character context, then convert to tasks. Should not be called much.
|
||||||
async function generateTasks() {
|
async function generateTasks() {
|
||||||
|
|
||||||
const prompt = substituteParams(objectivePrompts.createTask.replace(/{{objective}}/gi, currentObjective.description));
|
const prompt = substituteParamsPrompts(objectivePrompts.createTask);
|
||||||
console.log(`Generating tasks for objective with prompt`)
|
console.log(`Generating tasks for objective with prompt`)
|
||||||
toastr.info('Generating tasks for objective', 'Please wait...');
|
toastr.info('Generating tasks for objective', 'Please wait...');
|
||||||
const taskResponse = await generateQuietPrompt(prompt)
|
const taskResponse = await generateQuietPrompt(prompt)
|
||||||
|
|
||||||
// Clear all existing objective tasks when generating
|
// Clear all existing objective tasks when generating
|
||||||
currentObjective.children = []
|
currentObjective.children = []
|
||||||
const numberedListPattern = /^\d+\./
|
const numberedListPattern = /^\d+\./
|
||||||
@@ -100,8 +107,9 @@ async function checkTaskCompleted() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
checkCounter = $('#objective-check-frequency').val()
|
checkCounter = $('#objective-check-frequency').val()
|
||||||
|
toastr.info("Checking for task completion.")
|
||||||
|
|
||||||
const prompt = substituteParams(objectivePrompts.checkTaskCompleted.replace(/{{task}}/gi, currentTask.description));
|
const prompt = substituteParamsPrompts(objectivePrompts.checkTaskCompleted);
|
||||||
const taskResponse = (await generateQuietPrompt(prompt)).toLowerCase()
|
const taskResponse = (await generateQuietPrompt(prompt)).toLowerCase()
|
||||||
|
|
||||||
// Check response if task complete
|
// Check response if task complete
|
||||||
@@ -116,8 +124,10 @@ async function checkTaskCompleted() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNextIncompleteTaskRecurse(task){
|
function getNextIncompleteTaskRecurse(task){
|
||||||
// Skip tasks with children, as they will have subtasks to determine completeness
|
if (task.completed === false // Return task if incomplete
|
||||||
if (task.completed === false && task.children.length === 0){
|
&& task.children.length === 0 // Ensure task has no children, it's subtasks will determine completeness
|
||||||
|
&& task.parentId // Must have parent id. Only root task will be missing this and we dont want that
|
||||||
|
){
|
||||||
return task
|
return task
|
||||||
}
|
}
|
||||||
for (const childTask of task.children) {
|
for (const childTask of task.children) {
|
||||||
@@ -149,7 +159,7 @@ function setCurrentTask(taskId = null) {
|
|||||||
// Don't just check for a current task, check if it has data
|
// Don't just check for a current task, check if it has data
|
||||||
const description = currentTask.description || null;
|
const description = currentTask.description || null;
|
||||||
if (description) {
|
if (description) {
|
||||||
const extensionPromptText = objectivePrompts.currentTask.replace(/{{task}}/gi, description);
|
const extensionPromptText = substituteParamsPrompts(objectivePrompts.currentTask);
|
||||||
|
|
||||||
// Remove highlights
|
// Remove highlights
|
||||||
$('.objective-task').css({'border-color':'','border-width':''})
|
$('.objective-task').css({'border-color':'','border-width':''})
|
||||||
@@ -163,7 +173,6 @@ function setCurrentTask(taskId = null) {
|
|||||||
highlightTask = parent
|
highlightTask = parent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update the extension prompt
|
// Update the extension prompt
|
||||||
context.setExtensionPrompt(MODULE_NAME, extensionPromptText, 1, $('#objective-chat-depth').val());
|
context.setExtensionPrompt(MODULE_NAME, extensionPromptText, 1, $('#objective-chat-depth').val());
|
||||||
console.info(`Current task in context.extensionPrompts.Objective is ${JSON.stringify(context.extensionPrompts.Objective)}`);
|
console.info(`Current task in context.extensionPrompts.Objective is ${JSON.stringify(context.extensionPrompts.Objective)}`);
|
||||||
@@ -369,6 +378,8 @@ function onEditPromptClick() {
|
|||||||
let popupText = ''
|
let popupText = ''
|
||||||
popupText += `
|
popupText += `
|
||||||
<div class="objective_prompt_modal">
|
<div class="objective_prompt_modal">
|
||||||
|
<small>Edit prompts used by Objective for this session. You can use {{objective}} or {{task}} plus any other standard template variables. Save template to persist changes.</small>
|
||||||
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<label for="objective-prompt-generate">Generation Prompt</label>
|
<label for="objective-prompt-generate">Generation Prompt</label>
|
||||||
<textarea id="objective-prompt-generate" type="text" class="text_pole textarea_compact" rows="8"></textarea>
|
<textarea id="objective-prompt-generate" type="text" class="text_pole textarea_compact" rows="8"></textarea>
|
||||||
@@ -378,12 +389,12 @@ function onEditPromptClick() {
|
|||||||
<textarea id="objective-prompt-extension-prompt" type="text" class="text_pole textarea_compact" rows="8"></textarea>
|
<textarea id="objective-prompt-extension-prompt" type="text" class="text_pole textarea_compact" rows="8"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="objective_prompt_block">
|
<div class="objective_prompt_block">
|
||||||
<input id="objective-custom-prompt-name" style="flex-grow:2" type="text" class="flex1 heightFitContent text_pole widthNatural" maxlength="250" placeholder="Custom Prompt Name">
|
<label for="objective-custom-prompt-select">Custom Prompt Select</label>
|
||||||
<input id="objective-custom-prompt-save" style="flex-grow:1" class="menu_button" type="submit" value="Save Prompt" />
|
<select id="objective-custom-prompt-select"><select>
|
||||||
</div>
|
</div>
|
||||||
<div class="objective_prompt_block">
|
<div class="objective_prompt_block">
|
||||||
<label for="objective-prompt-load">Load Prompt</label>
|
<input id="objective-custom-prompt-new" class="menu_button" type="submit" value="New Prompt" />
|
||||||
<select id="objective-prompt-load"><select>
|
<input id="objective-custom-prompt-save" class="menu_button" type="submit" value="Save Prompt" />
|
||||||
<input id="objective-custom-prompt-delete" class="menu_button" type="submit" value="Delete Prompt" />
|
<input id="objective-custom-prompt-delete" class="menu_button" type="submit" value="Delete Prompt" />
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
@@ -405,23 +416,28 @@ function onEditPromptClick() {
|
|||||||
$('#objective-prompt-extension-prompt').on('input', () => {
|
$('#objective-prompt-extension-prompt').on('input', () => {
|
||||||
objectivePrompts.currentTask = $('#objective-prompt-extension-prompt').val()
|
objectivePrompts.currentTask = $('#objective-prompt-extension-prompt').val()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Handle new
|
||||||
|
$('#objective-custom-prompt-new').on('click', () => {
|
||||||
|
newCustomPrompt()
|
||||||
|
})
|
||||||
|
|
||||||
// Handle save
|
// Handle save
|
||||||
$('#objective-custom-prompt-save').on('click', () => {
|
$('#objective-custom-prompt-save').on('click', () => {
|
||||||
saveCustomPrompt($('#objective-custom-prompt-name').val(), objectivePrompts)
|
saveCustomPrompt()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle delete
|
// Handle delete
|
||||||
$('#objective-custom-prompt-delete').on('click', () => {
|
$('#objective-custom-prompt-delete').on('click', () => {
|
||||||
const optionSelected = $("#objective-prompt-load").find(':selected').val()
|
deleteCustomPrompt()
|
||||||
deleteCustomPrompt(optionSelected)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle load
|
// Handle load
|
||||||
$('#objective-prompt-load').on('change', loadCustomPrompt)
|
$('#objective-custom-prompt-select').on('change', loadCustomPrompt)
|
||||||
}
|
}
|
||||||
|
async function newCustomPrompt() {
|
||||||
function saveCustomPrompt(customPromptName, customPrompts) {
|
const customPromptName = await callPopup('<h3>Custom Prompt name:</h3>', 'input');
|
||||||
|
|
||||||
if (customPromptName == "") {
|
if (customPromptName == "") {
|
||||||
toastr.warning("Please set custom prompt name to save.")
|
toastr.warning("Please set custom prompt name to save.")
|
||||||
return
|
return
|
||||||
@@ -431,12 +447,25 @@ function saveCustomPrompt(customPromptName, customPrompts) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
extension_settings.objective.customPrompts[customPromptName] = {}
|
extension_settings.objective.customPrompts[customPromptName] = {}
|
||||||
Object.assign(extension_settings.objective.customPrompts[customPromptName], customPrompts)
|
Object.assign(extension_settings.objective.customPrompts[customPromptName], objectivePrompts)
|
||||||
saveSettingsDebounced()
|
saveSettingsDebounced()
|
||||||
populateCustomPrompts()
|
populateCustomPrompts()
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCustomPrompt(customPromptName){
|
function saveCustomPrompt() {
|
||||||
|
const customPromptName = $("#objective-custom-prompt-select").find(':selected').val()
|
||||||
|
if (customPromptName == "default"){
|
||||||
|
toastr.error("Cannot save over default prompt")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Object.assign(extension_settings.objective.customPrompts[customPromptName], objectivePrompts)
|
||||||
|
saveSettingsDebounced()
|
||||||
|
populateCustomPrompts()
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCustomPrompt(){
|
||||||
|
const customPromptName = $("#objective-custom-prompt-select").find(':selected').val()
|
||||||
|
|
||||||
if (customPromptName == "default"){
|
if (customPromptName == "default"){
|
||||||
toastr.error("Cannot delete default prompt")
|
toastr.error("Cannot delete default prompt")
|
||||||
return
|
return
|
||||||
@@ -448,8 +477,7 @@ function deleteCustomPrompt(customPromptName){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadCustomPrompt(){
|
function loadCustomPrompt(){
|
||||||
const optionSelected = $("#objective-prompt-load").find(':selected').val()
|
const optionSelected = $("#objective-custom-prompt-select").find(':selected').val()
|
||||||
console.log(optionSelected)
|
|
||||||
Object.assign(objectivePrompts, extension_settings.objective.customPrompts[optionSelected])
|
Object.assign(objectivePrompts, extension_settings.objective.customPrompts[optionSelected])
|
||||||
|
|
||||||
$('#objective-prompt-generate').val(objectivePrompts.createTask)
|
$('#objective-prompt-generate').val(objectivePrompts.createTask)
|
||||||
@@ -459,13 +487,13 @@ function loadCustomPrompt(){
|
|||||||
|
|
||||||
function populateCustomPrompts(){
|
function populateCustomPrompts(){
|
||||||
// Populate saved prompts
|
// Populate saved prompts
|
||||||
$('#objective-prompt-load').empty()
|
$('#objective-custom-prompt-select').empty()
|
||||||
for (const customPromptName in extension_settings.objective.customPrompts){
|
for (const customPromptName in extension_settings.objective.customPrompts){
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.innerText = customPromptName;
|
option.innerText = customPromptName;
|
||||||
option.value = customPromptName;
|
option.value = customPromptName;
|
||||||
option.selected = customPromptName
|
option.selected = customPromptName
|
||||||
$('#objective-prompt-load').append(option)
|
$('#objective-custom-prompt-select').append(option)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,8 +602,10 @@ function onChatDepthInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onObjectiveTextFocusOut(){
|
function onObjectiveTextFocusOut(){
|
||||||
currentObjective.description = $('#objective-text').val()
|
if (currentObjective){
|
||||||
saveState()
|
currentObjective.description = $('#objective-text').val()
|
||||||
|
saveState()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update how often we check for task completion
|
// Update how often we check for task completion
|
||||||
@@ -752,7 +782,7 @@ jQuery(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
eventSource.on(event_types.MESSAGE_RECEIVED, () => {
|
eventSource.on(event_types.MESSAGE_RECEIVED, () => {
|
||||||
if (currentChatId == undefined) {
|
if (currentChatId == undefined || currentTask == undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ($("#objective-check-frequency").val() > 0) {
|
if ($("#objective-check-frequency").val() > 0) {
|
||||||
|
@@ -1,19 +1,48 @@
|
|||||||
import { saveSettingsDebounced } from "../../../script.js";
|
import { saveSettingsDebounced, callPopup, getRequestHeaders } from "../../../script.js";
|
||||||
import { getContext, extension_settings } from "../../extensions.js";
|
import { getContext, extension_settings } from "../../extensions.js";
|
||||||
import { initScrollHeight, resetScrollHeight } from "../../utils.js";
|
import { initScrollHeight, resetScrollHeight } from "../../utils.js";
|
||||||
|
|
||||||
|
|
||||||
export { MODULE_NAME };
|
export { MODULE_NAME };
|
||||||
|
|
||||||
const MODULE_NAME = 'quick-reply';
|
const MODULE_NAME = 'quick-reply';
|
||||||
const UPDATE_INTERVAL = 1000;
|
const UPDATE_INTERVAL = 1000;
|
||||||
|
let presets = [];
|
||||||
|
let selected_preset = '';
|
||||||
|
|
||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
quickReplyEnabled: false,
|
quickReplyEnabled: true,
|
||||||
numberOfSlots: 5,
|
numberOfSlots: 5,
|
||||||
quickReplySlots: [],
|
quickReplySlots: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadSettings() {
|
//method from worldinfo
|
||||||
|
async function updateQuickReplyPresetList() {
|
||||||
|
var result = await fetch("/getsettings", {
|
||||||
|
method: "POST",
|
||||||
|
headers: getRequestHeaders(),
|
||||||
|
body: JSON.stringify({}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.ok) {
|
||||||
|
var data = await result.json();
|
||||||
|
presets = data.quickReplyPresets?.length ? data.quickReplyPresets : [];
|
||||||
|
console.log(presets)
|
||||||
|
$("#quickReplyPresets").find('option[value!=""]').remove();
|
||||||
|
|
||||||
|
|
||||||
|
if (presets !== undefined) {
|
||||||
|
presets.forEach((item, i) => {
|
||||||
|
$("#quickReplyPresets").append(`<option value='${item.name}'${selected_preset.includes(item.name) ? ' selected' : ''}>${item.name}</option>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadSettings(type) {
|
||||||
|
if (type === 'init') {
|
||||||
|
await updateQuickReplyPresetList()
|
||||||
|
}
|
||||||
if (Object.keys(extension_settings.quickReply).length === 0) {
|
if (Object.keys(extension_settings.quickReply).length === 0) {
|
||||||
Object.assign(extension_settings.quickReply, defaultSettings);
|
Object.assign(extension_settings.quickReply, defaultSettings);
|
||||||
}
|
}
|
||||||
@@ -111,6 +140,51 @@ async function moduleWorker() {
|
|||||||
if (extension_settings.quickReply.quickReplyEnabled === true) {
|
if (extension_settings.quickReply.quickReplyEnabled === true) {
|
||||||
$('#quickReplyBar').toggle(getContext().onlineStatus !== 'no_connection');
|
$('#quickReplyBar').toggle(getContext().onlineStatus !== 'no_connection');
|
||||||
}
|
}
|
||||||
|
if (extension_settings.quickReply.selectedPreset) {
|
||||||
|
selected_preset = extension_settings.quickReply.selectedPreset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveQuickReplyPreset() {
|
||||||
|
const name = await callPopup('Enter a name for the Quick Reply Preset:', 'input');
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const quickReplyPreset = {
|
||||||
|
name: name,
|
||||||
|
quickReplyEnabled: extension_settings.quickReply.quickReplyEnabled,
|
||||||
|
quickReplySlots: extension_settings.quickReply.quickReplySlots,
|
||||||
|
numberOfSlots: extension_settings.quickReply.numberOfSlots,
|
||||||
|
selectedPreset: name
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch('/savequickreply', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: getRequestHeaders(),
|
||||||
|
body: JSON.stringify(quickReplyPreset)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const quickReplyPresetIndex = presets.findIndex(x => x.name == name);
|
||||||
|
|
||||||
|
if (quickReplyPresetIndex == -1) {
|
||||||
|
presets.push(quickReplyPreset);
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.selected = true;
|
||||||
|
option.value = name;
|
||||||
|
option.innerText = name;
|
||||||
|
$('#quickReplyPresets').append(option);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
presets[quickReplyPresetIndex] = quickReplyPreset;
|
||||||
|
$(`#quickReplyPresets option[value="${name}"]`).attr('selected', true);
|
||||||
|
}
|
||||||
|
saveSettingsDebounced();
|
||||||
|
} else {
|
||||||
|
toastr.warning('Failed to save Quick Reply Preset.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onQuickReplyNumberOfSlotsInput() {
|
async function onQuickReplyNumberOfSlotsInput() {
|
||||||
@@ -178,6 +252,27 @@ function generateQuickReplyElements() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function applyQuickReplyPreset(name) {
|
||||||
|
const quickReplyPreset = presets.find(x => x.name == name);
|
||||||
|
|
||||||
|
if (!quickReplyPreset) {
|
||||||
|
console.log(`error, QR preset '${name}' not found`)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
extension_settings.quickReply = quickReplyPreset;
|
||||||
|
extension_settings.quickReply.selectedPreset = name;
|
||||||
|
saveSettingsDebounced()
|
||||||
|
loadSettings('init')
|
||||||
|
addQuickReplyBar();
|
||||||
|
moduleWorker();
|
||||||
|
|
||||||
|
$(`#quickReplyPresets option[value="${name}"]`).attr('selected', true);
|
||||||
|
|
||||||
|
console.debug('QR Preset applied: ' + name);
|
||||||
|
//loadMovingUIState()
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(async () => {
|
jQuery(async () => {
|
||||||
|
|
||||||
moduleWorker();
|
moduleWorker();
|
||||||
@@ -190,11 +285,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 class="checkbox_label marginBot10">
|
<div class="flex-container ">
|
||||||
<input id="quickReplyEnabled" type="checkbox" />
|
<label class="checkbox_label marginBot10 wide100p flexnowrap">
|
||||||
Enable Quick Replies
|
<input id="quickReplyEnabled" type="checkbox" />
|
||||||
</label>
|
Enable Quick Replies
|
||||||
<label for="quickReplyNumberOfSlots">Number of slots:</label>
|
</label>
|
||||||
|
<div class="flex-container flexnowrap wide100p">
|
||||||
|
<select id="quickReplyPresets" name="quickreply-preset">
|
||||||
|
</select>
|
||||||
|
<i id="quickReplyPresetSaveButton" class="fa-solid fa-save"></i>
|
||||||
|
</div>
|
||||||
|
<label for="quickReplyNumberOfSlots">Number of slots:</label>
|
||||||
|
</div>
|
||||||
<div class="flex-container flexGap5 flexnowrap">
|
<div class="flex-container flexGap5 flexnowrap">
|
||||||
<input id="quickReplyNumberOfSlots" class="text_pole" type="number" min="1" max="100" value="" />
|
<input id="quickReplyNumberOfSlots" class="text_pole" type="number" min="1" max="100" value="" />
|
||||||
<div class="menu_button menu_button_icon" id="quickReplyNumberOfSlotsApply">
|
<div class="menu_button menu_button_icon" id="quickReplyNumberOfSlotsApply">
|
||||||
@@ -212,8 +314,17 @@ jQuery(async () => {
|
|||||||
|
|
||||||
$('#quickReplyEnabled').on('input', onQuickReplyEnabledInput);
|
$('#quickReplyEnabled').on('input', onQuickReplyEnabledInput);
|
||||||
$('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput);
|
$('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput);
|
||||||
|
$("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset);
|
||||||
|
|
||||||
await loadSettings();
|
$("#quickReplyPresets").on('change', async function () {
|
||||||
|
const quickReplyPresetSelected = $(this).find(':selected').val();
|
||||||
|
extension_settings.quickReplyPreset = quickReplyPresetSelected;
|
||||||
|
applyQuickReplyPreset(quickReplyPresetSelected);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
await loadSettings('init');
|
||||||
addQuickReplyBar();
|
addQuickReplyBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import {
|
|||||||
delay,
|
delay,
|
||||||
isDataURL,
|
isDataURL,
|
||||||
createThumbnail,
|
createThumbnail,
|
||||||
|
extractAllWords,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
import { RA_CountCharTokens, humanizedDateTime, dragElement } from "./RossAscends-mods.js";
|
import { RA_CountCharTokens, humanizedDateTime, dragElement } from "./RossAscends-mods.js";
|
||||||
import { sortCharactersList, sortGroupMembers, loadMovingUIState } from './power-user.js';
|
import { sortCharactersList, sortGroupMembers, loadMovingUIState } from './power-user.js';
|
||||||
@@ -782,19 +783,6 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
|
|||||||
return memberIds;
|
return memberIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractAllWords(value) {
|
|
||||||
const words = [];
|
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
return words;
|
|
||||||
}
|
|
||||||
|
|
||||||
const matches = value.matchAll(/\b\w+\b/gim);
|
|
||||||
for (let match of matches) {
|
|
||||||
words.push(match[0].toLowerCase());
|
|
||||||
}
|
|
||||||
return words;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function deleteGroup(id) {
|
async function deleteGroup(id) {
|
||||||
|
@@ -102,7 +102,7 @@ const phraseRepPenStrings = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
function getPhraseRepPenString(phraseRepPenCounter) {
|
function getPhraseRepPenString(phraseRepPenCounter) {
|
||||||
if (phraseRepPenCounter < 1 || phraseRepPenCounter > F5) {
|
if (phraseRepPenCounter < 1 || phraseRepPenCounter > 5) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return phraseRepPenStrings[phraseRepPenCounter];
|
return phraseRepPenStrings[phraseRepPenCounter];
|
||||||
|
@@ -143,6 +143,7 @@ const default_settings = {
|
|||||||
api_url_scale: '',
|
api_url_scale: '',
|
||||||
show_external_models: false,
|
show_external_models: false,
|
||||||
proxy_password: '',
|
proxy_password: '',
|
||||||
|
assistant_prefill: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
const oai_settings = {
|
const oai_settings = {
|
||||||
@@ -180,6 +181,7 @@ const oai_settings = {
|
|||||||
api_url_scale: '',
|
api_url_scale: '',
|
||||||
show_external_models: false,
|
show_external_models: false,
|
||||||
proxy_password: '',
|
proxy_password: '',
|
||||||
|
assistant_prefill: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
let openai_setting_names;
|
let openai_setting_names;
|
||||||
@@ -775,6 +777,7 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) {
|
|||||||
if (isClaude) {
|
if (isClaude) {
|
||||||
generate_data['use_claude'] = true;
|
generate_data['use_claude'] = true;
|
||||||
generate_data['top_k'] = parseFloat(oai_settings.top_k_openai);
|
generate_data['top_k'] = parseFloat(oai_settings.top_k_openai);
|
||||||
|
generate_data['assistant_prefill'] = substituteParams(oai_settings.assistant_prefill);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOpenRouter) {
|
if (isOpenRouter) {
|
||||||
@@ -1109,6 +1112,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
oai_settings.api_url_scale = settings.api_url_scale ?? default_settings.api_url_scale;
|
oai_settings.api_url_scale = settings.api_url_scale ?? default_settings.api_url_scale;
|
||||||
oai_settings.show_external_models = settings.show_external_models ?? default_settings.show_external_models;
|
oai_settings.show_external_models = settings.show_external_models ?? default_settings.show_external_models;
|
||||||
oai_settings.proxy_password = settings.proxy_password ?? default_settings.proxy_password;
|
oai_settings.proxy_password = settings.proxy_password ?? default_settings.proxy_password;
|
||||||
|
oai_settings.assistant_prefill = settings.assistant_prefill ?? default_settings.assistant_prefill;
|
||||||
|
|
||||||
if (settings.nsfw_toggle !== undefined) oai_settings.nsfw_toggle = !!settings.nsfw_toggle;
|
if (settings.nsfw_toggle !== undefined) oai_settings.nsfw_toggle = !!settings.nsfw_toggle;
|
||||||
if (settings.keep_example_dialogue !== undefined) oai_settings.keep_example_dialogue = !!settings.keep_example_dialogue;
|
if (settings.keep_example_dialogue !== undefined) oai_settings.keep_example_dialogue = !!settings.keep_example_dialogue;
|
||||||
@@ -1121,6 +1125,7 @@ function loadOpenAISettings(data, settings) {
|
|||||||
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
||||||
$('#api_url_scale').val(oai_settings.api_url_scale);
|
$('#api_url_scale').val(oai_settings.api_url_scale);
|
||||||
$('#openai_proxy_password').val(oai_settings.proxy_password);
|
$('#openai_proxy_password').val(oai_settings.proxy_password);
|
||||||
|
$('#claude_assistant_prefill').val(oai_settings.assistant_prefill);
|
||||||
|
|
||||||
$('#model_openai_select').val(oai_settings.openai_model);
|
$('#model_openai_select').val(oai_settings.openai_model);
|
||||||
$(`#model_openai_select option[value="${oai_settings.openai_model}"`).attr('selected', true);
|
$(`#model_openai_select option[value="${oai_settings.openai_model}"`).attr('selected', true);
|
||||||
@@ -1323,6 +1328,7 @@ async function saveOpenAIPreset(name, settings) {
|
|||||||
stream_openai: settings.stream_openai,
|
stream_openai: settings.stream_openai,
|
||||||
api_url_scale: settings.api_url_scale,
|
api_url_scale: settings.api_url_scale,
|
||||||
show_external_models: settings.show_external_models,
|
show_external_models: settings.show_external_models,
|
||||||
|
assistant_prefill: settings.assistant_prefill,
|
||||||
};
|
};
|
||||||
|
|
||||||
const savePresetSettings = await fetch(`/savepreset_openai?name=${name}`, {
|
const savePresetSettings = await fetch(`/savepreset_openai?name=${name}`, {
|
||||||
@@ -1656,6 +1662,7 @@ function onSettingsPresetChange() {
|
|||||||
api_url_scale: ['#api_url_scale', 'api_url_scale', false],
|
api_url_scale: ['#api_url_scale', 'api_url_scale', false],
|
||||||
show_external_models: ['#openai_show_external_models', 'show_external_models', true],
|
show_external_models: ['#openai_show_external_models', 'show_external_models', true],
|
||||||
proxy_password: ['#openai_proxy_password', 'proxy_password', false],
|
proxy_password: ['#openai_proxy_password', 'proxy_password', false],
|
||||||
|
assistant_prefill: ['#claude_assistant_prefill', 'assistant_prefill', false],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const [key, [selector, setting, isCheckbox]] of Object.entries(settingsToUpdate)) {
|
for (const [key, [selector, setting, isCheckbox]] of Object.entries(settingsToUpdate)) {
|
||||||
@@ -2206,6 +2213,11 @@ $(document).ready(function () {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#claude_assistant_prefill').on('input', function () {
|
||||||
|
oai_settings.assistant_prefill = $(this).val();
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$("#api_button_openai").on("click", onConnectButtonClick);
|
$("#api_button_openai").on("click", onConnectButtonClick);
|
||||||
$("#openai_reverse_proxy").on("input", onReverseProxyInput);
|
$("#openai_reverse_proxy").on("input", onReverseProxyInput);
|
||||||
$("#model_openai_select").on("change", onModelChange);
|
$("#model_openai_select").on("change", onModelChange);
|
||||||
|
@@ -1224,12 +1224,6 @@ async function doMesCut(_, text) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//reject attempts to delete firstmes
|
|
||||||
if (text === '0') {
|
|
||||||
toastr.error('Cannot delete the First Message')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let mesIDToCut = Number(text).toFixed(0)
|
let mesIDToCut = Number(text).toFixed(0)
|
||||||
let mesToCut = $("#chat").find(`.mes[mesid=${mesIDToCut}]`)
|
let mesToCut = $("#chat").find(`.mes[mesid=${mesIDToCut}]`)
|
||||||
|
|
||||||
|
@@ -470,6 +470,20 @@ export function getCharaFilename(chid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function extractAllWords(value) {
|
||||||
|
const words = [];
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return words;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matches = value.matchAll(/\b\w+\b/gim);
|
||||||
|
for (let match of matches) {
|
||||||
|
words.push(match[0].toLowerCase());
|
||||||
|
}
|
||||||
|
return words;
|
||||||
|
}
|
||||||
|
|
||||||
export function escapeRegex(string) {
|
export function escapeRegex(string) {
|
||||||
return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ export {
|
|||||||
world_info_budget,
|
world_info_budget,
|
||||||
world_info_depth,
|
world_info_depth,
|
||||||
world_info_recursive,
|
world_info_recursive,
|
||||||
|
world_info_overflow_alert,
|
||||||
world_info_case_sensitive,
|
world_info_case_sensitive,
|
||||||
world_info_match_whole_words,
|
world_info_match_whole_words,
|
||||||
world_info_character_strategy,
|
world_info_character_strategy,
|
||||||
@@ -32,6 +33,7 @@ let world_names;
|
|||||||
let world_info_depth = 2;
|
let world_info_depth = 2;
|
||||||
let world_info_budget = 25;
|
let world_info_budget = 25;
|
||||||
let world_info_recursive = false;
|
let world_info_recursive = false;
|
||||||
|
let world_info_overflow_alert = false;
|
||||||
let world_info_case_sensitive = false;
|
let world_info_case_sensitive = false;
|
||||||
let world_info_match_whole_words = false;
|
let world_info_match_whole_words = false;
|
||||||
let world_info_character_strategy = world_info_insertion_strategy.character_first;
|
let world_info_character_strategy = world_info_insertion_strategy.character_first;
|
||||||
@@ -70,6 +72,8 @@ function setWorldInfoSettings(settings, data) {
|
|||||||
world_info_budget = Number(settings.world_info_budget);
|
world_info_budget = Number(settings.world_info_budget);
|
||||||
if (settings.world_info_recursive !== undefined)
|
if (settings.world_info_recursive !== undefined)
|
||||||
world_info_recursive = Boolean(settings.world_info_recursive);
|
world_info_recursive = Boolean(settings.world_info_recursive);
|
||||||
|
if (settings.world_info_overflow_alert !== undefined)
|
||||||
|
world_info_overflow_alert = Boolean(settings.world_info_overflow_alert);
|
||||||
if (settings.world_info_case_sensitive !== undefined)
|
if (settings.world_info_case_sensitive !== undefined)
|
||||||
world_info_case_sensitive = Boolean(settings.world_info_case_sensitive);
|
world_info_case_sensitive = Boolean(settings.world_info_case_sensitive);
|
||||||
if (settings.world_info_match_whole_words !== undefined)
|
if (settings.world_info_match_whole_words !== undefined)
|
||||||
@@ -102,6 +106,7 @@ function setWorldInfoSettings(settings, data) {
|
|||||||
$("#world_info_budget").val(world_info_budget);
|
$("#world_info_budget").val(world_info_budget);
|
||||||
|
|
||||||
$("#world_info_recursive").prop('checked', world_info_recursive);
|
$("#world_info_recursive").prop('checked', world_info_recursive);
|
||||||
|
$("#world_info_overflow_alert").prop('checked', world_info_overflow_alert);
|
||||||
$("#world_info_case_sensitive").prop('checked', world_info_case_sensitive);
|
$("#world_info_case_sensitive").prop('checked', world_info_case_sensitive);
|
||||||
$("#world_info_match_whole_words").prop('checked', world_info_match_whole_words);
|
$("#world_info_match_whole_words").prop('checked', world_info_match_whole_words);
|
||||||
|
|
||||||
@@ -1020,6 +1025,10 @@ async function checkWorldInfo(chat, maxContext) {
|
|||||||
|
|
||||||
if (textToScanTokens + getTokenCount(newContent) >= budget) {
|
if (textToScanTokens + getTokenCount(newContent) >= budget) {
|
||||||
console.debug(`WI budget reached, stopping`);
|
console.debug(`WI budget reached, stopping`);
|
||||||
|
if (world_info_overflow_alert) {
|
||||||
|
console.log("Alerting");
|
||||||
|
toastr.warning(`World info budget reached after ${count} entries.`, 'World Info');
|
||||||
|
}
|
||||||
needsToScan = false;
|
needsToScan = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1501,6 +1510,11 @@ jQuery(() => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#world_info_overflow_alert').on('change', function () {
|
||||||
|
world_info_overflow_alert = $(this).val();
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$('#world_button').on('click', async function () {
|
$('#world_button').on('click', async function () {
|
||||||
const chid = $('#set_character_world').data('chid');
|
const chid = $('#set_character_world').data('chid');
|
||||||
|
|
||||||
|
@@ -609,7 +609,7 @@ hr {
|
|||||||
display: flex;
|
display: flex;
|
||||||
column-gap: 10px;
|
column-gap: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
align-items: baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#extensionsMenu>div,
|
#extensionsMenu>div,
|
||||||
@@ -1293,7 +1293,7 @@ body.charListGrid #rm_print_characters_block .tags_inline {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.floating_prompt_radio_group {
|
.floating_prompt_radio_group, .radio_group {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
36
server.js
36
server.js
@@ -290,6 +290,7 @@ const directories = {
|
|||||||
instruct: 'public/instruct',
|
instruct: 'public/instruct',
|
||||||
context: 'public/context',
|
context: 'public/context',
|
||||||
backups: 'backups/',
|
backups: 'backups/',
|
||||||
|
quickreplies: 'public/QuickReplies'
|
||||||
};
|
};
|
||||||
|
|
||||||
// CSRF Protection //
|
// CSRF Protection //
|
||||||
@@ -1600,6 +1601,8 @@ app.post('/getsettings', jsonParser, (request, response) => {
|
|||||||
|
|
||||||
const themes = readAndParseFromDirectory(directories.themes);
|
const themes = readAndParseFromDirectory(directories.themes);
|
||||||
const movingUIPresets = readAndParseFromDirectory(directories.movingUI);
|
const movingUIPresets = readAndParseFromDirectory(directories.movingUI);
|
||||||
|
const quickReplyPresets = readAndParseFromDirectory(directories.quickreplies);
|
||||||
|
|
||||||
const instruct = readAndParseFromDirectory(directories.instruct);
|
const instruct = readAndParseFromDirectory(directories.instruct);
|
||||||
const context = readAndParseFromDirectory(directories.context);
|
const context = readAndParseFromDirectory(directories.context);
|
||||||
|
|
||||||
@@ -1616,6 +1619,7 @@ app.post('/getsettings', jsonParser, (request, response) => {
|
|||||||
textgenerationwebui_preset_names,
|
textgenerationwebui_preset_names,
|
||||||
themes,
|
themes,
|
||||||
movingUIPresets,
|
movingUIPresets,
|
||||||
|
quickReplyPresets,
|
||||||
instruct,
|
instruct,
|
||||||
context,
|
context,
|
||||||
enable_extensions: enableExtensions,
|
enable_extensions: enableExtensions,
|
||||||
@@ -1672,6 +1676,17 @@ app.post('/savemovingui', jsonParser, (request, response) => {
|
|||||||
return response.sendStatus(200);
|
return response.sendStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post('/savequickreply', jsonParser, (request, response) => {
|
||||||
|
if (!request.body || !request.body.name) {
|
||||||
|
return response.sendStatus(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filename = path.join(directories.quickreplies, sanitize(request.body.name) + '.json');
|
||||||
|
fs.writeFileSync(filename, JSON.stringify(request.body, null, 4), 'utf8');
|
||||||
|
|
||||||
|
return response.sendStatus(200);
|
||||||
|
});
|
||||||
|
|
||||||
function convertWorldInfoToCharacterBook(name, entries) {
|
function convertWorldInfoToCharacterBook(name, entries) {
|
||||||
const result = { entries: [], name };
|
const result = { entries: [], name };
|
||||||
|
|
||||||
@@ -1783,10 +1798,10 @@ app.post("/generate_novelai", jsonParser, async function (request, response_gene
|
|||||||
request.socket.on('close', function () {
|
request.socket.on('close', function () {
|
||||||
controller.abort();
|
controller.abort();
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(request.body);
|
const novelai = require('./src/novelai');
|
||||||
const bw = require('./src/bad-words');
|
|
||||||
const isNewModel = (request.body.model.includes('clio') || request.body.model.includes('kayra'));
|
const isNewModel = (request.body.model.includes('clio') || request.body.model.includes('kayra'));
|
||||||
|
const isKrake = request.body.model.includes('krake');
|
||||||
const data = {
|
const data = {
|
||||||
"input": request.body.input,
|
"input": request.body.input,
|
||||||
"model": request.body.model,
|
"model": request.body.model,
|
||||||
@@ -1801,6 +1816,7 @@ app.post("/generate_novelai", jsonParser, async function (request, response_gene
|
|||||||
"repetition_penalty_slope": request.body.repetition_penalty_slope,
|
"repetition_penalty_slope": request.body.repetition_penalty_slope,
|
||||||
"repetition_penalty_frequency": request.body.repetition_penalty_frequency,
|
"repetition_penalty_frequency": request.body.repetition_penalty_frequency,
|
||||||
"repetition_penalty_presence": request.body.repetition_penalty_presence,
|
"repetition_penalty_presence": request.body.repetition_penalty_presence,
|
||||||
|
"repetition_penalty_whitelist": isNewModel ? novelai.repPenaltyAllowList : null,
|
||||||
"top_a": request.body.top_a,
|
"top_a": request.body.top_a,
|
||||||
"top_p": request.body.top_p,
|
"top_p": request.body.top_p,
|
||||||
"top_k": request.body.top_k,
|
"top_k": request.body.top_k,
|
||||||
@@ -1809,15 +1825,18 @@ app.post("/generate_novelai", jsonParser, async function (request, response_gene
|
|||||||
"cfg_uc": request.body.cfg_uc,
|
"cfg_uc": request.body.cfg_uc,
|
||||||
"phrase_rep_pen": request.body.phrase_rep_pen,
|
"phrase_rep_pen": request.body.phrase_rep_pen,
|
||||||
//"stop_sequences": {{187}},
|
//"stop_sequences": {{187}},
|
||||||
"bad_words_ids": isNewModel ? bw.clioBadWordsId : bw.badWordIds,
|
"bad_words_ids": isNewModel ? novelai.badWordsList : (isKrake ? novelai.krakeBadWordsList : novelai.euterpeBadWordsList),
|
||||||
|
"logit_bias_exp": isNewModel ? novelai.logitBiasExp : null,
|
||||||
//generate_until_sentence = true;
|
//generate_until_sentence = true;
|
||||||
"use_cache": request.body.use_cache,
|
"use_cache": request.body.use_cache,
|
||||||
"use_string": true,
|
"use_string": true,
|
||||||
"return_full_text": request.body.return_full_text,
|
"return_full_text": request.body.return_full_text,
|
||||||
"prefix": isNewModel ? "special_instruct" : request.body.prefix,
|
"prefix": request.body.prefix,
|
||||||
"order": request.body.order
|
"order": request.body.order
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const util = require('util');
|
||||||
|
console.log(util.inspect(data, { depth: 4 }))
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
@@ -3077,7 +3096,12 @@ async function sendClaudeRequest(request, response) {
|
|||||||
controller.abort();
|
controller.abort();
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestPrompt = convertClaudePrompt(request.body.messages, true, true);
|
let requestPrompt = convertClaudePrompt(request.body.messages, true, true);
|
||||||
|
|
||||||
|
if (request.body.assistant_prefill) {
|
||||||
|
requestPrompt += request.body.assistant_prefill;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Claude request:', requestPrompt);
|
console.log('Claude request:', requestPrompt);
|
||||||
|
|
||||||
const generateResponse = await fetch(api_url + '/complete', {
|
const generateResponse = await fetch(api_url + '/complete', {
|
||||||
|
326
src/bad-words.js
326
src/bad-words.js
@@ -1,326 +0,0 @@
|
|||||||
const badWordIds = [
|
|
||||||
[60],
|
|
||||||
[62],
|
|
||||||
[544],
|
|
||||||
[683],
|
|
||||||
[696],
|
|
||||||
[880],
|
|
||||||
[905],
|
|
||||||
[1008],
|
|
||||||
[1019],
|
|
||||||
[1084],
|
|
||||||
[1092],
|
|
||||||
[1181],
|
|
||||||
[1184],
|
|
||||||
[1254],
|
|
||||||
[1447],
|
|
||||||
[1570],
|
|
||||||
[1656],
|
|
||||||
[2194],
|
|
||||||
[2470],
|
|
||||||
[2479],
|
|
||||||
[2498],
|
|
||||||
[2947],
|
|
||||||
[3138],
|
|
||||||
[3291],
|
|
||||||
[3455],
|
|
||||||
[3725],
|
|
||||||
[3851],
|
|
||||||
[3891],
|
|
||||||
[3921],
|
|
||||||
[3951],
|
|
||||||
[4207],
|
|
||||||
[4299],
|
|
||||||
[4622],
|
|
||||||
[4681],
|
|
||||||
[5013],
|
|
||||||
[5032],
|
|
||||||
[5180],
|
|
||||||
[5218],
|
|
||||||
[5290],
|
|
||||||
[5413],
|
|
||||||
[5456],
|
|
||||||
[5709],
|
|
||||||
[5749],
|
|
||||||
[5774],
|
|
||||||
[6038],
|
|
||||||
[6257],
|
|
||||||
[6334],
|
|
||||||
[6660],
|
|
||||||
[6904],
|
|
||||||
[7082],
|
|
||||||
[7086],
|
|
||||||
[7254],
|
|
||||||
[7444],
|
|
||||||
[7748],
|
|
||||||
[8001],
|
|
||||||
[8088],
|
|
||||||
[8168],
|
|
||||||
[8562],
|
|
||||||
[8605],
|
|
||||||
[8795],
|
|
||||||
[8850],
|
|
||||||
[9014],
|
|
||||||
[9102],
|
|
||||||
[9259],
|
|
||||||
[9318],
|
|
||||||
[9336],
|
|
||||||
[9502],
|
|
||||||
[9686],
|
|
||||||
[9793],
|
|
||||||
[9855],
|
|
||||||
[9899],
|
|
||||||
[9955],
|
|
||||||
[10148],
|
|
||||||
[10174],
|
|
||||||
[10943],
|
|
||||||
[11326],
|
|
||||||
[11337],
|
|
||||||
[11661],
|
|
||||||
[12004],
|
|
||||||
[12084],
|
|
||||||
[12159],
|
|
||||||
[12520],
|
|
||||||
[12977],
|
|
||||||
[13380],
|
|
||||||
[13488],
|
|
||||||
[13663],
|
|
||||||
[13811],
|
|
||||||
[13976],
|
|
||||||
[14412],
|
|
||||||
[14598],
|
|
||||||
[14767],
|
|
||||||
[15640],
|
|
||||||
[15707],
|
|
||||||
[15775],
|
|
||||||
[15830],
|
|
||||||
[16079],
|
|
||||||
[16354],
|
|
||||||
[16369],
|
|
||||||
[16445],
|
|
||||||
[16595],
|
|
||||||
[16614],
|
|
||||||
[16731],
|
|
||||||
[16943],
|
|
||||||
[17278],
|
|
||||||
[17281],
|
|
||||||
[17548],
|
|
||||||
[17555],
|
|
||||||
[17981],
|
|
||||||
[18022],
|
|
||||||
[18095],
|
|
||||||
[18297],
|
|
||||||
[18413],
|
|
||||||
[18736],
|
|
||||||
[18772],
|
|
||||||
[18990],
|
|
||||||
[19181],
|
|
||||||
[20095],
|
|
||||||
[20197],
|
|
||||||
[20481],
|
|
||||||
[20629],
|
|
||||||
[20871],
|
|
||||||
[20879],
|
|
||||||
[20924],
|
|
||||||
[20977],
|
|
||||||
[21375],
|
|
||||||
[21382],
|
|
||||||
[21391],
|
|
||||||
[21687],
|
|
||||||
[21810],
|
|
||||||
[21828],
|
|
||||||
[21938],
|
|
||||||
[22367],
|
|
||||||
[22372],
|
|
||||||
[22734],
|
|
||||||
[23405],
|
|
||||||
[23505],
|
|
||||||
[23734],
|
|
||||||
[23741],
|
|
||||||
[23781],
|
|
||||||
[24237],
|
|
||||||
[24254],
|
|
||||||
[24345],
|
|
||||||
[24430],
|
|
||||||
[25416],
|
|
||||||
[25896],
|
|
||||||
[26119],
|
|
||||||
[26635],
|
|
||||||
[26842],
|
|
||||||
[26991],
|
|
||||||
[26997],
|
|
||||||
[27075],
|
|
||||||
[27114],
|
|
||||||
[27468],
|
|
||||||
[27501],
|
|
||||||
[27618],
|
|
||||||
[27655],
|
|
||||||
[27720],
|
|
||||||
[27829],
|
|
||||||
[28052],
|
|
||||||
[28118],
|
|
||||||
[28231],
|
|
||||||
[28532],
|
|
||||||
[28571],
|
|
||||||
[28591],
|
|
||||||
[28653],
|
|
||||||
[29013],
|
|
||||||
[29547],
|
|
||||||
[29650],
|
|
||||||
[29925],
|
|
||||||
[30522],
|
|
||||||
[30537],
|
|
||||||
[30996],
|
|
||||||
[31011],
|
|
||||||
[31053],
|
|
||||||
[31096],
|
|
||||||
[31148],
|
|
||||||
[31258],
|
|
||||||
[31350],
|
|
||||||
[31379],
|
|
||||||
[31422],
|
|
||||||
[31789],
|
|
||||||
[31830],
|
|
||||||
[32214],
|
|
||||||
[32666],
|
|
||||||
[32871],
|
|
||||||
[33094],
|
|
||||||
[33376],
|
|
||||||
[33440],
|
|
||||||
[33805],
|
|
||||||
[34368],
|
|
||||||
[34398],
|
|
||||||
[34417],
|
|
||||||
[34418],
|
|
||||||
[34419],
|
|
||||||
[34476],
|
|
||||||
[34494],
|
|
||||||
[34607],
|
|
||||||
[34758],
|
|
||||||
[34761],
|
|
||||||
[34904],
|
|
||||||
[34993],
|
|
||||||
[35117],
|
|
||||||
[35138],
|
|
||||||
[35237],
|
|
||||||
[35487],
|
|
||||||
[35830],
|
|
||||||
[35869],
|
|
||||||
[36033],
|
|
||||||
[36134],
|
|
||||||
[36320],
|
|
||||||
[36399],
|
|
||||||
[36487],
|
|
||||||
[36586],
|
|
||||||
[36676],
|
|
||||||
[36692],
|
|
||||||
[36786],
|
|
||||||
[37077],
|
|
||||||
[37594],
|
|
||||||
[37596],
|
|
||||||
[37786],
|
|
||||||
[37982],
|
|
||||||
[38475],
|
|
||||||
[38791],
|
|
||||||
[39083],
|
|
||||||
[39258],
|
|
||||||
[39487],
|
|
||||||
[39822],
|
|
||||||
[40116],
|
|
||||||
[40125],
|
|
||||||
[41000],
|
|
||||||
[41018],
|
|
||||||
[41256],
|
|
||||||
[41305],
|
|
||||||
[41361],
|
|
||||||
[41447],
|
|
||||||
[41449],
|
|
||||||
[41512],
|
|
||||||
[41604],
|
|
||||||
[42041],
|
|
||||||
[42274],
|
|
||||||
[42368],
|
|
||||||
[42696],
|
|
||||||
[42767],
|
|
||||||
[42804],
|
|
||||||
[42854],
|
|
||||||
[42944],
|
|
||||||
[42989],
|
|
||||||
[43134],
|
|
||||||
[43144],
|
|
||||||
[43189],
|
|
||||||
[43521],
|
|
||||||
[43782],
|
|
||||||
[44082],
|
|
||||||
[44162],
|
|
||||||
[44270],
|
|
||||||
[44308],
|
|
||||||
[44479],
|
|
||||||
[44524],
|
|
||||||
[44965],
|
|
||||||
[45114],
|
|
||||||
[45301],
|
|
||||||
[45382],
|
|
||||||
[45443],
|
|
||||||
[45472],
|
|
||||||
[45488],
|
|
||||||
[45507],
|
|
||||||
[45564],
|
|
||||||
[45662],
|
|
||||||
[46265],
|
|
||||||
[46267],
|
|
||||||
[46275],
|
|
||||||
[46295],
|
|
||||||
[46462],
|
|
||||||
[46468],
|
|
||||||
[46576],
|
|
||||||
[46694],
|
|
||||||
[47093],
|
|
||||||
[47384],
|
|
||||||
[47389],
|
|
||||||
[47446],
|
|
||||||
[47552],
|
|
||||||
[47686],
|
|
||||||
[47744],
|
|
||||||
[47916],
|
|
||||||
[48064],
|
|
||||||
[48167],
|
|
||||||
[48392],
|
|
||||||
[48471],
|
|
||||||
[48664],
|
|
||||||
[48701],
|
|
||||||
[49021],
|
|
||||||
[49193],
|
|
||||||
[49236],
|
|
||||||
[49550],
|
|
||||||
[49694],
|
|
||||||
[49806],
|
|
||||||
[49824],
|
|
||||||
[50001],
|
|
||||||
[50256],
|
|
||||||
[0],
|
|
||||||
[1],
|
|
||||||
]
|
|
||||||
|
|
||||||
const clioBadWordsId = [
|
|
||||||
[3],
|
|
||||||
[49356],
|
|
||||||
[1431],
|
|
||||||
[31715],
|
|
||||||
[34387],
|
|
||||||
[20765],
|
|
||||||
[30702],
|
|
||||||
[10691],
|
|
||||||
[49333],
|
|
||||||
[1266],
|
|
||||||
[19438],
|
|
||||||
[43145],
|
|
||||||
[26523],
|
|
||||||
[41471],
|
|
||||||
[2936],
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
badWordIds,
|
|
||||||
clioBadWordsId,
|
|
||||||
};
|
|
75
src/novelai.js
Normal file
75
src/novelai.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
// Ban bracket generation, plus defaults
|
||||||
|
const euterpeBadWordsList = [
|
||||||
|
[8162], [17202], [8162], [17202], [8162], [17202], [8162], [17202], [8162], [17202], [46256, 224], [2343, 223, 224],
|
||||||
|
[46256, 224], [2343, 223, 224], [46256, 224], [2343, 223, 224], [46256, 224], [2343, 223, 224], [46256, 224],
|
||||||
|
[2343, 223, 224], [58], [60], [90], [92], [685], [1391], [1782], [2361], [3693], [4083], [4357], [4895], [5512],
|
||||||
|
[5974], [7131], [8183], [8351], [8762], [8964], [8973], [9063], [11208], [11709], [11907], [11919], [12878], [12962],
|
||||||
|
[13018], [13412], [14631], [14692], [14980], [15090], [15437], [16151], [16410], [16589], [17241], [17414], [17635],
|
||||||
|
[17816], [17912], [18083], [18161], [18477], [19629], [19779], [19953], [20520], [20598], [20662], [20740], [21476],
|
||||||
|
[21737], [22133], [22241], [22345], [22935], [23330], [23785], [23834], [23884], [25295], [25597], [25719], [25787],
|
||||||
|
[25915], [26076], [26358], [26398], [26894], [26933], [27007], [27422], [28013], [29164], [29225], [29342], [29565],
|
||||||
|
[29795], [30072], [30109], [30138], [30866], [31161], [31478], [32092], [32239], [32509], [33116], [33250], [33761],
|
||||||
|
[34171], [34758], [34949], [35944], [36338], [36463], [36563], [36786], [36796], [36937], [37250], [37913], [37981],
|
||||||
|
[38165], [38362], [38381], [38430], [38892], [39850], [39893], [41832], [41888], [42535], [42669], [42785], [42924],
|
||||||
|
[43839], [44438], [44587], [44926], [45144], [45297], [46110], [46570], [46581], [46956], [47175], [47182], [47527],
|
||||||
|
[47715], [48600], [48683], [48688], [48874], [48999], [49074], [49082], [49146], [49946], [10221], [4841], [1427],
|
||||||
|
[2602, 834], [29343], [37405], [35780], [2602], [50256],
|
||||||
|
]
|
||||||
|
|
||||||
|
// Ban bracket generation, plus defaults
|
||||||
|
const krakeBadWordsList = [
|
||||||
|
[9264], [14244], [9264], [14244], [9264], [14244], [9264], [14244], [9264], [14244], [25086, 213], [27344, 213],
|
||||||
|
[25086, 213], [27344, 213], [25086, 213], [27344, 213], [25086, 213], [27344, 213], [25086, 213], [27344, 213], [60],
|
||||||
|
[62], [544], [683], [696], [880], [905], [1008], [1019], [1084], [1092], [1181], [1184], [1254], [1447], [1570], [1656],
|
||||||
|
[2194], [2470], [2479], [2498], [2947], [3138], [3291], [3455], [3725], [3851], [3891], [3921], [3951], [4207], [4299],
|
||||||
|
[4622], [4681], [5013], [5032], [5180], [5218], [5290], [5413], [5456], [5709], [5749], [5774], [6038], [6257], [6334],
|
||||||
|
[6660], [6904], [7082], [7086], [7254], [7444], [7748], [8001], [8088], [8168], [8562], [8605], [8795], [8850], [9014],
|
||||||
|
[9102], [9259], [9318], [9336], [9502], [9686], [9793], [9855], [9899], [9955], [10148], [10174], [10943], [11326],
|
||||||
|
[11337], [11661], [12004], [12084], [12159], [12520], [12977], [13380], [13488], [13663], [13811], [13976], [14412],
|
||||||
|
[14598], [14767], [15640], [15707], [15775], [15830], [16079], [16354], [16369], [16445], [16595], [16614], [16731],
|
||||||
|
[16943], [17278], [17281], [17548], [17555], [17981], [18022], [18095], [18297], [18413], [18736], [18772], [18990],
|
||||||
|
[19181], [20095], [20197], [20481], [20629], [20871], [20879], [20924], [20977], [21375], [21382], [21391], [21687],
|
||||||
|
[21810], [21828], [21938], [22367], [22372], [22734], [23405], [23505], [23734], [23741], [23781], [24237], [24254],
|
||||||
|
[24345], [24430], [25416], [25896], [26119], [26635], [26842], [26991], [26997], [27075], [27114], [27468], [27501],
|
||||||
|
[27618], [27655], [27720], [27829], [28052], [28118], [28231], [28532], [28571], [28591], [28653], [29013], [29547],
|
||||||
|
[29650], [29925], [30522], [30537], [30996], [31011], [31053], [31096], [31148], [31258], [31350], [31379], [31422],
|
||||||
|
[31789], [31830], [32214], [32666], [32871], [33094], [33376], [33440], [33805], [34368], [34398], [34417], [34418],
|
||||||
|
[34419], [34476], [34494], [34607], [34758], [34761], [34904], [34993], [35117], [35138], [35237], [35487], [35830],
|
||||||
|
[35869], [36033], [36134], [36320], [36399], [36487], [36586], [36676], [36692], [36786], [37077], [37594], [37596],
|
||||||
|
[37786], [37982], [38475], [38791], [39083], [39258], [39487], [39822], [40116], [40125], [41000], [41018], [41256],
|
||||||
|
[41305], [41361], [41447], [41449], [41512], [41604], [42041], [42274], [42368], [42696], [42767], [42804], [42854],
|
||||||
|
[42944], [42989], [43134], [43144], [43189], [43521], [43782], [44082], [44162], [44270], [44308], [44479], [44524],
|
||||||
|
[44965], [45114], [45301], [45382], [45443], [45472], [45488], [45507], [45564], [45662], [46265], [46267], [46275],
|
||||||
|
[46295], [46462], [46468], [46576], [46694], [47093], [47384], [47389], [47446], [47552], [47686], [47744], [47916],
|
||||||
|
[48064], [48167], [48392], [48471], [48664], [48701], [49021], [49193], [49236], [49550], [49694], [49806], [49824],
|
||||||
|
[50001], [50256], [0], [1]
|
||||||
|
]
|
||||||
|
|
||||||
|
// Ban bracket generation, plus defaults
|
||||||
|
const badWordsList = [
|
||||||
|
[23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [21], [49209, 21],
|
||||||
|
[21], [49209, 21], [21], [49209, 21], [21], [49209, 21], [21], [49209, 21], [3], [49356], [1431], [31715], [34387],
|
||||||
|
[20765], [30702], [10691], [49333], [1266], [26523], [41471], [2936], [85, 85], [49332], [7286], [1115]
|
||||||
|
]
|
||||||
|
|
||||||
|
// Used for phrase repetition penalty
|
||||||
|
const repPenaltyAllowList = [
|
||||||
|
[49256, 49264, 49231, 49230, 49287, 85, 49255, 49399, 49262, 336, 333, 432, 363, 468, 492, 745, 401, 426, 623, 794,
|
||||||
|
1096, 2919, 2072, 7379, 1259, 2110, 620, 526, 487, 16562, 603, 805, 761, 2681, 942, 8917, 653, 3513, 506, 5301,
|
||||||
|
562, 5010, 614, 10942, 539, 2976, 462, 5189, 567, 2032, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 588,
|
||||||
|
803, 1040, 49209, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
||||||
|
]
|
||||||
|
|
||||||
|
// Ban the dinkus and asterism
|
||||||
|
const logitBiasExp = [
|
||||||
|
{ "sequence": [23], "bias": -0.08, "ensure_sequence_finish": false, "generate_once": false },
|
||||||
|
{ "sequence": [21], "bias": -0.08, "ensure_sequence_finish": false, "generate_once": false }
|
||||||
|
]
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
euterpeBadWordsList,
|
||||||
|
krakeBadWordsList,
|
||||||
|
badWordsList,
|
||||||
|
repPenaltyAllowList,
|
||||||
|
logitBiasExp
|
||||||
|
};
|
Reference in New Issue
Block a user