Merge branch 'staging' into persona-improvements

This commit is contained in:
Wolfsblvt 2025-02-22 19:23:59 +01:00
commit 8bd4fd76ae
150 changed files with 5337 additions and 2596 deletions

View File

@ -80,6 +80,8 @@ body:
required: true
- label: I have checked the [docs](https://docs.sillytavern.app/) ![important](https://img.shields.io/badge/Important!-F6094E)
required: true
- label: I confirm that my issue is not related to third-party content, unofficial extension or patch. If in doubt, check with a new [user account](https://docs.sillytavern.app/administration/multi-user/) and with extensions disabled
required: true
- type: markdown
attributes:

View File

@ -0,0 +1,13 @@
These are master copies of the default content files and are managed by SillyTavern.
Editing any of these files would not only have no effect, but will also cause merge conflicts during update pulls.
You should edit their respective copies instead, for example:
1. /default/config.yaml => /config.yaml
2. /default/public/css/user.css => /public/css/user.css
etc.
Any questions? You're always welcome at our official documentation website:
https://docs.sillytavern.app/

View File

@ -6,7 +6,13 @@ cardsCacheCapacity: 100
# -- SERVER CONFIGURATION --
# Listen for incoming connections
listen: false
# Listen on a specific address, supports IPv4 and IPv6
listenAddress:
ipv4: 0.0.0.0
ipv6: '[::]'
# Enables IPv6 and/or IPv4 protocols. Need to have at least one enabled!
# - Use option "auto" to automatically detect support
# - Use true or false (no qoutes) to enable or disable each protocol
protocol:
ipv4: true
ipv6: false
@ -77,6 +83,18 @@ cookieSecret: ''
disableCsrfProtection: false
# Disable startup security checks - NOT RECOMMENDED
securityOverride: false
# -- LOGGING CONFIGURATION --
logging:
# Enable access logging to access.log file
# Records new connections with timestamp, IP address and user agent
enableAccessLog: true
# Minimum log level to display in the terminal (DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3)
minLogLevel: 0
# -- RATE LIMITING CONFIGURATION --
rateLimiting:
# Use X-Real-IP header instead of socket IP for rate limiting
# Only enable this if you are using a properly configured reverse proxy (like Nginx/traefik/Caddy)
preferRealIpHeader: false
# -- ADVANCED CONFIGURATION --
# Open the browser automatically
autorun: true
@ -179,6 +197,10 @@ ollama:
# * 0: Unload the model immediately after the request
# * N (any positive number): Keep the model loaded for N seconds after the request.
keepAlive: -1
# Controls the "num_batch" (batch size) parameter of the generation request
# * -1: Use the default value of the model
# * N (positive number): Use the specified value. Must be a power of 2, e.g. 128, 256, 512, etc.
batchSize: -1
# -- ANTHROPIC CLAUDE API CONFIGURATION --
claude:
# Enables caching of the system prompt (if supported).
@ -198,3 +220,5 @@ claude:
cachingAtDepth: -1
# -- SERVER PLUGIN CONFIGURATION --
enableServerPlugins: false
# Attempt to automatically update server plugins on startup
enableServerPluginsAutoUpdate: true

View File

@ -671,10 +671,6 @@
"filename": "presets/moving-ui/Default.json",
"type": "moving_ui"
},
{
"filename": "presets/moving-ui/Black Magic Time.json",
"type": "moving_ui"
},
{
"filename": "presets/quick-replies/Default.json",
"type": "quick_replies"

View File

@ -1,45 +0,0 @@
{
"name": "Black Magic Time",
"movingUIState": {
"sheld": {
"top": 488,
"left": 1407,
"right": 1,
"bottom": 4,
"margin": "unset",
"width": 471,
"height": 439
},
"floatingPrompt": {
"width": 369,
"height": 441
},
"right-nav-panel": {
"top": 0,
"left": 1400,
"right": 111,
"bottom": 446,
"margin": "unset",
"width": 479,
"height": 487
},
"WorldInfo": {
"top": 41,
"left": 369,
"right": 642,
"bottom": 51,
"margin": "unset",
"width": 1034,
"height": 858
},
"left-nav-panel": {
"top": 442,
"left": 0,
"right": 1546,
"bottom": 25,
"margin": "unset",
"width": 368,
"height": 483
}
}
}

View File

@ -1,4 +1,4 @@
import getWebpackServeMiddleware from '../src/middleware/webpack-serve.js';
const middleware = getWebpackServeMiddleware();
await middleware.runWebpackCompiler();
await middleware.runWebpackCompiler({ forceDist: true });

76
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "sillytavern",
"version": "1.12.11",
"version": "1.12.12",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sillytavern",
"version": "1.12.11",
"version": "1.12.12",
"hasInstallScript": true,
"license": "AGPL-3.0",
"dependencies": {
@ -28,7 +28,7 @@
"cors": "^2.8.5",
"csrf-sync": "^4.0.3",
"diff-match-patch": "^1.0.5",
"dompurify": "^3.1.7",
"dompurify": "^3.2.4",
"droll": "^0.2.1",
"express": "^4.21.0",
"form-data": "^4.0.0",
@ -41,7 +41,9 @@
"html-entities": "^2.5.2",
"iconv-lite": "^0.6.3",
"ip-matching": "^2.1.2",
"ip-regex": "^5.0.0",
"ipaddr.js": "^2.0.1",
"is-docker": "^3.0.0",
"jimp": "^0.22.10",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
@ -1462,6 +1464,13 @@
"@types/jquery": "*"
}
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"license": "MIT",
"optional": true
},
"node_modules/@types/write-file-atomic": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/write-file-atomic/-/write-file-atomic-4.0.3.tgz",
@ -3217,10 +3226,13 @@
}
},
"node_modules/dompurify": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.7.tgz",
"integrity": "sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==",
"license": "(MPL-2.0 OR Apache-2.0)"
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.4.tgz",
"integrity": "sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==",
"license": "(MPL-2.0 OR Apache-2.0)",
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
}
},
"node_modules/domutils": {
"version": "3.1.0",
@ -4610,6 +4622,18 @@
"integrity": "sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg==",
"license": "LGPL-3.0-only"
},
"node_modules/ip-regex": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",
"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/ipaddr.js": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.1.0.tgz",
@ -4626,15 +4650,15 @@
"license": "MIT"
},
"node_modules/is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
"integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
"license": "MIT",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": ">=8"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
@ -4711,6 +4735,21 @@
"node": ">=8"
}
},
"node_modules/is-wsl/node_modules/is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"license": "MIT",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@ -5495,6 +5534,21 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/open/node_modules/is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"license": "MIT",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/openai": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/openai/-/openai-4.17.4.tgz",

View File

@ -18,7 +18,7 @@
"cors": "^2.8.5",
"csrf-sync": "^4.0.3",
"diff-match-patch": "^1.0.5",
"dompurify": "^3.1.7",
"dompurify": "^3.2.4",
"droll": "^0.2.1",
"express": "^4.21.0",
"form-data": "^4.0.0",
@ -31,7 +31,9 @@
"html-entities": "^2.5.2",
"iconv-lite": "^0.6.3",
"ip-matching": "^2.1.2",
"ip-regex": "^5.0.0",
"ipaddr.js": "^2.0.1",
"is-docker": "^3.0.0",
"jimp": "^0.22.10",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
@ -86,9 +88,10 @@
"type": "git",
"url": "https://github.com/SillyTavern/SillyTavern.git"
},
"version": "1.12.11",
"version": "1.12.12",
"scripts": {
"start": "node server.js",
"debug": "node server.js --inspect",
"start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js",
"start:bun": "bun server.js",
"start:no-csrf": "node server.js --disableCsrf",

View File

@ -8,7 +8,7 @@ import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { default as git } from 'simple-git';
import { default as git, CheckRepoActions } from 'simple-git';
import { color } from './src/util.js';
const __dirname = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
@ -48,6 +48,13 @@ async function updatePlugins() {
console.log(`Updating plugin ${color.green(directory)}...`);
const pluginPath = path.join(pluginsPath, directory);
const pluginRepo = git(pluginPath);
const isRepo = await pluginRepo.checkIsRepo(CheckRepoActions.IS_REPO_ROOT);
if (!isRepo) {
console.log(`Directory ${color.yellow(directory)} is not a Git repository`);
continue;
}
await pluginRepo.fetch();
const commitHash = await pluginRepo.revparse(['HEAD']);
const trackingBranch = await pluginRepo.revparse(['--abbrev-ref', '@{u}']);

View File

@ -104,6 +104,11 @@ const keyMigrationMap = [
newKey: 'extensions.models.textToSpeech',
migrate: (value) => value,
},
{
oldKey: 'minLogLevel',
newKey: 'logging.minLogLevel',
migrate: (value) => value,
},
];
/**

View File

@ -216,8 +216,6 @@
}
#showRawPrompt,
#copyPromptToClipboard,
#groupCurrentMemberPopoutButton,
#summaryExtensionPopoutButton {
display: none;

View File

@ -72,6 +72,10 @@ dialog {
overflow-x: auto;
}
.popup.left_aligned_dialogue_popup .popup-content {
text-align: start;
}
/* Opening animation */
.popup[opening] {
animation: pop-in var(--popup-animation-speed) ease-in-out;

View File

@ -100,6 +100,13 @@
border: 1px solid var(--SmartThemeBorderColor);
}
.select2-container .select2-results .select2-results__option--disabled {
color: inherit;
background-color: inherit;
cursor: not-allowed;
filter: brightness(0.5);
}
.select2-container .select2-selection--multiple .select2-selection__choice,
.select2-container .select2-selection--single .select2-selection__choice {
border-radius: 5px;

View File

@ -473,6 +473,11 @@ label[for="trim_spaces"]:has(input:checked) i.warning {
display: none;
}
label[for="trim_spaces"]:not(:has(input:checked)) small {
color: var(--warning);
opacity: 1;
}
#claude_function_prefill_warning {
display: none;
color: red;
@ -489,3 +494,7 @@ label[for="trim_spaces"]:has(input:checked) i.warning {
#mistralai_other_models:empty {
display: none;
}
#banned_tokens_block_ooba:not(:has(#send_banned_tokens_textgenerationwebui:checked)) #banned_tokens_controls_ooba {
filter: brightness(0.5);
}

8
public/global.d.ts vendored
View File

@ -40,4 +40,12 @@ declare global {
searchInputCssClass?: string;
}
}
/**
* Translates a text to a target language using a translation provider.
* @param text Text to translate
* @param lang Target language
* @param provider Translation provider
*/
async function translate(text: string, lang: string, provider: string = null): Promise<string>;
}

View File

@ -730,7 +730,7 @@
<input type="range" id="top_k_openai" name="volume" min="0" max="500" step="1">
</div>
<div class="range-block-counter">
<input type="number" min="0" max="200" step="1" data-for="top_k_openai" id="top_k_counter_openai">
<input type="number" min="0" max="500" step="1" data-for="top_k_openai" id="top_k_counter_openai">
</div>
</div>
</div>
@ -1587,6 +1587,10 @@
<input type="checkbox" id="skip_special_tokens_textgenerationwebui" />
<small data-i18n="Skip Special Tokens">Skip Special Tokens</small>
</label>
<label data-tg-type="openrouter" class="checkbox_label flexGrow flexShrink" for="include_reasoning_textgenerationwebui">
<input type="checkbox" id="include_reasoning_textgenerationwebui" />
<small data-i18n="Request Model Reasoning">Request Model Reasoning</small>
</label>
<label data-tg-type="ooba, aphrodite, tabby" class="checkbox_label flexGrow flexShrink" for="temperature_last_textgenerationwebui">
<input type="checkbox" id="temperature_last_textgenerationwebui" />
<label>
@ -1617,17 +1621,34 @@
</div>
<div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
<hr class="width100p">
<h4 class="range-block-title justifyCenter">
<span data-i18n="Banned Tokens">Banned Tokens/Strings</span>
<div class="range-block-title title_restorable">
<div>
<strong data-i18n="Banned Tokens">Banned Tokens/Strings</strong>
<div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output.&#13;Unquoted text will be tokenized in the back end and banned as tokens.&#13;[token ids] will be banned as-is.&#13;Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure.&#13;Enclose text in double quotes to ban the entire string as a set.&#13;Quoted Strings and [Token ids] must be on their own line."></div>
</h4>
</div>
<label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
<input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
</label>
</div>
<div id="banned_tokens_controls_ooba">
<div class="textAlignCenter">
<small data-i18n="Global list">Global list</small>
</div>
<div class="wide100p marginBot10">
<textarea id="global_banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="global_banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens&#10;[420, 69, 1337]&#10;"Some verbatim string"'></textarea>
</div>
<div class="textAlignCenter">
<small data-i18n="Preset-specific list">Preset-specific list</small>
</div>
<div class="wide100p">
<textarea id="banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens&#10;[420, 69, 1337]&#10;"Some verbatim string"'></textarea>
</div>
</div>
</div>
<div class="range-block wide100p">
<div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
<span data-i18n="Logit Bias">Logit Bias</span>
<strong data-i18n="Logit Bias">Logit Bias</strong>
<div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">
<i class="fa-xs fa-solid fa-plus"></i>
<small data-i18n="Add">Add</small>
@ -1930,7 +1951,7 @@
</span>
</div>
</div>
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq">
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq,deepseek">
<label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand">
<input id="openai_function_calling" type="checkbox" />
<span data-i18n="Enable function calling">Enable function calling</span>
@ -1953,6 +1974,7 @@
<span data-i18n="image_inlining_hint_3">menu to attach an image file to the chat.</span>
</div>
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
<div class="flex-container oneline-dropdown">
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
Inline Image Quality
</label>
@ -1963,6 +1985,7 @@
</select>
</div>
</div>
</div>
<div class="range-block" data-source="makersuite">
<label for="use_makersuite_sysprompt" class="checkbox_label widthFreeExpand">
<input id="use_makersuite_sysprompt" type="checkbox" />
@ -1977,20 +2000,32 @@
</span>
</div>
</div>
<div class="range-block" data-source="makersuite,deepseek,openrouter">
<div class="range-block" data-source="deepseek,openrouter,custom">
<label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
<input id="openai_show_thoughts" type="checkbox" />
<span>
<span data-i18n="Show model reasoning">Show model reasoning</span>
<i class="opacity50p fa-solid fa-circle-info" title="Gemini 2.0 Thinking / DeepSeek Reasoner"></i>
<span data-i18n="Request model reasoning">Request model reasoning</span>
<i class="opacity50p fa-solid fa-circle-info" title="DeepSeek Reasoner"></i>
</span>
</label>
<div class="toggle-description justifyLeft marginBot5">
<span data-i18n="Display the model's internal thoughts in the response.">
Display the model's internal thoughts in the response.
<span data-i18n="Allows the model to return its thinking process.">
Allows the model to return its thinking process.
</span>
</div>
</div>
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models.&#10;Currently supported values are low, medium, and high.&#10;Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response." data-i18n="[title]Constrains effort on reasoning for reasoning models.">
<label for="openai_reasoning_effort" data-i18n="Reasoning Effort">
Reasoning Effort
</label>
<select id="openai_reasoning_effort">
<option data-i18n="openai_reasoning_effort_low" value="low">Low</option>
<option data-i18n="openai_reasoning_effort_medium" value="medium">Medium</option>
<option data-i18n="openai_reasoning_effort_high" value="high">High</option>
</select>
</div>
</div>
<div class="range-block" data-source="claude">
<div class="wide100p">
<div class="flex-container alignItemsCenter">
@ -2805,27 +2840,6 @@
<div>
<h4 data-i18n="OpenAI Model">OpenAI Model</h4>
<select id="model_openai_select">
<optgroup label="GPT-3.5 Turbo">
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
<option value="gpt-3.5-turbo-0613">gpt-3.5-turbo-0613 (2023)</option>
<option value="gpt-3.5-turbo-0301">gpt-3.5-turbo-0301 (2023)</option>
<option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option>
<option value="gpt-3.5-turbo-16k-0613">gpt-3.5-turbo-16k-0613 (2023)</option>
</optgroup>
<optgroup label="GPT-3.5 Turbo Instruct">
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
<option value="gpt-3.5-turbo-instruct-0914">gpt-3.5-turbo-instruct-0914</option>
</optgroup>
<optgroup label="GPT-4">
<option value="gpt-4">gpt-4</option>
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
<option value="gpt-4-32k">gpt-4-32k</option>
<option value="gpt-4-32k-0613">gpt-4-32k-0613 (2023)</option>
<option value="gpt-4-32k-0314">gpt-4-32k-0314 (2023)</option>
</optgroup>
<optgroup label="GPT-4o">
<option value="gpt-4o">gpt-4o</option>
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
@ -2833,29 +2847,44 @@
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
</optgroup>
<optgroup label="gpt-4o-mini">
<optgroup label="GPT-4o mini">
<option value="gpt-4o-mini">gpt-4o-mini</option>
<option value="gpt-4o-mini-2024-07-18">gpt-4o-mini-2024-07-18</option>
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
<option value="gpt-4o-2024-08-06">gpt-4o-2024-08-06</option>
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
</optgroup>
<optgroup label="GPT-4 Turbo">
<optgroup label="o1 and o1-mini">
<option value="o1">o1</option>
<option value="o1-2024-12-17">o1-2024-12-17</option>
<option value="o1-mini">o1-mini</option>
<option value="o1-mini-2024-09-12">o1-mini-2024-09-12</option>
<option value="o1-preview">o1-preview</option>
<option value="o1-preview-2024-09-12">o1-preview-2024-09-12</option>
</optgroup>
<optgroup label="o3">
<option value="o3-mini">o3-mini</option>
<option value="o3-mini-2025-01-31">o3-mini-2025-01-31</option>
</optgroup>
<optgroup label="GPT-4 Turbo and GPT-4">
<option value="gpt-4-turbo">gpt-4-turbo</option>
<option value="gpt-4-turbo-2024-04-09">gpt-4-turbo-2024-04-09</option>
<option value="gpt-4-turbo-preview">gpt-4-turbo-preview</option>
<option value="gpt-4-vision-preview">gpt-4-vision-preview</option>
<option value="gpt-4-0125-preview">gpt-4-0125-preview (2024)</option>
<option value="gpt-4-1106-preview">gpt-4-1106-preview (2023)</option>
<option value="gpt-4">gpt-4</option>
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
</optgroup>
<optgroup label="o1">
<option value="o1-preview">o1-preview</option>
<option value="o1-mini">o1-mini</option>
<optgroup label="GPT-3.5 Turbo">
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
</optgroup>
<optgroup label="Other">
<option value="text-davinci-003">text-davinci-003</option>
<option value="text-davinci-002">text-davinci-002</option>
<option value="text-curie-001">text-curie-001</option>
<option value="text-babbage-001">text-babbage-001</option>
<option value="text-ada-001">text-ada-001</option>
<option value="code-davinci-002">code-davinci-002</option>
<option value="babbage-002">babbage-002</option>
<option value="davinci-002">davinci-002</option>
</optgroup>
<optgroup id="openai_external_category" label="External">
</optgroup>
@ -3054,6 +3083,7 @@
<h4 data-i18n="Google Model">Google Model</h4>
<select id="model_google_select">
<optgroup label="Primary">
<option value="gemini-2.0-flash">Gemini 2.0 Flash</option>
<option value="gemini-1.5-pro">Gemini 1.5 Pro</option>
<option value="gemini-1.5-flash">Gemini 1.5 Flash</option>
<option value="gemini-1.0-pro">Gemini 1.0 Pro (Deprecated)</option>
@ -3062,6 +3092,11 @@
<option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option>
</optgroup>
<optgroup label="Subversions">
<option value="gemini-2.0-pro-exp">Gemini 2.0 Pro Experimental</option>
<option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option>
<option value="gemini-2.0-flash-lite-preview">Gemini 2.0 Flash-Lite Preview</option>
<option value="gemini-2.0-flash-lite-preview-02-05">Gemini 2.0 Flash-Lite Preview 2025-02-05</option>
<option value="gemini-2.0-flash-001">Gemini 2.0 Flash [001]</option>
<option value="gemini-2.0-flash-thinking-exp">Gemini 2.0 Flash Thinking Experimental</option>
<option value="gemini-2.0-flash-thinking-exp-01-21">Gemini 2.0 Flash Thinking Experimental 2025-01-21</option>
<option value="gemini-2.0-flash-thinking-exp-1219">Gemini 2.0 Flash Thinking Experimental 2024-12-19</option>
@ -3151,33 +3186,33 @@
</div>
<h4 data-i18n="Groq Model">Groq Model</h4>
<select id="model_groq_select">
<optgroup label="Llama 3.3">
<option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile</option>
<optgroup label="Alibaba Cloud">
<option value="qwen-2.5-32b">qwen-2.5-32b</option>
<option value="qwen-2.5-coder-32b">qwen-2.5-coder-32b</option>
</optgroup>
<optgroup label="Llama 3.2">
<option value="llama-3.2-1b-preview">llama-3.2-1b-preview</option>
<option value="llama-3.2-3b-preview">llama-3.2-3b-preview</option>
<option value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option>
<option value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option>
<optgroup label="DeepSeek / Alibaba Cloud">
<option value="deepseek-r1-distill-qwen-32b">deepseek-r1-distill-qwen-32b</option>
</optgroup>
<optgroup label="Llama 3.1">
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option>
<option value="llama-3.1-70b-versatile">llama-3.1-70b-versatile</option>
<option value="llama-3.1-405b-reasoning">llama-3.1-405b-reasoning</option>
<optgroup label="DeepSeek / Meta">
<option value="deepseek-r1-distill-llama-70b">deepseek-r1-distill-llama-70b</option>
</optgroup>
<optgroup label="Llama 3">
<option value="llama3-groq-8b-8192-tool-use-preview">llama3-groq-8b-8192-tool-use-preview</option>
<option value="llama3-groq-70b-8192-tool-use-preview">llama3-groq-70b-8192-tool-use-preview</option>
<option value="llama3-8b-8192">llama3-8b-8192</option>
<option value="llama3-70b-8192">llama3-70b-8192</option>
</optgroup>
<optgroup label="Gemma">
<option value="gemma-7b-it">gemma-7b-it</option>
<optgroup label="Google">
<option value="gemma2-9b-it">gemma2-9b-it</option>
</optgroup>
<optgroup label="Other">
<optgroup label="Meta">
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant </option>
<option value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview </option>
<option value="llama-3.2-1b-preview">llama-3.2-1b-preview </option>
<option value="llama-3.2-3b-preview">llama-3.2-3b-preview </option>
<option value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview </option>
<option value="llama-3.3-70b-specdec">llama-3.3-70b-specdec </option>
<option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile </option>
<option value="llama-guard-3-8b">llama-guard-3-8b </option>
<option value="llama3-70b-8192">llama3-70b-8192 </option>
<option value="llama3-8b-8192">llama3-8b-8192 </option>
</optgroup>
<optgroup label="Mistral AI">
<option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option>
<option value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option>
</optgroup>
</select>
</div>
@ -3227,32 +3262,23 @@
<h4 data-i18n="Perplexity Model">Perplexity Model</h4>
<select id="model_perplexity_select">
<optgroup label="Perplexity Sonar Models">
<option value="sonar">sonar</option>
<option value="sonar-pro">sonar-pro</option>
<option value="sonar-reasoning">sonar-reasoning</option>
<option value="sonar-reasoning-pro">sonar-reasoning-pro</option>
</optgroup>
<optgroup label="Offline Models">
<option value="r1-1776">r1-1776</option>
</optgroup>
<optgroup label="Deprecated Models">
<!-- These are scheduled for deprecation after 2/22/2025 -->
<option value="llama-3.1-sonar-small-128k-online">llama-3.1-sonar-small-128k-online</option>
<option value="llama-3.1-sonar-large-128k-online">llama-3.1-sonar-large-128k-online</option>
<option value="llama-3.1-sonar-huge-128k-online">llama-3.1-sonar-huge-128k-online</option>
</optgroup>
<optgroup label="Perplexity Chat Models">
<!-- These are not listed on the site anymore -->
<option value="llama-3.1-sonar-small-128k-chat">llama-3.1-sonar-small-128k-chat</option>
<option value="llama-3.1-sonar-large-128k-chat">llama-3.1-sonar-large-128k-chat</option>
</optgroup>
<optgroup label="Open-Source Models">
<option value="llama-3.1-8b-instruct">llama-3.1-8b-instruct</option>
<option value="llama-3.1-70b-instruct">llama-3.1-70b-instruct</option>
</optgroup>
<optgroup label="Deprecated Models">
<option value="llama-3-sonar-small-32k-chat">llama-3-sonar-small-32k-chat</option>
<option value="llama-3-sonar-small-32k-online">llama-3-sonar-small-32k-online</option>
<option value="llama-3-sonar-large-32k-chat">llama-3-sonar-large-32k-chat</option>
<option value="llama-3-sonar-large-32k-online">llama-3-sonar-large-32k-online</option>
<option value="sonar-small-chat">sonar-small-chat</option>
<option value="sonar-small-online">sonar-small-online</option>
<option value="sonar-medium-chat">sonar-medium-chat</option>
<option value="sonar-medium-online">sonar-medium-online</option>
<option value="llama-3-8b-instruct">llama-3-8b-instruct</option>
<option value="llama-3-70b-instruct">llama-3-70b-instruct</option>
<option value="mistral-7b-instruct">mistral-7b-instruct (v0.2)</option>
<option value="mixtral-8x7b-instruct">mixtral-8x7b-instruct</option>
</optgroup>
</select>
</div>
<form id="cohere_form" data-source="cohere" action="javascript:void(null);" method="post" enctype="multipart/form-data">
@ -3524,7 +3550,7 @@
</label>
<label id="instruct_enabled_label"for="instruct_enabled" class="checkbox_label flex1" title="Enable Instruct Mode" data-i18n="[title]instruct_enabled">
<input id="instruct_enabled" type="checkbox" style="display:none;" />
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
</label>
</div>
</h4>
@ -3702,7 +3728,7 @@
<div class="flex-container">
<label id="sysprompt_enabled_label" for="sysprompt_enabled" class="checkbox_label flex1" title="Enable System Prompt" data-i18n="[title]sysprompt_enabled">
<input id="sysprompt_enabled" type="checkbox" style="display:none;" />
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
</label>
</div>
</h4>
@ -3756,8 +3782,8 @@
</div>
<label class="checkbox_label" for="custom_stopping_strings_macro">
<input id="custom_stopping_strings_macro" type="checkbox" checked>
<small data-i18n="Replace Macro in Custom Stopping Strings">
Replace Macro in Custom Stopping Strings
<small data-i18n="Replace Macro in Stop Strings">
Replace Macro in Stop Strings
</small>
</label>
</div>
@ -3804,12 +3830,42 @@
<span data-i18n="Reasoning">Reasoning</span>
</h4>
<div>
<label class="checkbox_label" for="reasoning_add_to_prompts" title="Add existing reasoning blocks to prompts. To add a new reasoning block, use the message edit menu." data-i18n="[title]reasoning_add_to_prompts">
<input id="reasoning_add_to_prompts" type="checkbox" />
<small data-i18n="Add Reasoning to Prompts">
Add Reasoning to Prompts
<div class="flex-container alignItemsBaseline">
<label class="checkbox_label flex1" for="reasoning_auto_parse" title="Automatically parse reasoning blocks from main content between the reasoning prefix/suffix. Both fields must be defined and non-empty." data-i18n="[title]reasoning_auto_parse">
<input id="reasoning_auto_parse" type="checkbox" />
<small data-i18n="Auto-Parse">
Auto-Parse
</small>
</label>
<label class="checkbox_label flex1" for="reasoning_auto_expand" title="Automatically expand reasoning blocks." data-i18n="[title]reasoning_auto_expand">
<input id="reasoning_auto_expand" type="checkbox" />
<small data-i18n="Auto-Expand">
Auto-Expand
</small>
</label>
<label class="checkbox_label flex1" for="reasoning_show_hidden" title="Show reasoning time for models with hidden reasoning." data-i18n="[title]reasoning_show_hidden">
<input id="reasoning_show_hidden" type="checkbox" />
<small data-i18n="Show Hidden">
Show Hidden
</small>
</label>
</div>
<div class="flex-container alignItemsBaseline">
<label class="checkbox_label flex1" for="reasoning_add_to_prompts" title="Add existing reasoning blocks to prompts. To add a new reasoning block, use the message edit menu." data-i18n="[title]reasoning_add_to_prompts">
<input id="reasoning_add_to_prompts" type="checkbox" />
<small data-i18n="Add to Prompts">
Add to Prompts
</small>
</label>
<div class="flex1 flex-container alignItemsBaseline" title="Maximum number of reasoning blocks to be added per prompt, counting from the last message." data-i18n="[title]reasoning_max_additions">
<input id="reasoning_max_additions" class="text_pole textarea_compact widthUnset" type="number" min="0" max="999"></textarea>
<small data-i18n="Max">Max</small>
</div>
</div>
<details>
<summary data-i18n="Reasoning Formatting">
Reasoning Formatting
</summary>
<div class="flex-container">
<div class="flex1" title="Inserted before the reasoning content." data-i18n="[title]reasoning_prefix">
<small data-i18n="Prefix">Prefix</small>
@ -3825,11 +3881,8 @@
<small data-i18n="Separator">Separator</small>
<textarea id="reasoning_separator" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flex1" title="Maximum number of reasoning blocks to be added per prompt, counting from the last message." data-i18n="[title]reasoning_max_additions">
<small data-i18n="Max Additions">Max Additions</small>
<input id="reasoning_max_additions" class="text_pole textarea_compact" type="number" min="0" max="999"></textarea>
</div>
</div>
</details>
</div>
</div>
<div>
@ -3964,7 +4017,7 @@
<div class="alignitemscenter flex-container flexFlowColumn flexGrow flexShrink gap0 flexBasis48p" title="Cap the number of entry activation recursions" data-i18n="[title]Cap the number of entry activation recursions">
<small>
<span data-i18n="Max Recursion Steps">Max Recursion Steps</span>
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title]0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\n(disabled when min activations are used)" title="0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc&#10;(disabled when min activations are used)"></div>
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title]0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc" title="0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc&#10;(disabled when min activations are used)"></div>
</small>
<input class="neo-range-slider" type="range" id="world_info_max_recursion_steps" name="world_info_max_recursion_steps" min="0" max="10" step="1">
<input class="neo-range-input" type="number" min="0" max="10" step="1" data-for="world_info_max_recursion_steps" id="world_info_max_recursion_steps_counter">
@ -4629,7 +4682,7 @@
<small data-i18n="Enabled">Enabled</small>
</label>
<small data-i18n="Minimum generated message length">Minimum generated message length</small>
<input id="auto_swipe_minimum_length" name="auto_swipe_minimum_length" type="number" min="0" step="1" value="0" class="text_pole" title="If the generated message is shorter than this, trigger an auto-swipe." data-i18n="[title]If the generated message is shorter than this, trigger an auto-swipe">
<input id="auto_swipe_minimum_length" name="auto_swipe_minimum_length" type="number" min="0" step="1" value="0" class="text_pole" title="If the generated message is shorter than these many characters, trigger an auto-swipe." data-i18n="[title]If the generated message is shorter than these many characters, trigger an auto-swipe">
<small data-i18n="Blacklisted words">Blacklisted words</small>
<div class="auto_swipe">
<textarea id="auto_swipe_blacklist" name="auto_swipe_blacklist" data-i18n="[placeholder]words you dont want generated separated by comma ','" placeholder="words you don't want generated separated by comma ','" class="text_pole textarea_compact" value="" autocomplete="off" rows="3"></textarea>
@ -4845,6 +4898,7 @@
</div>
<div id="extensions_settings" class="flex1 wide50p">
<div id="assets_container" class="extension_container"></div>
<div id="typing_indicator_container" class="extension_container"></div>
<div id="expressions_container" class="extension_container"></div>
<div id="sd_container" class="extension_container"></div>
<div id="tts_container" class="extension_container"></div>
@ -5880,7 +5934,7 @@
<div class="inline-drawer-content flex-container paddingBottom5px wide100p">
<div class="flex-container wide100p alignitemscenter">
<div name="keywordsAndLogicBlock" class="flex-container wide100p alignitemscenter">
<div class="world_entry_form_control flex1">
<div class="world_entry_form_control keyprimary flex1">
<small class="displayNone">
<span data-i18n="Comma separated (required)">
Comma separated (required)
@ -6302,14 +6356,19 @@
</div>
</div>
<details class="mes_reasoning_details">
<summary class="mes_reasoning_summary">
<span data-i18n="Reasoning">Reasoning</span>
<div class="mes_reasoning_actions">
<div class="mes_reasoning_edit_done mes_button fa-solid fa-check" title="Confirm" data-i18n="[title]Confirmedit"></div>
<div class="mes_reasoning_edit_cancel mes_button fa-solid fa-xmark" title="Cancel edit" data-i18n="[title]Cancel edit"></div>
<div class="mes_reasoning_edit mes_button fa-solid fa-pencil" title="Edit reasoning" data-i18n="[title]Edit reasoning"></div>
<summary class="mes_reasoning_summary flex-container">
<div class="mes_reasoning_header_block flex-container">
<div class="mes_reasoning_header flex-container">
<span class="mes_reasoning_header_title" data-i18n="Thought for some time">Thought for some time</span>
<div class="mes_reasoning_arrow fa-solid fa-chevron-up"></div>
</div>
</div>
<div class="mes_reasoning_actions flex-container">
<div class="mes_reasoning_edit_done menu_button edit_button fa-solid fa-check" title="Confirm" data-i18n="[title]Confirmedit"></div>
<div class="mes_reasoning_delete menu_button edit_button fa-solid fa-trash-can" title="Remove reasoning" data-i18n="[title]Remove reasoning"></div>
<div class="mes_reasoning_edit_cancel menu_button edit_button fa-solid fa-xmark" title="Cancel edit" data-i18n="[title]Cancel edit"></div>
<div class="mes_reasoning_copy mes_button fa-solid fa-copy" title="Copy reasoning" data-i18n="[title]Copy reasoning"></div>
<div class="mes_reasoning_delete mes_button fa-solid fa-trash-can" title="Remove reasoning" data-i18n="[title]Remove reasoning"></div>
<div class="mes_reasoning_edit mes_button fa-solid fa-pencil" title="Edit reasoning" data-i18n="[title]Edit reasoning"></div>
</div>
</summary>
<div class="mes_reasoning"></div>
@ -6528,9 +6587,6 @@
</div>
<!-- chat and input bar -->
<div id="typing_indicator_template" class="template_element">
<div class="typing_indicator"><span class="typing_indicator_name">CHAR</span> is typing</div>
</div>
<div id="message_file_template" class="template_element">
<div class="mes_file_container">
<div class="fa-lg fa-solid fa-file-alt mes_file_icon"></div>
@ -6890,8 +6946,8 @@
</div>
<div id="form_sheld">
<div id="dialogue_del_mes">
<div id="dialogue_del_mes_ok" class="menu_button">Delete</div>
<div id="dialogue_del_mes_cancel" class="menu_button">Cancel</div>
<div id="dialogue_del_mes_ok" data-i18n="Delete" class="menu_button">Delete</div>
<div id="dialogue_del_mes_cancel" data-i18n="Cancel" class="menu_button">Cancel</div>
</div>
<div id="send_form" class="no-connection">
<form id="file_form" class="wide100p displayNone">

View File

@ -24,10 +24,22 @@ if (typeof Array.prototype.indexOf === 'function') {
/* Polyfill EventEmitter. */
var EventEmitter = function () {
/**
* Creates an event emitter.
* @param {string[]} autoFireAfterEmit Auto-fire event names
*/
var EventEmitter = function (autoFireAfterEmit = []) {
this.events = {};
this.autoFireLastArgs = new Map();
this.autoFireAfterEmit = new Set(autoFireAfterEmit);
};
/**
* Adds a listener to an event.
* @param {string} event Event name
* @param {function} listener Event listener
* @returns
*/
EventEmitter.prototype.on = function (event, listener) {
// Unknown event used by external libraries?
if (event === undefined) {
@ -40,6 +52,10 @@ EventEmitter.prototype.on = function (event, listener) {
}
this.events[event].push(listener);
if (this.autoFireAfterEmit.has(event) && this.autoFireLastArgs.has(event)) {
listener.apply(this, this.autoFireLastArgs.get(event));
}
};
/**
@ -60,6 +76,10 @@ EventEmitter.prototype.makeLast = function (event, listener) {
}
events.push(listener);
if (this.autoFireAfterEmit.has(event) && this.autoFireLastArgs.has(event)) {
listener.apply(this, this.autoFireLastArgs.get(event));
}
}
/**
@ -80,8 +100,17 @@ EventEmitter.prototype.makeFirst = function (event, listener) {
}
events.unshift(listener);
if (this.autoFireAfterEmit.has(event) && this.autoFireLastArgs.has(event)) {
listener.apply(this, this.autoFireLastArgs.get(event));
}
}
/**
* Removes a listener from an event.
* @param {string} event Event name
* @param {function} listener Event listener
*/
EventEmitter.prototype.removeListener = function (event, listener) {
var idx;
@ -94,6 +123,10 @@ EventEmitter.prototype.removeListener = function (event, listener) {
}
};
/**
* Emits an event with optional arguments.
* @param {string} event Event name
*/
EventEmitter.prototype.emit = async function (event) {
let args = [].slice.call(arguments, 1);
if (localStorage.getItem('eventTracing') === 'true') {
@ -118,6 +151,10 @@ EventEmitter.prototype.emit = async function (event) {
}
}
}
if (this.autoFireAfterEmit.has(event)) {
this.autoFireLastArgs.set(event, args);
}
};
EventEmitter.prototype.emitAndWait = function (event) {
@ -144,6 +181,10 @@ EventEmitter.prototype.emitAndWait = function (event) {
}
}
}
if (this.autoFireAfterEmit.has(event)) {
this.autoFireLastArgs.set(event, args);
}
};
EventEmitter.prototype.once = function (event, listener) {

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "فصل بفواصل دون مسافة بينها",
"Custom Stopping Strings": "سلاسل توقف مخصصة",
"JSON serialized array of strings": "مصفوفة سلسلة JSON متسلسلة",
"Replace Macro in Custom Stopping Strings": "استبدال الماكرو في سلاسل التوقف المخصصة",
"Replace Macro in Stop Strings": "استبدال الماكرو في سلاسل التوقف المخصصة",
"Auto-Continue": "المتابعة التلقائية",
"Allow for Chat Completion APIs": "السماح بواجهات برمجة التطبيقات لإكمال الدردشة",
"Target length (tokens)": "الطول المستهدف (رموز)",
@ -709,7 +709,7 @@
"Auto-swipe": "السحب التلقائي",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "تمكين وظيفة السحب التلقائي. الإعدادات في هذا القسم تؤثر فقط عند تمكين السحب التلقائي",
"Minimum generated message length": "الحد الأدنى لطول الرسالة المولدة",
"If the generated message is shorter than this, trigger an auto-swipe": "إذا كانت الرسالة المولدة أقصر من هذا، فتحريض السحب التلقائي",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "إذا كانت الرسالة المولدة أقصر من هذا، فتحريض السحب التلقائي",
"Blacklisted words": "الكلمات الممنوعة",
"words you dont want generated separated by comma ','": "الكلمات التي لا تريد توليدها مفصولة بفاصلة ','",
"Blacklisted word count to swipe": "عدد الكلمات الممنوعة للسحب",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "getrennt durch Kommas ohne Leerzeichen dazwischen",
"Custom Stopping Strings": "Benutzerdefinierte Stoppzeichenfolgen",
"JSON serialized array of strings": "JSON serialisierte Reihe von Zeichenfolgen",
"Replace Macro in Custom Stopping Strings": "Makro in benutzerdefinierten Stoppzeichenfolgen ersetzen",
"Replace Macro in Stop Strings": "Makro in benutzerdefinierten Stoppzeichenfolgen ersetzen",
"Auto-Continue": "Automatisch fortsetzen",
"Allow for Chat Completion APIs": "Erlaube Chat-Vervollständigungs-APIs",
"Target length (tokens)": "Ziel-Länge (Tokens)",
@ -709,7 +709,7 @@
"Auto-swipe": "Automatisches Wischen",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Aktiviere die Auto-Wisch-Funktion. Einstellungen in diesem Abschnitt haben nur dann Auswirkungen, wenn das automatische Wischen aktiviert ist",
"Minimum generated message length": "Minimale generierte Nachrichtenlänge",
"If the generated message is shorter than this, trigger an auto-swipe": "Wenn die generierte Nachricht kürzer ist als diese, löse automatisches Wischen aus",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Wenn die generierte Nachricht kürzer ist als diese, löse automatisches Wischen aus",
"Blacklisted words": "Verbotene Wörter",
"words you dont want generated separated by comma ','": "Wörter, die du nicht generiert haben möchtest, durch Komma ',' getrennt",
"Blacklisted word count to swipe": "Anzahl der verbotenen Wörter, um zu wischen",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "separe con comas sin espacio entre ellas",
"Custom Stopping Strings": "Cadenas de Detención Personalizadas",
"JSON serialized array of strings": "Arreglo de cadenas serializado en JSON",
"Replace Macro in Custom Stopping Strings": "Reemplazar macro en Cadenas de Detención Personalizadas",
"Replace Macro in Stop Strings": "Reemplazar macro en Cadenas de Detención Personalizadas",
"Auto-Continue": "Autocontinuar",
"Allow for Chat Completion APIs": "Permitir para APIs de Completado de Chat",
"Target length (tokens)": "Longitud objetivo (tokens)",
@ -709,7 +709,7 @@
"Auto-swipe": "Deslizamiento automático",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Habilitar la función de deslizamiento automático. La configuración en esta sección solo tiene efecto cuando el deslizamiento automático está habilitado",
"Minimum generated message length": "Longitud mínima del mensaje generado",
"If the generated message is shorter than this, trigger an auto-swipe": "Si el mensaje generado es más corto que esto, activar un deslizamiento automático",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Si el mensaje generado es más corto que esto, activar un deslizamiento automático",
"Blacklisted words": "Palabras prohibidas",
"words you dont want generated separated by comma ','": "palabras que no desea generar separadas por coma ','",
"Blacklisted word count to swipe": "Número de palabras prohibidas para deslizar",

View File

@ -434,7 +434,7 @@
"Non-markdown strings": "Chaînes non Markdown",
"Custom Stopping Strings": "Chaînes d'arrêt personnalisées",
"JSON serialized array of strings": "Tableau de chaînes sérialisé JSON",
"Replace Macro in Custom Stopping Strings": "Remplacer les macro dans les chaînes d'arrêt personnalisées",
"Replace Macro in Stop Strings": "Remplacer les macro dans les chaînes d'arrêt personnalisées",
"Auto-Continue": "Auto-Continue",
"Allow for Chat Completion APIs": "Autoriser les APIs de complétion de chat",
"Target length (tokens)": "Longueur cible (tokens)",
@ -656,7 +656,7 @@
"Auto-swipe": "Balayage automatique",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Activer la fonction de balayage automatique. Les paramètres de cette section n'ont d'effet que lorsque le balayage automatique est activé",
"Minimum generated message length": "Longueur minimale du message généré",
"If the generated message is shorter than this, trigger an auto-swipe": "Si le message généré est plus court que cela, déclenchez un balayage automatique",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Si le message généré est plus court que cela, déclenchez un balayage automatique",
"Blacklisted words": "Mots en liste noire",
"words you dont want generated separated by comma ','": "mots que vous ne voulez pas générer séparés par des virgules ','",
"Blacklisted word count to swipe": "Nombre de mots en liste noire pour balayer",
@ -1385,8 +1385,8 @@
"enable_functions_desc_1": "Autorise l'utilisation",
"enable_functions_desc_2": "outils de fonction",
"enable_functions_desc_3": "Peut être utilisé par diverses extensions pour fournir des fonctionnalités supplémentaires.",
"Show model reasoning": "Afficher les pensées du modèle",
"Display the model's internal thoughts in the response.": "Afficher les pensées internes du modèle dans la réponse.",
"Request model reasoning": "Demander les pensées du modèle",
"Allows the model to return its thinking process.": "Permet au modèle de retourner son processus de réflexion.",
"Confirm token parsing with": "Confirmer l'analyse des tokens avec",
"openai_logit_bias_no_items": "Aucun élément",
"api_no_connection": "Pas de connection...",
@ -1485,7 +1485,7 @@
"(disabled when max recursion steps are used)": "(désactivé lorsque le nombre maximum de pas de récursivité est utilisé)",
"Cap the number of entry activation recursions": "Plafonner le nombre de récursions d'activation d'entrée",
"Max Recursion Steps": "Nombre maximal d'étapes de récursivité",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\\n(disabled when min activations are used)": "0 = illimité, 1 = scanne une fois et ne récure pas, 2 = scanne une fois et récure une fois, etc.\n(désactivé lorsque des activations minimales sont utilisées)",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "0 = illimité, 1 = scanne une fois et ne récure pas, 2 = scanne une fois et récure une fois, etc.\n(désactivé lorsque des activations minimales sont utilisées)",
"Include names with each message into the context for scanning": "Inclure les noms dans chaque message dans le contexte pour l'analyse.",
"Apply current sorting as Order": "Appliquer le tri actuel comme ordre",
"Display swipe numbers for all messages, not just the last.": "Afficher le nombre de balayage sur tous les messages, et pas seulement le dernier.",
@ -1602,7 +1602,6 @@
"Character Expressions": "Expressions de personnages",
"Translate text to English before classification": "Traduire le texte en anglais avant de le classer",
"Show default images (emojis) if sprite missing": "Afficher les images par défaut (emojis) si le sprite est manquant",
"Image Type - talkinghead (extras)": "Type d'image - talkinghead (extras)",
"Classifier API": "API de classification",
"Select the API for classifying expressions.": "Sélectionnez l'API pour classer les expressions.",
"Main API": "API principale",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "aðskilið með kommum án bila milli",
"Custom Stopping Strings": "Eigin stopp-strengir",
"JSON serialized array of strings": "JSON raðað fylki af strengjum",
"Replace Macro in Custom Stopping Strings": "Skiptu út í macro í sérsniðnum stoppa strengjum",
"Replace Macro in Stop Strings": "Skiptu út í macro í sérsniðnum stoppa strengjum",
"Auto-Continue": "Sjálfvirk Forná",
"Allow for Chat Completion APIs": "Leyfa fyrir spjall Loka APIs",
"Target length (tokens)": "Markaðarlengd (texti)",
@ -709,7 +709,7 @@
"Auto-swipe": "Sjálfvirkur sveip",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Virkjaðu sjálfvirka sveiflugerð. Stillingar í þessum hluta hafa aðeins áhrif þegar sjálfvirkur sveiflugerð er virk",
"Minimum generated message length": "Lágmarks lengd á mynduðum skilaboðum",
"If the generated message is shorter than this, trigger an auto-swipe": "Ef mynduðu skilaboðin eru styttri en þessi, kallaðu fram sjálfvirkar sveiflugerðar",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Ef mynduðu skilaboðin eru styttri en þessi, kallaðu fram sjálfvirkar sveiflugerðar",
"Blacklisted words": "Svört orð",
"words you dont want generated separated by comma ','": "orð sem þú vilt ekki að framleiða aðskilin með kommu ','",
"Blacklisted word count to swipe": "Fjöldi svörtra orða til að sveipa",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "separati con virgole senza spazio tra loro",
"Custom Stopping Strings": "Stringhe di Stop Personalizzate",
"JSON serialized array of strings": "Matrice serializzata JSON di stringhe",
"Replace Macro in Custom Stopping Strings": "Sostituisci Macro in Stringhe di Arresto Personalizzate",
"Replace Macro in Stop Strings": "Sostituisci Macro in Stringhe di Arresto Personalizzate",
"Auto-Continue": "Auto-continua",
"Allow for Chat Completion APIs": "Consenti per API di completamento chat",
"Target length (tokens)": "Lunghezza obiettivo (token)",
@ -709,7 +709,7 @@
"Auto-swipe": "Auto-swipe",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Abilita la funzione di auto-swipe. Le impostazioni in questa sezione hanno effetto solo quando l'auto-swipe è abilitato",
"Minimum generated message length": "Lunghezza minima del messaggio generato",
"If the generated message is shorter than this, trigger an auto-swipe": "Se il messaggio generato è più breve di questo, attiva un'automatica rimozione",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Se il messaggio generato è più breve di questo, attiva un'automatica rimozione",
"Blacklisted words": "Parole in blacklist",
"words you dont want generated separated by comma ','": "parole che non vuoi generate separate da virgola ','",
"Blacklisted word count to swipe": "Numero di parole in blacklist per attivare un'automatica rimozione",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "間にスペースのないカンマで区切ります",
"Custom Stopping Strings": "カスタム停止文字列",
"JSON serialized array of strings": "文字列のJSONシリアル化配列",
"Replace Macro in Custom Stopping Strings": "カスタム停止文字列内のマクロを置換する",
"Replace Macro in Stop Strings": "カスタム停止文字列内のマクロを置換する",
"Auto-Continue": "自動継続",
"Allow for Chat Completion APIs": "チャット補完APIを許可",
"Target length (tokens)": "ターゲット長さ(トークン)",
@ -709,7 +709,7 @@
"Auto-swipe": "オートスワイプ",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "自動スワイプ機能を有効にします。このセクションの設定は、自動スワイプが有効になっている場合にのみ効果があります",
"Minimum generated message length": "生成されたメッセージの最小長",
"If the generated message is shorter than this, trigger an auto-swipe": "生成されたメッセージがこれよりも短い場合、自動スワイプをトリガーします",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "生成されたメッセージがこれよりも短い場合、自動スワイプをトリガーします",
"Blacklisted words": "ブラックリストされた単語",
"words you dont want generated separated by comma ','": "コンマ ',' で区切られた生成したくない単語",
"Blacklisted word count to swipe": "スワイプするブラックリストされた単語の数",

View File

@ -211,7 +211,7 @@
"Sampler Priority": "샘플러 우선 순위",
"Ooba only. Determines the order of samplers.": "Ooba 전용. 샘플러의 순서를 결정합니다.",
"Character Names Behavior": "캐릭터 이름 동작",
"[title]character_names_none": "캐릭터 이름 접두사를 추가하지 않습니다. 그룹 채팅에서는 좋지 않을 수 있으므로, 이 설정을 선택할 때는 주의해야 합니다.",
"character_names_none": "캐릭터 이름 접두사를 추가하지 않습니다. 그룹 채팅에서는 좋지 않을 수 있으므로, 이 설정을 선택할 때는 주의해야 합니다.",
"Helps the model to associate messages with characters.": "모델이 메시지를 캐릭터와 연관시키는 데 도움이 됩니다.",
"None": "없음",
"None (not injected)": "없음 (삽입되지 않음)",
@ -404,7 +404,7 @@
"Custom API Key": "커스텀 API 키",
"Available Models": "사용 가능한 모델",
"Prompt Post-Processing": "신속한 후처리",
"[title]API Connections;[no_connection_text]api_no_connection": "연결이 되지 않았습니다...",
"api_no_connection": "연결이 되지 않았습니다...",
"Applies additional processing to the prompt before sending it to the API.": "API로 보내기 전에 프롬프트에 추가 처리를 적용합니다.",
"Verifies your API connection by sending a short test message. Be aware that you'll be credited for it!": "짧은 테스트 메시지를 보내어 API 연결을 확인합니다. 이에 대해 유료 크레딧이 지불될 수 있음을 인식하세요!",
"Test Message": "테스트 메시지",
@ -492,7 +492,7 @@
"separate with commas w/o space between": "쉼표로 구분 (공백 없이)",
"Custom Stopping Strings": "사용자 정의 중지 문자열",
"JSON serialized array of strings": "문자열의 JSON 직렬화된 배열",
"Replace Macro in Custom Stopping Strings": "사용자 정의 중단 문자열에서 매크로 교체",
"Replace Macro in Stop Strings": "사용자 정의 중단 문자열에서 매크로 교체",
"Auto-Continue": "자동 계속하기",
"Allow for Chat Completion APIs": "채팅 완성 API 허용",
"Target length (tokens)": "대상 길이 (토큰)",
@ -625,7 +625,7 @@
"Single-row message input area. Mobile only, no effect on PC": "한 줄짜리 메시지 입력 영역. 모바일 전용, PC에는 영향 없음",
"Compact Input Area (Mobile)": "조그마한 입력 영역 (모바일)",
"Swipe # for All Messages": "모든 스와이프 메시지에 대해 번호 매기기",
"[title]Display swipe numbers for all messages, not just the last.": "마지막 메시지만이 아니라 모든 메시지에 대한 스와이프 번호를 표시합니다.",
"Display swipe numbers for all messages, not just the last.": "마지막 메시지만이 아니라 모든 메시지에 대한 스와이프 번호를 표시합니다.",
"In the Character Management panel, show quick selection buttons for favorited characters": "캐릭터 관리 패널에서 즐겨찾는 캐릭터에 대한 빠른 선택 버튼을 표시합니다",
"Characters Hotswap": "캐릭터 핫스왑",
"Enable magnification for zoomed avatar display.": "마우스 포인터를 아바타 위에 올려두면 아바타가 확대 됩니다.",
@ -724,7 +724,7 @@
"Auto-swipe": "자동 스와이프",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "자동 스와이프 기능을 활성화합니다. 이 섹션의 설정은 자동 스와이프가 활성화되었을 때만 영향을 미칩니다",
"Minimum generated message length": "생성된 메시지 최소 길이",
"If the generated message is shorter than this, trigger an auto-swipe": "생성된 메시지가이보다 짧으면 자동 스와이프를 트리거합니다",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "생성된 메시지가이보다 짧으면 자동 스와이프를 트리거합니다",
"Blacklisted words": "금지어",
"words you dont want generated separated by comma ','": "쉼표로 구분된 생성하지 않으려는 단어",
"Blacklisted word count to swipe": "스와이프할 금지어 개수",
@ -1467,7 +1467,6 @@
"menu within": "내의 메뉴",
"Translate text to English before classification": "분류 전에 텍스트를 영어로 번역합니다.",
"Show default images (emojis) if sprite missing": "해당하는 스프라이트가 없으면 기본 이미지 (이모지들)을 표시합니다.",
"Image Type - talkinghead (extras)": "이미지 유형 - 토킹 헤드 (부가 사항)",
"Classifier API": "분류를 위한 API",
"Select the API for classifying expressions.": "감정 이미지들을 분류할 API를 선택하세요.",
"Local": "로컬",
@ -1538,7 +1537,7 @@
"Only apply color as accent": "색상은 오직 강조로써만 적용됩니다",
"qr--colorClear": "색상 지우기",
"Color": "색상",
"[title]world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift를 클릭하면 '월드 인포 링크' 팝업이 열립니다.",
"world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift를 클릭하면 '월드 인포 링크' 팝업이 열립니다.",
"Select TTS Provider": "TTS 공급자 선택",
"tts_enabled": "활성화",
"Narrate user messages": "사용자 메시지 나레이션",
@ -1583,15 +1582,15 @@
"Prompt Content": "프롬프트 내용",
"Instruct Sequences": "지시 시퀀스",
"Prefer Character Card Instructions": "캐릭터 카드의 지시사항을 선호",
"[title]If checked and the character card contains a Post-History Instructions override, use that instead": "활성화 된 경우, 캐릭터 카드에 Post-History 지시 무시 항목이 포함되어 있으면, 카드 지시사항의 내용으로 대신 사용합니다.",
"If checked and the character card contains a Post-History Instructions override, use that instead": "활성화 된 경우, 캐릭터 카드에 Post-History 지시 무시 항목이 포함되어 있으면, 카드 지시사항의 내용으로 대신 사용합니다.",
"Auto-select Input Text": "입력 텍스트 자동 선택",
"[title]Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields.": "일부 텍스트 필드를 클릭하거나 선택할 때 자동으로 입력된 텍스트가 선택되도록 설정합니다. 팝업 입력창과 기타 커스텀 입력 필드에 적용됩니다.",
"Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields.": "일부 텍스트 필드를 클릭하거나 선택할 때 자동으로 입력된 텍스트가 선택되도록 설정합니다. 팝업 입력창과 기타 커스텀 입력 필드에 적용됩니다.",
"Markdown Hotkeys": "마크다운 입력 단축키",
"[title]markdown_hotkeys_desc": "특정 텍스트 입력창에서 마크다운 형식 문자를 입력하기 위한 단축키를 활성화합니다. '/help hotkeys'를 참고하세요.",
"markdown_hotkeys_desc": "특정 텍스트 입력창에서 마크다운 형식 문자를 입력하기 위한 단축키를 활성화합니다. '/help hotkeys'를 참고하세요.",
"Show group chat queue": "그룹 채팅 대기열 표시",
"[title]In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond.": "그룹 채팅에서 응답을 생성하기 위해 현재 대기 중인 캐릭터와 응답할 순서를 강조 표시합니다.",
"In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond.": "그룹 채팅에서 응답을 생성하기 위해 현재 대기 중인 캐릭터와 응답할 순서를 강조 표시합니다.",
"Quick 'Impersonate' button": "빠른 '사칭' 버튼",
"[title]Show a button in the input area to ask the AI to impersonate your character for a single message": "입력 영역에 AI에게 한 메시지 동안 당신의 캐릭터 연기를 사칭하도록 요청하는 버튼을 표시합니다.",
"Show a button in the input area to ask the AI to impersonate your character for a single message": "입력 영역에 AI에게 한 메시지 동안 당신의 캐릭터 연기를 사칭하도록 요청하는 버튼을 표시합니다.",
"Injection Template": "삽입 템플릿",
"Query messages": "쿼리 메시지 수",
"Score threshold": "점수 임계값",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "gescheiden met komma's zonder spatie ertussen",
"Custom Stopping Strings": "Aangepaste Stopreeksen",
"JSON serialized array of strings": "JSON geserialiseerde reeks van strings",
"Replace Macro in Custom Stopping Strings": "Macro vervangen in aangepaste stopreeksen",
"Replace Macro in Stop Strings": "Macro vervangen in aangepaste stopreeksen",
"Auto-Continue": "Automatisch doorgaan",
"Allow for Chat Completion APIs": "Chatvervolledigings-API's toestaan",
"Target length (tokens)": "Doellengte (tokens)",
@ -709,7 +709,7 @@
"Auto-swipe": "Automatisch vegen",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Schakel de automatische-vegen functie in. Instellingen in dit gedeelte hebben alleen effect wanneer automatisch vegen is ingeschakeld",
"Minimum generated message length": "Minimale gegenereerde berichtlengte",
"If the generated message is shorter than this, trigger an auto-swipe": "Als het gegenereerde bericht korter is dan dit, activeer dan een automatische veeg",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Als het gegenereerde bericht korter is dan dit, activeer dan een automatische veeg",
"Blacklisted words": "Verboden woorden",
"words you dont want generated separated by comma ','": "woorden die je niet gegenereerd wilt hebben gescheiden door komma ','",
"Blacklisted word count to swipe": "Aantal verboden woorden om te vegen",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "separe com vírgulas sem espaço entre",
"Custom Stopping Strings": "Cadeias de parada personalizadas",
"JSON serialized array of strings": "Matriz de strings serializada em JSON",
"Replace Macro in Custom Stopping Strings": "Substituir Macro em Strings de Parada Personalizadas",
"Replace Macro in Stop Strings": "Substituir Macro em Strings de Parada Personalizadas",
"Auto-Continue": "Auto-Continuar",
"Allow for Chat Completion APIs": "Permitir APIs de Completar Chat",
"Target length (tokens)": "Comprimento alvo (tokens)",
@ -709,7 +709,7 @@
"Auto-swipe": "Auto-swipe",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Ativar a função de auto-swipe. As configurações nesta seção só têm efeito quando o auto-swipe está ativado",
"Minimum generated message length": "Comprimento mínimo da mensagem gerada",
"If the generated message is shorter than this, trigger an auto-swipe": "Se a mensagem gerada for mais curta que isso, acione um auto-swipe",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Se a mensagem gerada for mais curta que isso, acione um auto-swipe",
"Blacklisted words": "Palavras proibidas",
"words you dont want generated separated by comma ','": "palavras que você não quer geradas separadas por vírgula ','",
"Blacklisted word count to swipe": "Contagem de palavras proibidas para swipe",

View File

@ -161,7 +161,7 @@
"View hidden API keys": "Посмотреть скрытые API-ключи",
"Advanced Formatting": "Расширенное форматирование",
"Context Template": "Шаблон контекста",
"Replace Macro in Custom Stopping Strings": "Заменять макросы в пользовательских стоп-строках",
"Replace Macro in Stop Strings": "Заменять макросы в пользовательских стоп-строках",
"Story String": "Строка истории",
"Example Separator": "Разделитель примеров сообщений",
"Chat Start": "Начало чата",
@ -195,7 +195,7 @@
"Yes": "Да",
"No": "Нет",
"Context %": "Процент контекста",
"Budget Cap": "Бюджетный лимит",
"Budget Cap": "Лимит бюджета",
"(0 = disabled)": "(0 = отключено)",
"None": "Отсутствует",
"User Settings": "Настройки пользователя",
@ -426,7 +426,7 @@
"Requests logprobs from the API for the Token Probabilities feature": "Запросить логпробы из API для функции Token Probabilities.",
"Automatically reject and re-generate AI message based on configurable criteria": "Автоматическое отклонение и повторная генерация сообщений AI на основе настраиваемых критериев.",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Включить авто-свайп. Настройки в этом разделе действуют только при включенном авто-свайпе.",
"If the generated message is shorter than this, trigger an auto-swipe": "Если сгенерированное сообщение короче этого значения, срабатывает авто-свайп.",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Если сгенерированное сообщение короче этого значения, срабатывает авто-свайп.",
"Reload and redraw the currently open chat": "Перезагрузить и перерисовать открытый в данный момент чат.",
"Auto-Expand Message Actions": "Развернуть действия",
"Persona Management": "Управление персоной",
@ -575,10 +575,10 @@
"Characters sorting order": "Порядок сортировки персонажей",
"Remove": "Убрать",
"Select a World Info file for": "Выбрать файл с миром для",
"Primary Lorebook": "Основного лорбука",
"A selected World Info will be bound to this character as its own Lorebook.": "Информация о мире будет привязана к персонажу как его собственный лорбук",
"When generating an AI reply, it will be combined with the entries from a global World Info selector.": "Когда ИИ генерирует ответ, он будет совмещён с записями из глобально выбранного мира",
"Exporting a character would also export the selected Lorebook file embedded in the JSON data.": "При экспорте персонажа вместе с ним также выгрузится выбранный лорбук в виде JSON",
"Primary Lorebook": "Основной лорбук",
"A selected World Info will be bound to this character as its own Lorebook.": "Информация о мире будет привязана к персонажу как его собственный лорбук.",
"When generating an AI reply, it will be combined with the entries from a global World Info selector.": "Когда ИИ генерирует ответ, он будет совмещён с записями из глобально выбранного мира.",
"Exporting a character would also export the selected Lorebook file embedded in the JSON data.": "При экспорте персонажа вместе с ним также выгрузится выбранный лорбук в виде JSON.",
"Additional Lorebooks": "Вспомогательные лорбуки",
"Associate one or more auxillary Lorebooks with this character.": "Привязать к этому персонажу один или больше вспомогательных лорбуков",
"NOTE: These choices are optional and won't be preserved on character export!": "ВНИМАНИЕ: эти выборы необязательные и не будут сохранены при экспорте персонажа!",
@ -593,7 +593,7 @@
"Prompt": "Промпт",
"Copy": "Скопировать",
"Confirm": "Подтвердить",
"Copy this message": "Скопировать сообщение",
"Copy this message": "Продублировать сообщение",
"Delete this message": "Удалить сообщение",
"Move message up": "Переместить сообщение вверх",
"Move message down": "Переместить сообщение вниз",
@ -612,7 +612,7 @@
"Ask AI to write your message for you": "Попросить ИИ написать сообщение за вас",
"Continue the last message": "Продолжить текущее сообщение",
"Bind user name to that avatar": "Закрепить имя за этим аватаром",
"Select this as default persona for the new chats.": "Выберать эту Персону в качестве персоны по умолчанию для новых чатов.",
"Select this as default persona for the new chats.": "Выбирать эту персону по умолчанию для всех новых чатов.",
"Change persona image": "Сменить аватар персоны",
"Delete persona": "Удалить персону",
"Reduced Motion": "Сокращение анимаций",
@ -640,7 +640,7 @@
"Token Probabilities": "Вероятности токенов",
"Close chat": "Закрыть чат",
"Manage chat files": "Все чаты",
"Import Extension From Git Repo": "Импортировать расширение из Git Repository",
"Import Extension From Git Repo": "Импортировать расширение из Git-репозитория.",
"Install extension": "Установить расширение",
"Manage extensions": "Управление расширениями",
"Tokens persona description": "Токенов",
@ -1122,7 +1122,7 @@
"help_hotkeys_0": "Горячие клавиши",
"You can browse a list of bundled characters in the": "Комплектных персонажей можно найти в меню",
"Download Extensions & Assets": "Загрузить расширения и ресурсы",
"menu within": нутри этих кубиков",
"menu within": меню",
"Assets URL": "URL с описанием ресурсов",
"Custom (OpenAI-compatible)": "Кастомный (совместимый с OpenAI)",
"Custom Endpoint (Base URL)": "Кастомный эндпоинт (базовый URL)",
@ -1943,7 +1943,7 @@
"and connect to an": "и подключитесь к",
"You can add more": "Можете добавить больше",
"from other websites": "с других сайтов.",
"Go to the": "Загляните в",
"Go to the": "Заходите в",
"to install additional features.": ", чтобы установить разные дополнительные ресурсы.",
"or_welcome": "; также доступен",
"Claude API Key": "Ключ от API Claude",
@ -1958,7 +1958,7 @@
"Save": "Сохранить",
"Chat Lorebook": "Лорбук для чата",
"chat_world_template_txt": "Выбранный мир будет привязан к этому чату. Будет добавляться в промпт наряду с глобальным лорбуком и лором персонажа.",
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + клик, чтобы открыть диалог привязки мира",
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + ЛКМ, чтобы открыть диалог привязки мира",
"No auxillary Lorebooks set. Click here to select.": "Вспомогательный лорбук не выбран. Нажмите, чтобы выбрать.",
"ext_regex_user_input_desc": "Отправленные вами сообщения.",
"ext_regex_ai_input_desc": "Полученные от API ответы.",
@ -2144,5 +2144,65 @@
"Not connected to the API!": "Нет соединения с API!",
"ext_type_system": "Это комплектное расширение. Его нельзя удалить, а обновляется оно вместе со всей системой.",
"Update all": "Обновить все",
"Close": "Закрыть"
"Close": "Закрыть",
"Optional modules:": "Необязательные модули:",
"Sort: Display Name": "Сортировать: по названию",
"Sort: Loading Order": "Сортировать: в порядке загрузки",
"Click to toggle": "Нажмите, чтобы включить или выключить",
"Loading Asset List": "Загрузить список ресурсов",
"Don't ask again for this URL": "Запомнить выбор для этого адреса",
"Are you sure you want to connect to the following url?": "Вы точно хотите подключиться к этому адресу?",
"All": "Всё",
"Characters": "Персонажи",
"Ambient sounds": "Звуковой эмбиент",
"Blip sounds": "Звуки уведомлений",
"Background music": "Фоновая музыка",
"Search": "Поиск",
"extension_install_1": "Чтобы загружать расширения из этого списка, у вас должен быть установлен ",
"extension_install_2": ".",
"extension_install_3": "Нажмите на иконку ",
"extension_install_4": ", чтобы перейти в репозиторий расширения и получить более подробную информацию о нём.",
"Extension repo/guide:": "Репозиторий расширения:",
"Preview in browser": "Предпросмотр",
"Adds a function tool": "Частично или полностью работает через вызов функций",
"Tool": "Функции",
"Move extension": "Переместить расширение",
"ext_type_local": "Это локальное расширение, доступно только вам",
"ext_type_global": "Это глобальное расширение, доступно всем пользователям",
"Move": "Переместить",
"Enter the Git URL of the extension to install": "Введите Git-адрес расширения",
"Please be aware that using external extensions can have unintended side effects and may pose security risks. Always make sure you trust the source before importing an extension. We are not responsible for any damage caused by third-party extensions.": "помните, что используя расширения от сторонних авторов, вы можете подвергать систему опасности. Устанавливайте расширения только от проверенных разработчиков. Мы не несём ответственности за любой ущерб, причинённый сторонними расширениями.",
"Disclaimer:": "Внимание:",
"Example:": "Пример:",
"context_derived": "Считывать из метаданных модели (по возможности)",
"instruct_derived": "Считывать из метаданных модели (по возможности)",
"Confirm token parsing with": "Чтобы убедиться в правильности выделения токенов, используйте",
"Reasoning Effort": "Рассуждения",
"Constrains effort on reasoning for reasoning models.": "Регулирует объём внутренних рассуждений модели (reasoning), для моделей которые поддерживают эту возможность.\nНа данный момент поддерживаются три значения: Подробные, Обычные, Поверхностные.\nПри менее подробном рассуждении ответ получается быстрее, а также экономятся токены, уходящие на рассуждения.",
"openai_reasoning_effort_low": "Поверхностные",
"openai_reasoning_effort_medium": "Обычные",
"openai_reasoning_effort_high": "Подробные",
"Persona Lore Alt+Click to open the lorebook": "Лорбук данной персоны\nAlt + ЛКМ чтобы открыть лорбук",
"Persona Lorebook for": "Лорбук для персоны",
"persona_world_template_txt": "Выбранная Информация о мире будет привязана к этой персоне. Информация будет добавляться в каждом промпте вместе с глобальным лорбуком и лорбуками персонажа и чата.",
"Global list": "Глобальный список",
"Preset-specific list": "Список для данного пресета",
"Banned tokens/strings are being sent in the request.": "Запрещённые токены и строки отсылаются в запросе.",
"Banned tokens/strings are NOT being sent in the request.": "Запрещённые токены и строки НЕ отсылаются в запросе.",
"Add a reasoning block": "Добавить блок рассуждений",
"Create a copy of this message?": "Продублировать это сообщение?",
"Max Recursion Steps": "Макс. глубина рекурсии",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "0 = неограничено, 1 = сканировать единожды, 2 = сканировать единожды и сделать один повторный проход, и т.д.\n(неактивно при указанном мин. числе активаций)",
"(disabled when max recursion steps are used)": "(неактивно при указанной макс. глубине рекурсии)",
"Enter a valid API URL": "Введите корректный адрес API",
"No Ollama model selected.": "Не выбрана модель Ollama",
"Background Fitting": "Способ подгонки фона под разрешение",
"Chat Lore Alt+Click to open the lorebook": "Лорбук данного чата\nAlt + ЛКМ чтобы открыть лорбук",
"Token Counter": "Подсчитать токены",
"Type / paste in the box below to see the number of tokens in the text.": "Введите или вставьте текст в окошко ниже, чтобы подсчитать количество токенов в нём.",
"Selected tokenizer:": "Выбранный токенайзер:",
"Input:": "Входные данные:",
"Tokenized text:": "Токенизированный текст:",
"Token IDs:": "Идентификаторы токенов:",
"Tokens:": "Токенов:"
}

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "розділяйте комами без пропусків між ними",
"Custom Stopping Strings": "Власні рядки зупинки",
"JSON serialized array of strings": "JSON-серіалізований масив рядків",
"Replace Macro in Custom Stopping Strings": "Замінювати макроси у власних рядках зупинки",
"Replace Macro in Stop Strings": "Замінювати макроси у власних рядках зупинки",
"Auto-Continue": "Автоматичне продовження",
"Allow for Chat Completion APIs": "Дозволити для Chat Completion API",
"Target length (tokens)": "Цільова довжина (токени)",
@ -709,7 +709,7 @@
"Auto-swipe": "Автоматичний змах",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Вмикає функцію автоматичного змаху. Налаштування в цьому розділі діють лише тоді, коли увімкнено автоматичний змах",
"Minimum generated message length": "Мінімальна довжина згенерованого повідомлення",
"If the generated message is shorter than this, trigger an auto-swipe": "Якщо згенероване повідомлення коротше за це, викликайте автоматичний змаху",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Якщо згенероване повідомлення коротше за це, викликайте автоматичний змаху",
"Blacklisted words": "Список заборонених слів",
"words you dont want generated separated by comma ','": "слова, які ви не хочете генерувати, розділені комою ','",
"Blacklisted word count to swipe": "Кількість заборонених слів для змаху",

View File

@ -482,7 +482,7 @@
"separate with commas w/o space between": "phân tách bằng dấu phẩy không có khoảng trắng giữa",
"Custom Stopping Strings": "Chuỗi dừng tùy chỉnh",
"JSON serialized array of strings": "Mảng chuỗi được tuần tự hóa JSON",
"Replace Macro in Custom Stopping Strings": "Thay thế Macro trong Chuỗi Dừng Tùy chỉnh",
"Replace Macro in Stop Strings": "Thay thế Macro trong Chuỗi Dừng Tùy chỉnh",
"Auto-Continue": "Tự động Tiếp tục",
"Allow for Chat Completion APIs": "Cho phép các API hoàn thành Trò chuyện",
"Target length (tokens)": "Độ dài mục tiêu (token)",
@ -709,7 +709,7 @@
"Auto-swipe": "Tự động vuốt",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Bật chức năng tự động vuốt. Các cài đặt trong phần này chỉ có tác dụng khi tự động vuốt được bật",
"Minimum generated message length": "Độ dài tối thiểu của tin nhắn được tạo",
"If the generated message is shorter than this, trigger an auto-swipe": "Nếu tin nhắn được tạo ra ngắn hơn điều này, kích hoạt tự động vuốt",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "Nếu tin nhắn được tạo ra ngắn hơn điều này, kích hoạt tự động vuốt",
"Blacklisted words": "Từ trong danh sách đen",
"words you dont want generated separated by comma ','": "các từ bạn không muốn được tạo ra được phân tách bằng dấu phẩy ','",
"Blacklisted word count to swipe": "Số từ trong danh sách đen để vuốt",

View File

@ -215,7 +215,7 @@
"Classifier Free Guidance. More helpful tip coming soon": "无分类器指导CFG。更多有用的提示敬请期待。",
"Scale": "缩放比例",
"Negative Prompt": "负面提示词",
"Used if CFG Scale is unset globally, per chat or character": "如果无分类器指导CFG缩放比例未在全局设置它将作用于每个聊天或每个角色",
"Used if CFG Scale is unset globally, per chat or character": "如果CFG缩放比例未被全局设置它将作用于所有聊天或角色",
"Add text here that would make the AI generate things you don't want in your outputs.": "请在此处添加文本,以避免生成您不希望出现在输出中的内容。",
"Grammar String": "语法字符串",
"GBNF or EBNF, depends on the backend in use. If you're using this you should know which.": "GBNF 或 EBNF取决于使用的后端。如果您使用这个您应该知道该用哪一个。",
@ -266,8 +266,8 @@
"Use system prompt": "使用系统提示词",
"Merges_all_system_messages_desc_1": "合并所有系统消息,直到第一条具有非系统角色的消息,然后通过",
"Merges_all_system_messages_desc_2": "字段发送。",
"Show model reasoning": "展示思维链",
"Display the model's internal thoughts in the response.": "展示模型在回复时的内部思维链。",
"Request model reasoning": "请求思维链",
"Allows the model to return its thinking process.": "允许模型返回其思维过程。",
"Assistant Prefill": "AI预填",
"Expand the editor": "展开编辑器",
"Start Claude's answer with...": "以如下内容开始Claude的回答...",
@ -559,7 +559,7 @@
"Prompt Content": "提示词内容",
"Custom Stopping Strings": "自定义停止字符串",
"JSON serialized array of strings": "JSON序列化的字符串数组",
"Replace Macro in Custom Stopping Strings": "替换自定义停止字符串中的宏",
"Replace Macro in Stop Strings": "替换自定义停止字符串中的宏",
"Token Padding": "词符填充",
"Miscellaneous": "杂项",
"Non-markdown strings": "非 Markdown 字符串",
@ -584,7 +584,7 @@
"(0 = unlimited, use budget)": "“0”为无限制使用预算",
"Cap the number of entry activation recursions": "限制条目激活递归的次数",
"Max Recursion Steps": "最大递归深度",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\\n(disabled when min activations are used)": "“0”为无限制“1”为扫描一次且不递归“2”为扫描一次且递归一次依此类推\n当使用最小激活次数时此功能被禁用",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "“0”为无限制“1”为扫描一次且不递归“2”为扫描一次且递归一次依此类推\n当使用最小激活次数时此功能被禁用",
"Insertion Strategy": "插入策略",
"Sorted Evenly": "均匀排序",
"Character Lore First": "角色世界书优先",
@ -804,7 +804,7 @@
"Auto-swipe": "自动滑动",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "启用自动滑动功能。仅当启用自动滑动时,本节中的设置才会生效",
"Minimum generated message length": "生成的消息的最小长度",
"If the generated message is shorter than this, trigger an auto-swipe": "如果生成的消息短于此长度,则触发自动滑动",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "如果生成的消息短于此长度,则触发自动滑动",
"Blacklisted words": "屏蔽词",
"words you dont want generated separated by comma ','": "不想生成的词语,用半角逗号“,”分隔",
"Blacklisted word count to swipe": "触发滑动的黑名单词语数量",
@ -1208,7 +1208,7 @@
"View contents": "查看内容",
"Remove the file": "删除文件",
"Author's Note": "作者注释",
"Unique to this chat": "此聊天独有",
"Unique to this chat": "仅对此聊天生效",
"Checkpoints inherit the Note from their parent, and can be changed individually after that.": "检查点从其父级继承注释,之后可以单独更改。",
"Include in World Info Scanning": "纳入世界信息扫描",
"Before Main Prompt / Story String": "主提示词/故事线之前",
@ -1224,13 +1224,13 @@
"Replace Author's Note": "替换作者注",
"Default Author's Note": "默认作者注",
"Will be automatically added as the Author's Note for all new chats.": "将自动添加为所有新聊天的作者注释。",
"Chat CFG": "聊天CFG",
"1 = disabled": "“1”为禁用",
"Chat CFG": "聊天CFG缩放",
"1 = disabled": "“1”为禁用",
"write short replies, write replies using past tense": "写简短的回复,用过去时写回复",
"Positive Prompt": "正面提示词",
"Use character CFG scales": "单独为各个角色设置CFG缩放",
"Character CFG": "角色CFG配置",
"Will be automatically added as the CFG for this character.": "将自动添加为该角色的 CFG。",
"Will be automatically added as the CFG for this character.": "将自动添加到该角色的CFG设置中。",
"Global CFG": "全局CFG",
"Will be used as the default CFG options for every chat unless overridden.": "除非被覆盖,否则将用作每次聊天的默认 CFG 选项。",
"CFG Prompt Cascading": "CFG 提示词级联",
@ -1349,7 +1349,6 @@
"Character Expressions": "角色表情",
"Translate text to English before classification": "分类之前将文本翻译成英文",
"Show default images (emojis) if sprite missing": "如果表情包缺失,则显示默认图像(表情符号)",
"Image Type - talkinghead (extras)": "图像类型 - 说话头像(附加内容)",
"Classifier API": "分类器 API",
"Select the API for classifying expressions.": "选择用于对表达式进行分类的API。",
"Main API": "主要 API",
@ -1486,7 +1485,7 @@
"ext_regex_replace_string_placeholder": "使用 {{match}} 包含来自“查找正则表达式”或“$1”、“$2”等的匹配文本作为捕获组。",
"Trim Out": "修剪掉",
"ext_regex_trim_placeholder": "在替换之前全局修剪正则表达式匹配中任何不需要的部分。用回车键分隔每个元素。",
"ext_regex_affects": "影响",
"ext_regex_affects": "作用范围",
"ext_regex_user_input_desc": "用户发送的消息",
"ext_regex_user_input": "用户输入",
"ext_regex_ai_input_desc": "从生成式API中获取的信息。",
@ -1720,9 +1719,9 @@
"Chat Lorebook for": "聊天知识书",
"chat_world_template_txt": "选定的世界信息将绑定到此聊天。生成 AI 回复时,\n它将与全球和角色传说书中的条目相结合。",
"chat_rename_1": "输入聊天的新名称:",
"chat_rename_2": "注意!!使用已有文件名会导致错误!!",
"chat_rename_3": "此举会将聊天与标记为“检查点”的聊天解绑。",
"chat_rename_4": "不需要在结尾添加 '.JSONL'",
"chat_rename_2": "注意!!与其他文件重名会导致错误!!",
"chat_rename_3": "此举会将聊天与标记为“检查点”的聊天解绑。",
"chat_rename_4": "不需要在结尾添加 '.JSONL' 后缀)",
"Enter Checkpoint Name:": "输入检查点名称:",
"(Leave empty to auto-generate)": "(留空以自动生成)",
"The currently existing checkpoint will be unlinked and replaced with the new checkpoint, but can still be found in the Chat Management.": "当前检查点将会被解绑并替换为新的检查点,但仍可在聊天管理中找到。",
@ -1975,7 +1974,7 @@
"Enter your password below to confirm:": "输入您的密码以确认:",
"Chat Scenario Override": "聊天场景覆盖",
"Remove": "移除",
"Unique to this chat.": "Unique to this chat.",
"Unique to this chat.": "仅对此聊天生效。",
"All group members will use the following scenario text instead of what is specified in their character cards.": "All group members will use the following scenario text instead of what is specified in their character cards.",
"The following scenario text will be used instead of the value set in the character card.": "The following scenario text will be used instead of the value set in the character card.",
"Checkpoints inherit the scenario override from their parent, and can be changed individually after that.": "Checkpoints inherit the scenario override from their parent, and can be changed individually after that.",

View File

@ -483,7 +483,7 @@
"separate with commas w/o space between": "用逗號分隔,之間無空格",
"Custom Stopping Strings": "自訂停止字串",
"JSON serialized array of strings": "JSON 序列化字串數組",
"Replace Macro in Custom Stopping Strings": "取代自訂停止字串中的巨集",
"Replace Macro in Stop Strings": "取代自訂停止字串中的巨集",
"Auto-Continue": "自動繼續",
"Allow for Chat Completion APIs": "允許聊天補全 API",
"Target length (tokens)": "目標長度(符元)",
@ -710,7 +710,7 @@
"Auto-swipe": "自動滑動",
"Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "啟用自動滑動功能。此部分的設定僅在啟用自動滑動時有效。",
"Minimum generated message length": "生成訊息的最小長度",
"If the generated message is shorter than this, trigger an auto-swipe": "如果生成的訊息比這個短,將觸發自動滑動。",
"If the generated message is shorter than these many characters, trigger an auto-swipe": "如果生成的訊息比這個短,將觸發自動滑動。",
"Blacklisted words": "黑名單詞語",
"words you dont want generated separated by comma ','": "您不想生成的文字,使用逗號分隔",
"Blacklisted word count to swipe": "滑動的黑名單詞語數量",
@ -1458,7 +1458,7 @@
"Example: http://localhost:1234/v1": "例如http://localhost:1234/v1",
"popup-button-crop": "裁剪",
"(disabled when max recursion steps are used)": "(當最大遞歸步驟數使用時將停用)",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\n(disabled when min activations are used)": "0 = 無限制1 = 掃描一次且不遞歸2 = 掃描一次並遞歸一次,以此類推\n使用最小啟動設定時將停用",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "0 = 無限制1 = 掃描一次且不遞歸2 = 掃描一次並遞歸一次,以此類推\n使用最小啟動設定時將停用",
"A greedy, brute-force algorithm used in LLM sampling to find the most likely sequence of words or tokens. It expands multiple candidate sequences at once, maintaining a fixed number (beam width) of top sequences at each step.": "一種用於 LLM 抽樣的貪婪演算法用於尋找最可能的單詞或標記序列。該方法會同時展開多個候選序列並在每一步中保持固定數量的頂級序列beam width。",
"A multiplicative factor to expand the overall area that the nodes take up.": "節點佔用該擴充功能區域的倍數。",
"Abort current image generation task": "終止目前的圖片生成任務",
@ -1653,7 +1653,6 @@
"HuggingFace Token": "HuggingFace 符元",
"Image Captioning": "圖片註解",
"Generate Caption": "產生圖片註解",
"Image Type - talkinghead (extras)": "圖片類型 - talkinghead額外選項",
"Injection Position": "插入位置",
"Injection position. Relative (to other prompts in prompt manager) or In-chat @ Depth.": "插入位置(與提示詞管理器中的其他提示相比)或聊天中的深度位置。",
"Injection Template": "插入範本",
@ -1806,7 +1805,7 @@
"context_derived": "若可能,根據模型元數據推導。",
"instruct_derived": "若可能,根據模型元數據推導。",
"Inserted before the first User's message.": "插入於第一則使用者訊息之前。",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\\n(disabled when min activations are used)": "0 = 無限制1 = 掃描一次不遞歸2 = 掃描一次後遞歸一次 ⋯以此類推\n啟用最小啟動次數時無效",
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "0 = 無限制1 = 掃描一次不遞歸2 = 掃描一次後遞歸一次 ⋯以此類推\n啟用最小啟動次數時無效",
"Quick 'Impersonate' button": "快速「AI 扮演使用者」按鈕",
"Manual": "手動",
"Any contents here will replace the default Post-History Instructions used for this character. (v2 spec: post_history_instructions)": "此處填入的內容將取代該角色的默認聊天歷史後指示Post-History Instructions。\nv2 格式specpost_history_instructions",
@ -2357,8 +2356,8 @@
"Forbid": "禁止",
"Aphrodite only. Determines the order of samplers. Skew is always applied post-softmax, so it's not included here.": "僅限 Aphrodite 使用。決定採樣器的順序。偏移總是在 softmax 後應用,因此不包括在此。",
"Aphrodite only. Determines the order of samplers.": "僅限 Aphrodite 使用。決定採樣器的順序。",
"Show model reasoning": "顯示模型思維鏈",
"Display the model's internal thoughts in the response.": "在回應中顯示模型的思維鏈(內部思考過程)。",
"Request model reasoning": "請求模型思維鏈",
"Allows the model to return its thinking process.": "讓模型回傳其思考過程。",
"Generic (OpenAI-compatible) [LM Studio, LiteLLM, etc.]": "通用(兼容 OpenAI[LM Studio, LiteLLM 等]",
"Model ID (optional)": "模型 ID可選",
"DeepSeek API Key": "DeepSeek API 金鑰",

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,6 @@ import {
send_on_enter_options,
} from './power-user.js';
import { LoadLocal, SaveLocal, LoadLocalBool } from './f-localStorage.js';
import { selected_group, is_group_generating, openGroupById } from './group-chats.js';
import { getTagKeyForEntity, applyTagsOnCharacterSelect } from './tags.js';
import {
@ -41,6 +40,8 @@ import { textgen_types, textgenerationwebui_settings as textgen_settings, getTex
import { debounce_timeout } from './constants.js';
import { Popup } from './popup.js';
import { accountStorage } from './util/AccountStorage.js';
import { getCurrentUserHandle } from './user.js';
var RPanelPin = document.getElementById('rm_button_panel_pin');
var LPanelPin = document.getElementById('lm_button_panel_pin');
@ -279,17 +280,32 @@ async function RA_autoloadchat() {
// active character is the name, we should look it up in the character list and get the id
if (active_character !== null && active_character !== undefined) {
const active_character_id = characters.findIndex(x => getTagKeyForEntity(x) === active_character);
if (active_character_id !== null) {
if (active_character_id !== -1) {
await selectCharacterById(active_character_id);
// Do a little tomfoolery to spoof the tag selector
const selectedCharElement = $(`#rm_print_characters_block .character_select[chid="${active_character_id}"]`);
applyTagsOnCharacterSelect.call(selectedCharElement);
} else {
setActiveCharacter(null);
saveSettingsDebounced();
console.warn(`Currently active character with ID ${active_character} not found. Resetting to no active character.`);
}
}
if (active_group !== null && active_group !== undefined) {
await openGroupById(String(active_group));
if (active_character) {
console.warn('Active character and active group are both set. Only active character will be loaded. Resetting active group.');
setActiveGroup(null);
saveSettingsDebounced();
} else {
const result = await openGroupById(String(active_group));
if (!result) {
setActiveGroup(null);
saveSettingsDebounced();
console.warn(`Currently active group with ID ${active_group} not found. Resetting to no active group.`);
}
}
}
// if the character list hadn't been loaded yet, try again.
@ -409,32 +425,34 @@ function RA_autoconnect(PrevApi) {
function OpenNavPanels() {
if (!isMobile()) {
//auto-open R nav if locked and previously open
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
if (accountStorage.getItem('NavLockOn') == 'true' && accountStorage.getItem('NavOpened') == 'true') {
//console.log("RA -- clicking right nav to open");
$('#rightNavDrawerIcon').click();
}
//auto-open L nav if locked and previously open
if (LoadLocalBool('LNavLockOn') == true && LoadLocalBool('LNavOpened') == true) {
if (accountStorage.getItem('LNavLockOn') == 'true' && accountStorage.getItem('LNavOpened') == 'true') {
console.debug('RA -- clicking left nav to open');
$('#leftNavDrawerIcon').click();
}
//auto-open WI if locked and previously open
if (LoadLocalBool('WINavLockOn') == true && LoadLocalBool('WINavOpened') == true) {
if (accountStorage.getItem('WINavLockOn') == 'true' && accountStorage.getItem('WINavOpened') == 'true') {
console.debug('RA -- clicking WI to open');
$('#WIDrawerIcon').click();
}
}
}
const getUserInputKey = () => getCurrentUserHandle() + '_userInput';
function restoreUserInput() {
if (!power_user.restore_user_input) {
console.debug('restoreUserInput disabled');
return;
}
const userInput = LoadLocal('userInput');
const userInput = localStorage.getItem(getUserInputKey());
if (userInput) {
$('#send_textarea').val(userInput)[0].dispatchEvent(new Event('input', { bubbles: true }));
}
@ -442,7 +460,8 @@ function restoreUserInput() {
function saveUserInput() {
const userInput = String($('#send_textarea').val());
SaveLocal('userInput', userInput);
localStorage.setItem(getUserInputKey(), userInput);
console.debug('User Input -- ', userInput);
}
const saveUserInputDebounced = debounce(saveUserInput);
@ -739,7 +758,7 @@ export function initRossMods() {
//toggle pin class when lock toggle clicked
$(RPanelPin).on('click', function () {
SaveLocal('NavLockOn', $(RPanelPin).prop('checked'));
accountStorage.setItem('NavLockOn', $(RPanelPin).prop('checked'));
if ($(RPanelPin).prop('checked') == true) {
//console.log('adding pin class to right nav');
$(RightNavPanel).addClass('pinnedOpen');
@ -757,7 +776,7 @@ export function initRossMods() {
}
});
$(LPanelPin).on('click', function () {
SaveLocal('LNavLockOn', $(LPanelPin).prop('checked'));
accountStorage.setItem('LNavLockOn', $(LPanelPin).prop('checked'));
if ($(LPanelPin).prop('checked') == true) {
//console.log('adding pin class to Left nav');
$(LeftNavPanel).addClass('pinnedOpen');
@ -776,7 +795,7 @@ export function initRossMods() {
});
$(WIPanelPin).on('click', function () {
SaveLocal('WINavLockOn', $(WIPanelPin).prop('checked'));
accountStorage.setItem('WINavLockOn', $(WIPanelPin).prop('checked'));
if ($(WIPanelPin).prop('checked') == true) {
console.debug('adding pin class to WI');
$(WorldInfo).addClass('pinnedOpen');
@ -796,8 +815,8 @@ export function initRossMods() {
});
// read the state of right Nav Lock and apply to rightnav classlist
$(RPanelPin).prop('checked', LoadLocalBool('NavLockOn'));
if (LoadLocalBool('NavLockOn') == true) {
$(RPanelPin).prop('checked', accountStorage.getItem('NavLockOn') == 'true');
if (accountStorage.getItem('NavLockOn') == 'true') {
//console.log('setting pin class via local var');
$(RightNavPanel).addClass('pinnedOpen');
$(RightNavDrawerIcon).addClass('drawerPinnedOpen');
@ -808,8 +827,8 @@ export function initRossMods() {
$(RightNavDrawerIcon).addClass('drawerPinnedOpen');
}
// read the state of left Nav Lock and apply to leftnav classlist
$(LPanelPin).prop('checked', LoadLocalBool('LNavLockOn'));
if (LoadLocalBool('LNavLockOn') == true) {
$(LPanelPin).prop('checked', accountStorage.getItem('LNavLockOn') === 'true');
if (accountStorage.getItem('LNavLockOn') == 'true') {
//console.log('setting pin class via local var');
$(LeftNavPanel).addClass('pinnedOpen');
$(LeftNavDrawerIcon).addClass('drawerPinnedOpen');
@ -821,8 +840,8 @@ export function initRossMods() {
}
// read the state of left Nav Lock and apply to leftnav classlist
$(WIPanelPin).prop('checked', LoadLocalBool('WINavLockOn'));
if (LoadLocalBool('WINavLockOn') == true) {
$(WIPanelPin).prop('checked', accountStorage.getItem('WINavLockOn') === 'true');
if (accountStorage.getItem('WINavLockOn') == 'true') {
//console.log('setting pin class via local var');
$(WorldInfo).addClass('pinnedOpen');
$(WIDrawerIcon).addClass('drawerPinnedOpen');
@ -837,22 +856,22 @@ export function initRossMods() {
//save state of Right nav being open or closed
$('#rightNavDrawerIcon').on('click', function () {
if (!$('#rightNavDrawerIcon').hasClass('openIcon')) {
SaveLocal('NavOpened', 'true');
} else { SaveLocal('NavOpened', 'false'); }
accountStorage.setItem('NavOpened', 'true');
} else { accountStorage.setItem('NavOpened', 'false'); }
});
//save state of Left nav being open or closed
$('#leftNavDrawerIcon').on('click', function () {
if (!$('#leftNavDrawerIcon').hasClass('openIcon')) {
SaveLocal('LNavOpened', 'true');
} else { SaveLocal('LNavOpened', 'false'); }
accountStorage.setItem('LNavOpened', 'true');
} else { accountStorage.setItem('LNavOpened', 'false'); }
});
//save state of Left nav being open or closed
$('#WorldInfo').on('click', function () {
if (!$('#WorldInfo').hasClass('openIcon')) {
SaveLocal('WINavOpened', 'true');
} else { SaveLocal('WINavOpened', 'false'); }
accountStorage.setItem('WINavOpened', 'true');
} else { accountStorage.setItem('WINavOpened', 'false'); }
});
var chatbarInFocus = false;
@ -868,8 +887,8 @@ export function initRossMods() {
OpenNavPanels();
}, 300);
$(SelectedCharacterTab).click(function () { SaveLocal('SelectedNavTab', 'rm_button_selected_ch'); });
$('#rm_button_characters').click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
$(SelectedCharacterTab).click(function () { accountStorage.setItem('SelectedNavTab', 'rm_button_selected_ch'); });
$('#rm_button_characters').click(function () { accountStorage.setItem('SelectedNavTab', 'rm_button_characters'); });
// when a char is selected from the list, save them as the auto-load character for next page load
@ -1063,14 +1082,21 @@ export function initRossMods() {
// Ctrl+Enter for Regeneration Last Response. If editing, accept the edits instead
if (event.ctrlKey && event.key == 'Enter') {
const editMesDone = $('.mes_edit_done:visible');
const reasoningMesDone = $('.mes_reasoning_edit_done:visible');
if (editMesDone.length > 0) {
console.debug('Accepting edits with Ctrl+Enter');
$('#send_textarea').focus();
$('#send_textarea').trigger('focus');
editMesDone.trigger('click');
return;
} else if (is_send_press == false) {
} else if (reasoningMesDone.length > 0) {
console.debug('Accepting edits with Ctrl+Enter');
$('#send_textarea').trigger('focus');
reasoningMesDone.trigger('click');
return;
}
else if (is_send_press == false) {
const skipConfirmKey = 'RegenerateWithCtrlEnter';
const skipConfirm = LoadLocalBool(skipConfirmKey);
const skipConfirm = accountStorage.getItem(skipConfirmKey) === 'true';
function doRegenerate() {
console.debug('Regenerating with Ctrl+Enter');
$('#option_regenerate').trigger('click');
@ -1082,13 +1108,15 @@ export function initRossMods() {
let regenerateWithCtrlEnter = false;
const result = await Popup.show.confirm('Regenerate Message', 'Are you sure you want to regenerate the latest message?', {
customInputs: [{ id: 'regenerateWithCtrlEnter', label: 'Don\'t ask again' }],
onClose: (popup) => regenerateWithCtrlEnter = popup.inputResults.get('regenerateWithCtrlEnter') ?? false,
onClose: (popup) => {
regenerateWithCtrlEnter = popup.inputResults.get('regenerateWithCtrlEnter') ?? false;
},
});
if (!result) {
return;
}
SaveLocal(skipConfirmKey, regenerateWithCtrlEnter);
accountStorage.setItem(skipConfirmKey, String(regenerateWithCtrlEnter));
doRegenerate();
}
return;

View File

@ -566,7 +566,7 @@ export function initAuthorsNote() {
namedArgumentList: [],
unnamedArgumentList: [
new SlashCommandArgument(
'position', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user', 'assistant'],
'role', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user', 'assistant'],
),
],
helpString: `

View File

@ -96,8 +96,13 @@ function highlightLockedBackground() {
});
}
/**
* Locks the background for the current chat
* @param {Event} e Click event
* @returns {string} Empty string
*/
function onLockBackgroundClick(e) {
e.stopPropagation();
e?.stopPropagation();
const chatName = getCurrentChatId();
@ -106,7 +111,7 @@ function onLockBackgroundClick(e) {
return '';
}
const relativeBgImage = getUrlParameter(this);
const relativeBgImage = getUrlParameter(this) ?? background_settings.url;
saveBackgroundMetadata(relativeBgImage);
setCustomBackground();
@ -114,8 +119,13 @@ function onLockBackgroundClick(e) {
return '';
}
/**
* Locks the background for the current chat
* @param {Event} e Click event
* @returns {string} Empty string
*/
function onUnlockBackgroundClick(e) {
e.stopPropagation();
e?.stopPropagation();
removeBackgroundMetadata();
unsetCustomBackground();
highlightLockedBackground();
@ -513,12 +523,12 @@ export function initBackgrounds() {
$('#add_bg_button').on('change', onBackgroundUploadSelected);
$('#bg-filter').on('input', onBackgroundFilterInput);
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'lockbg',
callback: onLockBackgroundClick,
callback: () => onLockBackgroundClick(new CustomEvent('click')),
aliases: ['bglock'],
helpString: 'Locks a background for the currently selected chat',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'unlockbg',
callback: onUnlockBackgroundClick,
callback: () => onUnlockBackgroundClick(new CustomEvent('click')),
aliases: ['bgunlock'],
helpString: 'Unlocks a background for the currently selected chat',
}));

View File

@ -69,6 +69,7 @@ const hash_derivations = {
// DeepSeek R1
'b6835114b7303ddd78919a82e4d9f7d8c26ed0d7dfc36beeb12d524f6144eab1':
'DeepSeek-V2.5'
,
};
const substr_derivations = {
@ -97,6 +98,6 @@ export async function deriveTemplatesFromChatTemplate(chat_template, hash) {
}
}
console.log(`Unknown chat template hash: ${hash} for [${chat_template}]`);
console.warn(`Unknown chat template hash: ${hash} for [${chat_template}]`);
return null;
}

View File

@ -45,6 +45,7 @@ import { DragAndDropHandler } from './dragdrop.js';
import { renderTemplateAsync } from './templates.js';
import { t } from './i18n.js';
import { humanizedDateTime } from './RossAscends-mods.js';
import { accountStorage } from './util/AccountStorage.js';
/**
* @typedef {Object} FileAttachment
@ -621,21 +622,56 @@ async function enlargeMessageImage() {
}
async function deleteMessageImage() {
const value = await callGenericPopup('<h3>Delete image from message?<br>This action can\'t be undone.</h3>', POPUP_TYPE.CONFIRM);
const value = await callGenericPopup('<h3>Delete image from message?<br>This action can\'t be undone.</h3>', POPUP_TYPE.TEXT, '', {
okButton: t`Delete one`,
customButtons: [
{
text: t`Delete all`,
appendAtEnd: true,
result: POPUP_RESULT.CUSTOM1,
},
{
text: t`Cancel`,
appendAtEnd: true,
result: POPUP_RESULT.CANCELLED,
},
],
});
if (value !== POPUP_RESULT.AFFIRMATIVE) {
if (!value) {
return;
}
const mesBlock = $(this).closest('.mes');
const mesId = mesBlock.attr('mesid');
const message = chat[mesId];
let isLastImage = true;
if (Array.isArray(message.extra.image_swipes)) {
const indexOf = message.extra.image_swipes.indexOf(message.extra.image);
if (indexOf > -1) {
message.extra.image_swipes.splice(indexOf, 1);
isLastImage = message.extra.image_swipes.length === 0;
if (!isLastImage) {
const newIndex = Math.min(indexOf, message.extra.image_swipes.length - 1);
message.extra.image = message.extra.image_swipes[newIndex];
}
}
}
if (isLastImage || value === POPUP_RESULT.CUSTOM1) {
delete message.extra.image;
delete message.extra.inline_image;
delete message.extra.title;
delete message.extra.append_title;
delete message.extra.image_swipes;
mesBlock.find('.mes_img_container').removeClass('img_extra');
mesBlock.find('.mes_img').attr('src', '');
} else {
appendMediaToMessage(message, mesBlock);
}
await saveChatConditional();
}
@ -1043,8 +1079,8 @@ async function openAttachmentManager() {
renderAttachments();
});
let sortField = localStorage.getItem('DataBank_sortField') || 'created';
let sortOrder = localStorage.getItem('DataBank_sortOrder') || 'desc';
let sortField = accountStorage.getItem('DataBank_sortField') || 'created';
let sortOrder = accountStorage.getItem('DataBank_sortOrder') || 'desc';
let filterString = '';
const template = $(await renderExtensionTemplateAsync('attachments', 'manager', {}));
@ -1060,8 +1096,8 @@ async function openAttachmentManager() {
sortField = this.selectedOptions[0].dataset.sortField;
sortOrder = this.selectedOptions[0].dataset.sortOrder;
localStorage.setItem('DataBank_sortField', sortField);
localStorage.setItem('DataBank_sortOrder', sortOrder);
accountStorage.setItem('DataBank_sortField', sortField);
accountStorage.setItem('DataBank_sortOrder', sortOrder);
renderAttachments();
});
function handleBulkAction(action) {
@ -1451,7 +1487,7 @@ jQuery(function () {
...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
];
download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json');
download(chatToSave.map((m) => JSON.stringify(m)).join('\n'), `Assistant - ${humanizedDateTime()}.jsonl`, 'application/json');
});
// Do not change. #attachFile is added by extension.

View File

@ -9,6 +9,7 @@ import { getContext } from './st-context.js';
import { isAdmin } from './user.js';
import { t } from './i18n.js';
import { debounce_timeout } from './constants.js';
import { accountStorage } from './util/AccountStorage.js';
export {
getContext,
@ -153,8 +154,18 @@ export const extension_settings = {
refine_mode: false,
},
expressions: {
/** @type {number} see `EXPRESSION_API` */
api: undefined,
/** @type {string[]} */
custom: [],
showDefault: false,
translate: false,
/** @type {string} */
fallback_expression: undefined,
/** @type {string} */
llmPrompt: undefined,
allowMultiple: true,
rerollIfSame: false,
},
connectionManager: {
selectedProfile: '',
@ -602,12 +613,12 @@ function generateExtensionHtml(name, manifest, isActive, isDisabled, isExternal,
}
let toggleElement = isActive || isDisabled ?
`<input type="checkbox" title="Click to toggle" data-name="${name}" class="${isActive ? 'toggle_disable' : 'toggle_enable'} ${checkboxClass}" ${isActive ? 'checked' : ''}>` :
'<input type="checkbox" title="' + t`Click to toggle` + `" data-name="${name}" class="${isActive ? 'toggle_disable' : 'toggle_enable'} ${checkboxClass}" ${isActive ? 'checked' : ''}>` :
`<input type="checkbox" title="Cannot enable extension" data-name="${name}" class="extension_missing ${checkboxClass}" disabled>`;
let deleteButton = isExternal ? `<button class="btn_delete menu_button" data-name="${externalId}" title="Delete"><i class="fa-fw fa-solid fa-trash-can"></i></button>` : '';
let deleteButton = isExternal ? `<button class="btn_delete menu_button" data-name="${externalId}" data-i18n="[title]Delete" title="Delete"><i class="fa-fw fa-solid fa-trash-can"></i></button>` : '';
let updateButton = isExternal ? `<button class="btn_update menu_button displayNone" data-name="${externalId}" title="Update available"><i class="fa-solid fa-download fa-fw"></i></button>` : '';
let moveButton = isExternal && isUserAdmin ? `<button class="btn_move menu_button" data-name="${externalId}" title="Move"><i class="fa-solid fa-folder-tree fa-fw"></i></button>` : '';
let moveButton = isExternal && isUserAdmin ? `<button class="btn_move menu_button" data-name="${externalId}" data-i18n="[title]Move" title="Move"><i class="fa-solid fa-folder-tree fa-fw"></i></button>` : '';
let modulesInfo = '';
if (isActive && Array.isArray(manifest.optional)) {
@ -615,7 +626,7 @@ function generateExtensionHtml(name, manifest, isActive, isDisabled, isExternal,
modules.forEach(x => optional.delete(x));
if (optional.size > 0) {
const optionalString = DOMPurify.sanitize([...optional].join(', '));
modulesInfo = `<div class="extension_modules">Optional modules: <span class="optional">${optionalString}</span></div>`;
modulesInfo = '<div class="extension_modules">' + t`Optional modules:` + ` <span class="optional">${optionalString}</span></div>`;
}
} else if (!isDisabled) { // Neither active nor disabled
const requirements = new Set(manifest.requires);
@ -714,7 +725,7 @@ async function showExtensionsDetails() {
htmlExternal.append(htmlLoading);
const sortOrderKey = 'extensions_sortByName';
const sortByName = localStorage.getItem(sortOrderKey) === 'true';
const sortByName = accountStorage.getItem(sortOrderKey) === 'true';
const sortFn = sortByName ? sortManifestsByName : sortManifestsByOrder;
const extensions = Object.entries(manifests).sort((a, b) => sortFn(a[1], b[1])).map(getExtensionData);
@ -745,7 +756,7 @@ async function showExtensionsDetails() {
text: sortByName ? t`Sort: Display Name` : t`Sort: Loading Order`,
action: async () => {
abortController.abort();
localStorage.setItem(sortOrderKey, sortByName ? 'false' : 'true');
accountStorage.setItem(sortOrderKey, sortByName ? 'false' : 'true');
await showExtensionsDetails();
},
};
@ -1153,11 +1164,11 @@ async function checkForExtensionUpdates(force) {
const currentDate = new Date().toDateString();
// Don't nag more than once a day
if (localStorage.getItem(STORAGE_NAG_KEY) === currentDate) {
if (accountStorage.getItem(STORAGE_NAG_KEY) === currentDate) {
return;
}
localStorage.setItem(STORAGE_NAG_KEY, currentDate);
accountStorage.setItem(STORAGE_NAG_KEY, currentDate);
}
const isCurrentUserAdmin = isAdmin();

View File

@ -8,7 +8,9 @@ import { getRequestHeaders, processDroppedFiles, eventSource, event_types } from
import { deleteExtension, extensionNames, getContext, installExtension, renderExtensionTemplateAsync } from '../../extensions.js';
import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
import { executeSlashCommands } from '../../slash-commands.js';
import { accountStorage } from '../../util/AccountStorage.js';
import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js';
import { t } from '../../i18n.js';
export { MODULE_NAME };
const MODULE_NAME = 'assets';
@ -58,11 +60,11 @@ const KNOWN_TYPES = {
'blip': 'Blip sounds',
};
function downloadAssetsList(url) {
updateCurrentAssets().then(function () {
async function downloadAssetsList(url) {
updateCurrentAssets().then(async function () {
fetch(url, { cache: 'no-cache' })
.then(response => response.json())
.then(json => {
.then(async function(json) {
availableAssets = {};
$('#assets_menu').empty();
@ -83,10 +85,10 @@ function downloadAssetsList(url) {
$('#assets_type_select').empty();
$('#assets_search').val('');
$('#assets_type_select').append($('<option />', { value: '', text: 'All' }));
$('#assets_type_select').append($('<option />', { value: '', text: t`All` }));
for (const type of assetTypes) {
const option = $('<option />', { value: type, text: KNOWN_TYPES[type] || type });
const option = $('<option />', { value: type, text: t([KNOWN_TYPES[type] || type]) });
$('#assets_type_select').append(option);
}
@ -103,11 +105,7 @@ function downloadAssetsList(url) {
assetTypeMenu.append(`<h3>${KNOWN_TYPES[assetType] || assetType}</h3>`).hide();
if (assetType == 'extension') {
assetTypeMenu.append(`
<div class="assets-list-git">
To download extensions from this page, you need to have <a href="https://git-scm.com/downloads" target="_blank">Git</a> installed.<br>
Click the <i class="fa-solid fa-sm fa-arrow-up-right-from-square"></i> icon to visit the Extension's repo for tips on how to use it.
</div>`);
assetTypeMenu.append(await renderExtensionTemplateAsync('assets', 'installation'));
}
for (const i in availableAssets[assetType].sort((a, b) => a?.name && b?.name && a['name'].localeCompare(b['name']))) {
@ -183,7 +181,7 @@ function downloadAssetsList(url) {
const displayName = DOMPurify.sanitize(asset['name'] || asset['id']);
const description = DOMPurify.sanitize(asset['description'] || '');
const url = isValidUrl(asset['url']) ? asset['url'] : '';
const title = assetType === 'extension' ? `Extension repo/guide: ${url}` : 'Preview in browser';
const title = assetType === 'extension' ? t`Extension repo/guide:` + ` ${url}` : t`Preview in browser`;
const previewIcon = (assetType === 'extension' || assetType === 'character') ? 'fa-arrow-up-right-from-square' : 'fa-headphones-simple';
const toolTag = assetType === 'extension' && asset['tool'];
@ -194,9 +192,10 @@ function downloadAssetsList(url) {
<b>${displayName}</b>
<a class="asset_preview" href="${url}" target="_blank" title="${title}">
<i class="fa-solid fa-sm ${previewIcon}"></i>
</a>
${toolTag ? '<span class="tag" title="Adds a function tool"><i class="fa-solid fa-sm fa-wrench"></i> Tool</span>' : ''}
</span>
</a>` +
(toolTag ? '<span class="tag" title="' + t`Adds a function tool` + '"><i class="fa-solid fa-sm fa-wrench"></i> ' +
t`Tool` + '</span>' : '') +
`</span>
<small class="asset-description">
${description}
</small>
@ -432,14 +431,14 @@ jQuery(async () => {
connectButton.on('click', async function () {
const url = DOMPurify.sanitize(String(assetsJsonUrl.val()));
const rememberKey = `Assets_SkipConfirm_${getStringHash(url)}`;
const skipConfirm = localStorage.getItem(rememberKey) === 'true';
const skipConfirm = accountStorage.getItem(rememberKey) === 'true';
const confirmation = skipConfirm || await Popup.show.confirm('Loading Asset List', `<span>Are you sure you want to connect to the following url?</span><var>${url}</var>`, {
const confirmation = skipConfirm || await Popup.show.confirm(t`Loading Asset List`, '<span>' + t`Are you sure you want to connect to the following url?` + `</span><var>${url}</var>`, {
customInputs: [{ id: 'assets-remember', label: 'Don\'t ask again for this URL' }],
onClose: popup => {
if (popup.result) {
const rememberValue = popup.inputResults.get('assets-remember');
localStorage.setItem(rememberKey, String(rememberValue));
accountStorage.setItem(rememberKey, String(rememberValue));
}
},
});

View File

@ -0,0 +1,4 @@
<div class="assets-list-git">
<span data-i18n="extension_install_1">To download extensions from this page, you need to have </span><a href="https://git-scm.com/downloads" target="_blank">Git</a><span data-i18n="extension_install_2"> installed.</span><br>
<span data-i18n="extension_install_3">Click the </span><i class="fa-solid fa-sm fa-arrow-up-right-from-square"></i><span data-i18n="extension_install_4"> icon to visit the Extension's repo for tips on how to use it.</span>
</div>

View File

@ -33,7 +33,7 @@ To install a single 3rd party extension, use the &quot;Install Extensions&quot;
<div id="assets_filters" class="flex-container">
<select id="assets_type_select" class="text_pole flex1">
</select>
<input id="assets_search" class="text_pole flex1" placeholder="Search" type="search">
<input id="assets_search" class="text_pole flex1" data-i18n="[placeholder]Search" placeholder="Search" type="search">
<div id="assets-characters-button" class="menu_button menu_button_icon">
<i class="fa-solid fa-image-portrait"></i>
<span data-i18n="Characters">Characters</span>

View File

@ -10,7 +10,7 @@
<select id="caption_source" class="text_pole">
<option value="local" data-i18n="Local">Local</option>
<option value="multimodal" data-i18n="Multimodal (OpenAI / Anthropic / llama / Google)">Multimodal (OpenAI / Anthropic / llama / Google)</option>
<option value="extras" data-i18n="Extras">Extras</option>
<option value="extras" data-i18n="Extras">Extras (deprecated)</option>
<option value="horde" data-i18n="Horde">Horde</option>
</select>
<div id="caption_multimodal_block" class="flex-container wide100p">
@ -53,6 +53,12 @@
<option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option>
<option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option>
<option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option>
<option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option>
<option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05</option>
<option data-type="google" value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option>
<option data-type="google" value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option>
<option data-type="google" value="gemini-2.0-flash">gemini-2.0-flash</option>
<option data-type="google" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option>
<option data-type="google" value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option>
<option data-type="google" value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp</option>
<option data-type="google" value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21</option>

View File

@ -30,6 +30,7 @@ const CC_COMMANDS = [
'api-url',
'model',
'proxy',
'stop-strings',
];
const TC_COMMANDS = [
@ -43,6 +44,7 @@ const TC_COMMANDS = [
'context',
'instruct-state',
'tokenizer',
'stop-strings',
];
const FANCY_NAMES = {
@ -57,6 +59,7 @@ const FANCY_NAMES = {
'instruct': 'Instruct Template',
'context': 'Context Template',
'tokenizer': 'Tokenizer',
'stop-strings': 'Custom Stopping Strings',
};
/**
@ -138,6 +141,7 @@ const profilesProvider = () => [
* @property {string} [context] Context Template
* @property {string} [instruct-state] Instruct Mode
* @property {string} [tokenizer] Tokenizer
* @property {string} [stop-strings] Custom Stopping Strings
* @property {string[]} [exclude] Commands to exclude
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
<div id="{{item}}" class="expression_list_item">
{{#each images}}
<div class="expression_list_item interactable" data-expression="{{../expression}}" data-expression-type="{{this.type}}" data-filename="{{this.fileName}}">
<div class="expression_list_buttons">
<div class="menu_button expression_list_upload" title="Upload image">
<i class="fa-solid fa-upload"></i>
@ -7,11 +8,14 @@
<i class="fa-solid fa-trash"></i>
</div>
</div>
<div class="expression_list_title {{textClass}}">
<span>{{item}}</span>
{{#if isCustom}}
<div class="expression_list_title">
<span>{{../expression}}</span>
{{#if ../isCustom}}
<small class="expression_list_custom">(custom)</small>
{{/if}}
</div>
<img class="expression_list_image" src="{{imageSrc}}" />
<div class="expression_list_image_container" title="{{this.title}}">
<img class="expression_list_image" src="{{this.imageSrc}}" alt="{{this.title}}" data-epression="{{../expression}}" />
</div>
</div>
{{/each}}

View File

@ -6,24 +6,24 @@
</div>
<div class="inline-drawer-content">
<label class="checkbox_label" for="expression_translate" title="Use the selected API from Chat Translation extension settings.">
<label class="checkbox_label" for="expression_translate" title="Use the selected API from Chat Translation extension settings." data-i18n="[title]Use the selected API from Chat Translation extension settings.">
<input id="expression_translate" type="checkbox">
<span data-i18n="Translate text to English before classification">Translate text to English before classification</span>
</label>
<label class="checkbox_label" for="expressions_show_default">
<input id="expressions_show_default" type="checkbox">
<span data-i18n="Show default images (emojis) if sprite missing">Show default images (emojis) if sprite missing</span>
<label class="checkbox_label" for="expressions_allow_multiple" title="A single expression can have multiple sprites. Whenever the expression is chosen, a random sprite for this expression will be selected." data-i18n="[title]A single expression can have multiple sprites. Whenever the expression is chosen, a random sprite for this expression will be selected.">
<input id="expressions_allow_multiple" type="checkbox">
<span data-i18n="Allow multiple sprites per expression">Allow multiple sprites per expression</span>
</label>
<label id="image_type_block" class="checkbox_label" for="image_type_toggle">
<input id="image_type_toggle" type="checkbox">
<span data-i18n="Image Type - talkinghead (extras)">Image Type - talkinghead (extras)</span>
<label class="checkbox_label" for="expressions_reroll_if_same" title="If the same expression is used again, re-roll the sprite. This only applies to expressions that have multiple available sprites assigned." data-i18n="[title]If the same expression is used again, re-roll the sprite. This only applies to expressions that have multiple available sprites assigned.">
<input id="expressions_reroll_if_same" type="checkbox">
<span data-i18n="Re-roll if same expression is used again">Re-roll if same sprite is used again</span>
</label>
<div class="expression_api_block m-b-1 m-t-1">
<label for="expression_api" data-i18n="Classifier API">Classifier API</label>
<small data-i18n="Select the API for classifying expressions.">Select the API for classifying expressions.</small>
<select id="expression_api" class="flex1 margin0">
<option value="0" data-i18n="Local">Local</option>
<option value="1" data-i18n="Extras">Extras</option>
<option value="1" data-i18n="Extras">Extras (deprecated)</option>
<option value="2" data-i18n="Main API">Main API</option>
<option value="3" data-i18n="WebLLM Extension">WebLLM Extension</option>
</select>
@ -75,8 +75,20 @@
<span data-i18n="Remove all image overrides">Remove all image overrides</span>
</div>
</div>
<p class="hint"><b data-i18n="Hint:">Hint:</b> <i><span data-i18n="Create new folder in the _space">Create new folder in the </span><b>/characters/</b> <span data-i18n="folder of your user data directory and name it as the name of the character.">folder of your user data directory and name it as the name of the character.</span>
<span data-i18n="Put images with expressions there. File names should follow the pattern:">Put images with expressions there. File names should follow the pattern: </span><tt data-i18n="expression_label_pattern">[expression_label].[image_format]</tt></i></p>
<p class="hint">
<b data-i18n="Hint:">Hint:</b>
<i>
<span data-i18n="Create new folder in the _space">Create new folder in the </span><b>/characters/</b> <span data-i18n="folder of your user data directory and name it as the name of the character.">folder of your user data directory and name it as the name of the character.</span>
<span data-i18n="Put images with expressions there. File names should follow the pattern:">Put images with expressions there. File names should follow the pattern: </span><tt data-i18n="expression_label_pattern">[expression_label].[image_format]</tt>
</i>
</p>
<p>
<i>
<span>In case of multiple files per expression, file names can contain a suffix, either separated by a dot or a
dash.
Examples: </span><tt>joy.png</tt>, <tt>joy-1.png</tt>, <tt>joy.expressive.png</tt>
</i>
</p>
<h3 id="image_list_header">
<strong data-i18n="Sprite set:">Sprite set:</strong>&nbsp;<span id="image_list_header_name"></span>
</h3>

View File

@ -111,6 +111,10 @@ img.expression.default {
justify-content: center;
}
.expression_list_image_container {
overflow: hidden;
}
.expression_list_title {
position: absolute;
bottom: 0;
@ -126,6 +130,9 @@ img.expression.default {
flex-direction: column;
line-height: 1;
}
.expression_list_custom {
font-size: 0.66rem;
}
.expression_list_buttons {
position: absolute;
@ -162,11 +169,24 @@ img.expression.default {
row-gap: 1rem;
}
#image_list .success {
#image_list .expression_list_item[data-expression-type="success"] .expression_list_title {
color: green;
}
#image_list .failure {
#image_list .expression_list_item[data-expression-type="additional"] .expression_list_title {
color: darkolivegreen;
}
#image_list .expression_list_item[data-expression-type="additional"] .expression_list_title::before {
content: '';
position: absolute;
top: -7px;
left: -9px;
font-size: 14px;
color: transparent;
text-shadow: 0 0 0 darkolivegreen;
}
#image_list .expression_list_item[data-expression-type="failure"] .expression_list_title {
color: red;
}
@ -189,3 +209,12 @@ img.expression.default {
flex-direction: row;
}
#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"],
#expressions_container:has(#expressions_allow_multiple:not(:checked)) label[for="expressions_reroll_if_same"] {
opacity: 0.3;
transition: opacity var(--animation-duration) ease;
}
#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"]:hover,
#expressions_container:has(#expressions_allow_multiple:not(:checked)) #image_list .expression_list_item[data-expression-type="additional"]:focus {
opacity: unset;
}

View File

@ -0,0 +1,12 @@
<div class="m-b-1" data-i18n="upload_expression_request">Please enter a name for the sprite (without extension).</div>
<div class="m-b-1" data-i18n="upload_expression_naming_1">
Sprite names must follow the naming schema for the selected expression: {{expression}}
</div>
<div data-i18n="upload_expression_naming_2">
For multiple expressions, the name must follow the expression name and a valid suffix. Allowed separators are '-' or dot '.'.
</div>
<span class="m-b-1" data-i18n="Examples:">Examples:</span> <tt>{{expression}}.png</tt>, <tt>{{expression}}-1.png</tt>, <tt>{{expression}}.expressive.png</tt>
{{#if clickedFileName}}
<div class="m-t-1" data-i18n="upload_expression_replace">Click 'Replace' to replace the existing expression:</div>
<tt>{{clickedFileName}}</tt>
{{/if}}

View File

@ -441,7 +441,6 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
description: 'character name',
typeList: [ARGUMENT_TYPE.STRING],
enumProvider: commonEnumProviders.characters('character'),
forceEnum: true,
}),
SlashCommandNamedArgument.fromProps({
name: 'group',

View File

@ -12,7 +12,7 @@
<label for="summary_source" data-i18n="ext_sum_with">Summarize with:</label>
<select id="summary_source">
<option value="main" data-i18n="ext_sum_main_api">Main API</option>
<option value="extras">Extras API</option>
<option value="extras">Extras API (deprecated)</option>
<option value="webllm" data-i18n="ext_sum_webllm">WebLLM Extension</option>
</select><br>

View File

@ -10,6 +10,7 @@ import { SlashCommandExecutor } from '../../../slash-commands/SlashCommandExecut
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
import { SlashCommandParserError } from '../../../slash-commands/SlashCommandParserError.js';
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
import { accountStorage } from '../../../util/AccountStorage.js';
import { debounce, delay, getSortableDelay, showFontAwesomePicker } from '../../../utils.js';
import { log, quickReplyApi, warn } from '../index.js';
import { QuickReplyContextLink } from './QuickReplyContextLink.js';
@ -544,9 +545,9 @@ export class QuickReply {
this.editorSyntax = messageSyntaxInner;
/**@type {HTMLInputElement}*/
const wrap = dom.querySelector('#qr--modal-wrap');
wrap.checked = JSON.parse(localStorage.getItem('qr--wrap') ?? 'false');
wrap.checked = JSON.parse(accountStorage.getItem('qr--wrap') ?? 'false');
wrap.addEventListener('click', () => {
localStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
accountStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
updateWrap();
});
const updateWrap = () => {
@ -594,27 +595,27 @@ export class QuickReply {
};
/**@type {HTMLInputElement}*/
const tabSize = dom.querySelector('#qr--modal-tabSize');
tabSize.value = JSON.parse(localStorage.getItem('qr--tabSize') ?? '4');
tabSize.value = JSON.parse(accountStorage.getItem('qr--tabSize') ?? '4');
const updateTabSize = () => {
message.style.tabSize = tabSize.value;
messageSyntaxInner.style.tabSize = tabSize.value;
updateScrollDebounced();
};
tabSize.addEventListener('change', () => {
localStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
accountStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
updateTabSize();
});
/**@type {HTMLInputElement}*/
const executeShortcut = dom.querySelector('#qr--modal-executeShortcut');
executeShortcut.checked = JSON.parse(localStorage.getItem('qr--executeShortcut') ?? 'true');
executeShortcut.checked = JSON.parse(accountStorage.getItem('qr--executeShortcut') ?? 'true');
executeShortcut.addEventListener('click', () => {
localStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
accountStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
});
/**@type {HTMLInputElement}*/
const syntax = dom.querySelector('#qr--modal-syntax');
syntax.checked = JSON.parse(localStorage.getItem('qr--syntax') ?? 'true');
syntax.checked = JSON.parse(accountStorage.getItem('qr--syntax') ?? 'true');
syntax.addEventListener('click', () => {
localStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
accountStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
updateSyntaxEnabled();
});
if (navigator.keyboard) {

View File

@ -1,15 +1,14 @@
import { getRequestHeaders, substituteParams } from '../../../../script.js';
import { Popup, POPUP_RESULT, POPUP_TYPE } from '../../../popup.js';
import { executeSlashCommands, executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
import { executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
import { debounceAsync, log, warn } from '../index.js';
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
import { debounceAsync, warn } from '../index.js';
import { QuickReply } from './QuickReply.js';
export class QuickReplySet {
/**@type {QuickReplySet[]}*/ static list = [];
static from(props) {
props.qrList = []; //props.qrList?.map(it=>QuickReply.from(it));
const instance = Object.assign(new this(), props);
@ -24,9 +23,6 @@ export class QuickReplySet {
return this.list.find(it=>it.name == name);
}
/**@type {string}*/ name;
/**@type {boolean}*/ disableSend = false;
/**@type {boolean}*/ placeBeforeInput = false;
@ -34,19 +30,12 @@ export class QuickReplySet {
/**@type {string}*/ color = 'transparent';
/**@type {boolean}*/ onlyBorderColor = false;
/**@type {QuickReply[]}*/ qrList = [];
/**@type {number}*/ idIndex = 0;
/**@type {boolean}*/ isDeleted = false;
/**@type {function}*/ save;
/**@type {HTMLElement}*/ dom;
/**@type {HTMLElement}*/ settingsDom;
constructor() {
this.save = debounceAsync(()=>this.performSave(), 200);
}
@ -55,9 +44,6 @@ export class QuickReplySet {
this.qrList.forEach(qr=>this.hookQuickReply(qr));
}
unrender() {
this.dom?.remove();
this.dom = null;
@ -100,9 +86,6 @@ export class QuickReplySet {
}
}
renderSettings() {
if (!this.settingsDom) {
this.settingsDom = document.createElement('div'); {
@ -123,9 +106,6 @@ export class QuickReplySet {
this.settingsDom.append(qr.renderSettings(idx));
}
/**
*
* @param {QuickReply} qr
@ -138,6 +118,7 @@ export class QuickReplySet {
closure.scope.setMacro('arg::*', '');
return (await closure.execute())?.pipe;
}
/**
*
* @param {QuickReply} qr The QR to execute.
@ -207,6 +188,7 @@ export class QuickReplySet {
document.querySelector('#send_but').click();
}
}
/**
* @param {QuickReply} qr
* @param {string} [message] - optional altered message to be used
@ -220,9 +202,6 @@ export class QuickReplySet {
});
}
addQuickReply(data = {}) {
const id = Math.max(this.idIndex, this.qrList.reduce((max,qr)=>Math.max(max,qr.id),0)) + 1;
data.id =
@ -239,6 +218,7 @@ export class QuickReplySet {
this.save();
return qr;
}
addQuickReplyFromText(qrJson) {
let data;
if (qrJson) {
@ -371,7 +351,6 @@ export class QuickReplySet {
this.save();
}
toJSON() {
return {
version: 2,
@ -386,7 +365,6 @@ export class QuickReplySet {
};
}
async performSave() {
const response = await fetch('/api/quick-replies/save', {
method: 'POST',

View File

@ -883,6 +883,10 @@ export class SlashCommandHandler {
}
}
getQuickReply(args) {
if (!args.id && !args.label) {
toastr.error('Please provide a valid id or label.');
return '';
}
try {
return JSON.stringify(this.api.getQrByLabel(args.set, args.id !== undefined ? Number(args.id) : args.label));
} catch (ex) {

View File

@ -346,7 +346,7 @@ export class SettingsUi {
}
async addQrSet() {
const name = await Popup.show.input('Create a new World Info', 'Enter a name for the new Quick Reply Set:');
const name = await Popup.show.input('Create a new Quick Reply Set', 'Enter a name for the new Quick Reply Set:');
if (name && name.length > 0) {
const oldQrs = QuickReplySet.get(name);
if (oldQrs) {

View File

@ -94,6 +94,12 @@
<span data-i18n="World Info">World Info</span>
</label>
</div>
<div data-i18n="[title]ext_regex_reasoning_desc" title="Reasoning block contents. When 'Only Format Prompt' is checked, it will also affect the reasoning contents added to the prompt.">
<label class="checkbox flex-container">
<input type="checkbox" name="replace_position" value="6">
<span data-i18n="Reasoning">Reasoning</span>
</label>
</div>
<div class="flex-container wide100p marginTop5">
<div class="flex1 flex-container flexNoGap">
<small data-i18n="[title]ext_regex_min_depth_desc" title="When applied to prompts or display, only affect messages that are at least N levels deep. 0 = last message, 1 = penultimate message, etc. Only counts WI entries @Depth and usable messages, i.e. not hidden or system.">

View File

@ -20,6 +20,7 @@ const regex_placement = {
SLASH_COMMAND: 3,
// 4 - sendAs (legacy)
WORLD_INFO: 5,
REASONING: 6,
};
export const substitute_find_regex = {
@ -94,7 +95,7 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown,
// Script applies to Generate and input is Generate
(script.promptOnly && isPrompt) ||
// Script applies to all cases when neither "only"s are true, but there's no need to do it when `isMarkdown`, the as source (chat history) should already be changed beforehand
(!script.markdownOnly && !script.promptOnly && !isMarkdown)
(!script.markdownOnly && !script.promptOnly && !isMarkdown && !isPrompt)
) {
if (isEdit && !script.runOnEdit) {
console.debug(`getRegexedString: Skipping script ${script.scriptName} because it does not run on edit`);

View File

@ -10,6 +10,7 @@ import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
import { download, getFileText, getSortableDelay, uuidv4 } from '../../utils.js';
import { regex_placement, runRegexScript, substitute_find_regex } from './engine.js';
import { t } from '../../i18n.js';
import { accountStorage } from '../../util/AccountStorage.js';
/**
* @typedef {object} RegexScript
@ -18,7 +19,7 @@ import { t } from '../../i18n.js';
* @property {string} replaceString - The replace string
* @property {string[]} trimStrings - The trim strings
* @property {string?} findRegex - The find regex
* @property {string?} substituteRegex - The substitute regex
* @property {number?} substituteRegex - The substitute regex
*/
/**
@ -440,8 +441,8 @@ async function checkEmbeddedRegexScripts() {
if (avatar && !extension_settings.character_allowed_regex.includes(avatar)) {
const checkKey = `AlertRegex_${characters[chid].avatar}`;
if (!localStorage.getItem(checkKey)) {
localStorage.setItem(checkKey, 'true');
if (!accountStorage.getItem(checkKey)) {
accountStorage.setItem(checkKey, 'true');
const template = await renderExtensionTemplateAsync('regex', 'embeddedScripts', {});
const result = await callGenericPopup(template, POPUP_TYPE.CONFIRM, '', { okButton: 'Yes' });

View File

@ -81,6 +81,7 @@ const sources = {
huggingface: 'huggingface',
nanogpt: 'nanogpt',
bfl: 'bfl',
falai: 'falai',
};
const initiators = {
@ -1169,6 +1170,10 @@ async function onBflKeyClick() {
return onApiKeyClick('BFL API Key:', SECRET_KEYS.BFL);
}
async function onFalaiKeyClick() {
return onApiKeyClick('FALAI API Key:', SECRET_KEYS.FALAI);
}
function onBflUpsamplingInput() {
extension_settings.sd.bfl_upsampling = !!$('#sd_bfl_upsampling').prop('checked');
saveSettingsDebounced();
@ -1299,6 +1304,7 @@ async function onModelChange() {
sources.huggingface,
sources.nanogpt,
sources.bfl,
sources.falai,
];
if (cloudSources.includes(extension_settings.sd.source)) {
@ -1707,6 +1713,9 @@ async function loadModels() {
case sources.bfl:
models = await loadBflModels();
break;
case sources.falai:
models = await loadFalaiModels();
break;
}
for (const model of models) {
@ -1744,6 +1753,21 @@ async function loadBflModels() {
];
}
async function loadFalaiModels() {
$('#sd_falai_key').toggleClass('success', !!secret_state[SECRET_KEYS.FALAI]);
const result = await fetch('/api/sd/falai/models', {
method: 'POST',
headers: getRequestHeaders(),
});
if (result.ok) {
return await result.json();
}
return [];
}
async function loadPollinationsModels() {
const result = await fetch('/api/sd/pollinations/models', {
method: 'POST',
@ -2081,6 +2105,9 @@ async function loadSchedulers() {
case sources.bfl:
schedulers = ['N/A'];
break;
case sources.falai:
schedulers = ['N/A'];
break;
}
for (const scheduler of schedulers) {
@ -2735,6 +2762,9 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
case sources.bfl:
result = await generateBflImage(prefixedPrompt, signal);
break;
case sources.falai:
result = await generateFalaiImage(prefixedPrompt, negativePrompt, signal);
break;
}
if (!result.data) {
@ -3496,6 +3526,40 @@ async function generateBflImage(prompt, signal) {
}
}
/**
* Generates an image using the FAL.AI API.
* @param {string} prompt - The main instruction used to guide the image generation.
* @param {string} negativePrompt - The negative prompt used to guide the image generation.
* @param {AbortSignal} signal - An AbortSignal object that can be used to cancel the request.
* @returns {Promise<{format: string, data: string}>} - A promise that resolves when the image generation and processing are complete.
*/
async function generateFalaiImage(prompt, negativePrompt, signal) {
const result = await fetch('/api/sd/falai/generate', {
method: 'POST',
headers: getRequestHeaders(),
signal: signal,
body: JSON.stringify({
prompt: prompt,
negative_prompt: negativePrompt,
model: extension_settings.sd.model,
steps: clamp(extension_settings.sd.steps, 1, 50),
guidance: clamp(extension_settings.sd.scale, 1.5, 5),
width: clamp(extension_settings.sd.width, 256, 1440),
height: clamp(extension_settings.sd.height, 256, 1440),
seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
}),
});
if (result.ok) {
const data = await result.json();
return { format: 'jpg', data: data.image };
} else {
const text = await result.text();
console.log(text);
throw new Error(text);
}
}
async function onComfyOpenWorkflowEditorClick() {
let workflow = await (await fetch('/api/sd/comfy/workflow', {
method: 'POST',
@ -3782,6 +3846,8 @@ function isValidState() {
return secret_state[SECRET_KEYS.NANOGPT];
case sources.bfl:
return secret_state[SECRET_KEYS.BFL];
case sources.falai:
return secret_state[SECRET_KEYS.FALAI];
}
}
@ -4443,6 +4509,7 @@ jQuery(async () => {
$('#sd_function_tool').on('input', onFunctionToolInput);
$('#sd_bfl_key').on('click', onBflKeyClick);
$('#sd_bfl_upsampling').on('input', onBflUpsamplingInput);
$('#sd_falai_key').on('click', onFalaiKeyClick);
if (!CSS.supports('field-sizing', 'content')) {
$('.sd_settings .inline-drawer-toggle').on('click', function () {

View File

@ -41,7 +41,8 @@
<option value="blockentropy">Block Entropy</option>
<option value="comfy">ComfyUI</option>
<option value="drawthings">DrawThings HTTP API</option>
<option value="extras">Extras API (local / remote)</option>
<option value="extras">Extras API (deprecated)</option>
<option value="falai">FAL.AI</option>
<option value="huggingface">HuggingFace Inference API (serverless)</option>
<option value="nanogpt">NanoGPT</option>
<option value="novel">NovelAI Diffusion</option>
@ -256,6 +257,20 @@
</label>
</div>
<div data-sd-source="falai">
<div class="flex-container flexnowrap alignItemsBaseline marginBot5">
<a href="https://fal.ai/dashboard" target="_blank" rel="noopener noreferrer">
<strong data-i18n="API Key">API Key</strong>
<i class="fa-solid fa-share-from-square"></i>
</a>
<span class="expander"></span>
<div id="sd_falai_key" class="menu_button menu_button_icon">
<i class="fa-fw fa-solid fa-key"></i>
<span data-i18n="Click to set">Click to set</span>
</div>
</div>
</div>
<div class="flex-container">
<div class="flex1">
<label for="sd_model" data-i18n="Model">Model</label>

View File

@ -6,6 +6,8 @@ import { getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, tokenizers
import { resetScrollHeight, debounce } from '../../utils.js';
import { debounce_timeout } from '../../constants.js';
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
import { renderExtensionTemplateAsync } from '../../extensions.js';
import { t } from '../../i18n.js';
function rgb2hex(rgb) {
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
@ -22,23 +24,7 @@ $('button').click(function () {
async function doTokenCounter() {
const { tokenizerName, tokenizerId } = getFriendlyTokenizerName(main_api);
const html = `
<div class="wide100p">
<h3>Token Counter</h3>
<div class="justifyLeft flex-container flexFlowColumn">
<h4>Type / paste in the box below to see the number of tokens in the text.</h4>
<p>Selected tokenizer: ${tokenizerName}</p>
<div>Input:</div>
<textarea id="token_counter_textarea" class="wide100p textarea_compact" rows="1"></textarea>
<div>Tokens: <span id="token_counter_result">0</span></div>
<hr>
<div>Tokenized text:</div>
<div id="tokenized_chunks_display" class="wide100p"></div>
<hr>
<div>Token IDs:</div>
<textarea id="token_counter_ids" class="wide100p textarea_compact" readonly rows="1"></textarea>
</div>
</div>`;
const html = await renderExtensionTemplateAsync('token-counter', 'window', {tokenizerName});
const dialog = $(html);
const countDebounced = debounce(async () => {
@ -131,9 +117,9 @@ async function doCount() {
jQuery(() => {
const buttonHtml = `
<div id="token_counter" class="list-group-item flex-container flexGap5">
<div class="fa-solid fa-1 extensionsMenuExtensionButton" /></div>
Token Counter
</div>`;
<div class="fa-solid fa-1 extensionsMenuExtensionButton" /></div>` +
t`Token Counter` +
'</div>';
$('#token_counter_wand_container').append(buttonHtml);
$('#token_counter').on('click', doTokenCounter);
SlashCommandParser.addCommandObject(SlashCommand.fromProps({

View File

@ -0,0 +1,16 @@
<div class="wide100p">
<h3 data-i18n="Token Counter">Token Counter</h3>
<div class="justifyLeft flex-container flexFlowColumn">
<h4 data-i18n="Type / paste in the box below to see the number of tokens in the text.">Type / paste in the box below to see the number of tokens in the text.</h4>
<p><span data-i18n="Selected tokenizer:">Selected tokenizer:</span> {{tokenizerName}}</p>
<div data-i18n="Input:">Input:</div>
<textarea id="token_counter_textarea" class="wide100p textarea_compact" rows="1"></textarea>
<div><span data-i18n="Tokens:">Tokens:</span> <span id="token_counter_result">0</span></div>
<hr>
<div data-i18n="Tokenized text:">Tokenized text:</div>
<div id="tokenized_chunks_display" class="wide100p"></div>
<hr>
<div data-i18n="Token IDs:">Token IDs:</div>
<textarea id="token_counter_ids" class="wide100p textarea_compact" readonly rows="1"></textarea>
</div>
</div>

View File

@ -605,7 +605,7 @@ const handleOutgoingMessage = createEventHandler(translateOutgoingMessage, () =>
const handleImpersonateReady = createEventHandler(translateImpersonate, () => shouldTranslate(incomingTypes));
const handleMessageEdit = createEventHandler(translateMessageEdit, () => true);
window['translate'] = translate;
globalThis.translate = translate;
jQuery(async () => {
const html = await renderExtensionTemplateAsync('translate', 'index');

View File

@ -388,7 +388,7 @@ class AllTalkTtsProvider {
}
async fetchRvcVoiceObjects() {
if (this.settings.server_version == 'v2') {
if (this.settings.server_version == 'v1') {
console.log('Skipping RVC voices fetch for V1 server');
return [];
}
@ -1031,14 +1031,18 @@ class AllTalkTtsProvider {
console.error('fetchTtsGeneration Error Response Text:', errorText);
throw new Error(`HTTP ${response.status}: ${errorText}`);
}
const data = await response.json();
// Handle V1/V2 URL differences
const outputUrl = this.settings.server_version === 'v1'
? data.output_file_url // V1 returns full URL
: `${this.settings.provider_endpoint}${data.output_file_url}`; // V2 returns relative path
// V1 returns a complete URL, V2 returns a relative path
if (this.settings.server_version === 'v1') {
// V1: Use the complete URL directly from the response
return data.output_file_url;
} else {
// V2: Combine the endpoint with the relative path
return `${this.settings.provider_endpoint}${data.output_file_url}`;
}
return outputUrl;
} catch (error) {
console.error('[fetchTtsGeneration] Exception caught:', error);
throw error;

View File

@ -27,13 +27,12 @@ import { SlashCommandEnumValue, enumTypes } from '../../slash-commands/SlashComm
import { enumIcons } from '../../slash-commands/SlashCommandCommonEnumsProvider.js';
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
import { GoogleTranslateTtsProvider } from './google-translate.js';
export { talkingAnimation };
const UPDATE_INTERVAL = 1000;
const wrapper = new ModuleWorkerWrapper(moduleWorker);
let voiceMapEntries = [];
let voiceMap = {}; // {charName:voiceid, charName2:voiceid2}
let talkingHeadState = false;
let lastChatId = null;
let lastMessage = null;
let lastMessageHash = null;
@ -120,7 +119,7 @@ async function onNarrateOneMessage() {
}
resetTtsPlayback();
ttsJobQueue.push(message);
processAndQueueTtsMessage(message);
moduleWorker();
}
@ -147,7 +146,7 @@ async function onNarrateText(args, text) {
}
resetTtsPlayback();
ttsJobQueue.push({ mes: text, name: name });
processAndQueueTtsMessage({ mes: text, name: name });
await moduleWorker();
// Return back to the chat voices
@ -165,27 +164,6 @@ async function moduleWorker() {
updateUiAudioPlayState();
}
function talkingAnimation(switchValue) {
if (!modules.includes('talkinghead')) {
console.debug('Talking Animation module not loaded');
return;
}
const apiUrl = getApiUrl();
const animationType = switchValue ? 'start' : 'stop';
if (switchValue !== talkingHeadState) {
try {
console.log(animationType + ' Talking Animation');
doExtrasFetch(`${apiUrl}/api/talkinghead/${animationType}_talking`);
talkingHeadState = switchValue;
} catch (error) {
// Handle the error here or simply ignore it to prevent logging
}
}
updateUiAudioPlayState();
}
function resetTtsPlayback() {
// Stop system TTS utterance
cancelTtsPlay();
@ -220,6 +198,36 @@ function isTtsProcessing() {
return processing;
}
/**
* Splits a message into lines and adds each non-empty line to the TTS job queue.
* @param {Object} message - The message object to be processed.
* @param {string} message.mes - The text of the message to be split into lines.
* @param {string} message.name - The name associated with the message.
* @returns {void}
*/
function processAndQueueTtsMessage(message) {
if (!extension_settings.tts.narrate_by_paragraphs) {
ttsJobQueue.push(message);
return;
}
const lines = message.mes.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.length === 0) {
continue;
}
ttsJobQueue.push(
Object.assign({}, message, {
mes: line,
}),
);
}
}
function debugTtsPlayback() {
console.log(JSON.stringify(
{
@ -347,10 +355,9 @@ function onAudioControlClicked() {
// Not pausing, doing a full stop to anything TTS is doing. Better UX as pause is not as useful
if (!audioElement.paused || isTtsProcessing()) {
resetTtsPlayback();
talkingAnimation(false);
} else {
// Default play behavior if not processing or playing is to play the last message.
ttsJobQueue.push(context.chat[context.chat.length - 1]);
processAndQueueTtsMessage(context.chat[context.chat.length - 1]);
}
updateUiAudioPlayState();
}
@ -374,8 +381,8 @@ function addAudioControl() {
function completeCurrentAudioJob() {
audioQueueProcessorReady = true;
currentAudioJob = null;
talkingAnimation(false); //stop lip animation
// updateUiPlayState();
wrapper.update();
}
/**
@ -404,7 +411,6 @@ async function processAudioJobQueue() {
audioQueueProcessorReady = false;
currentAudioJob = audioJobQueue.shift();
playAudioData(currentAudioJob);
talkingAnimation(true);
} catch (error) {
toastr.error(error.toString());
console.error(error);
@ -569,6 +575,7 @@ function loadSettings() {
$('#tts_narrate_quoted').prop('checked', extension_settings.tts.narrate_quoted_only);
$('#tts_auto_generation').prop('checked', extension_settings.tts.auto_generation);
$('#tts_periodic_auto_generation').prop('checked', extension_settings.tts.periodic_auto_generation);
$('#tts_narrate_by_paragraphs').prop('checked', extension_settings.tts.narrate_by_paragraphs);
$('#tts_narrate_translated_only').prop('checked', extension_settings.tts.narrate_translated_only);
$('#tts_narrate_user').prop('checked', extension_settings.tts.narrate_user);
$('#tts_pass_asterisks').prop('checked', extension_settings.tts.pass_asterisks);
@ -638,6 +645,11 @@ function onPeriodicAutoGenerationClick() {
saveSettingsDebounced();
}
function onNarrateByParagraphsClick() {
extension_settings.tts.narrate_by_paragraphs = !!$('#tts_narrate_by_paragraphs').prop('checked');
saveSettingsDebounced();
}
function onNarrateDialoguesClick() {
extension_settings.tts.narrate_dialogues_only = !!$('#tts_narrate_dialogues').prop('checked');
@ -816,7 +828,12 @@ async function onMessageEvent(messageId, lastCharIndex) {
lastChatId = context.chatId;
console.debug(`Adding message from ${message.name} for TTS processing: "${message.mes}"`);
if (extension_settings.tts.periodic_auto_generation) {
ttsJobQueue.push(message);
} else {
processAndQueueTtsMessage(message);
}
}
async function onMessageDeleted() {
@ -1156,6 +1173,7 @@ jQuery(async function () {
$('#tts_pass_asterisks').on('click', onPassAsterisksClick);
$('#tts_auto_generation').on('click', onAutoGenerationClick);
$('#tts_periodic_auto_generation').on('click', onPeriodicAutoGenerationClick);
$('#tts_narrate_by_paragraphs').on('click', onNarrateByParagraphsClick);
$('#tts_narrate_user').on('click', onNarrateUserClick);
$('#playback_rate').on('input', function () {
@ -1177,7 +1195,6 @@ jQuery(async function () {
loadSettings(); // Depends on Extension Controls and loadTtsProvider
loadTtsProvider(extension_settings.tts.currentProvider); // No dependencies
addAudioControl(); // Depends on Extension Controls
const wrapper = new ModuleWorkerWrapper(moduleWorker);
setInterval(wrapper.update.bind(wrapper), UPDATE_INTERVAL); // Init depends on all the things
eventSource.on(event_types.MESSAGE_SWIPED, resetTtsPlayback);
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);

View File

@ -25,7 +25,7 @@ class OpenAICompatibleTtsProvider {
<label for="openai_compatible_tts_endpoint">Provider Endpoint:</label>
<div class="flex-container alignItemsCenter">
<div class="flex1">
<input id="openai_compatible_tts_endpoint" type="text" class="text_pole" maxlength="250" value="${this.defaultSettings.provider_endpoint}"/>
<input id="openai_compatible_tts_endpoint" type="text" class="text_pole" maxlength="500" value="${this.defaultSettings.provider_endpoint}"/>
</div>
<div id="openai_compatible_tts_key" class="menu_button menu_button_icon">
<i class="fa-solid fa-key"></i>
@ -33,9 +33,9 @@ class OpenAICompatibleTtsProvider {
</div>
</div>
<label for="openai_compatible_model">Model:</label>
<input id="openai_compatible_model" type="text" class="text_pole" maxlength="250" value="${this.defaultSettings.model}"/>
<input id="openai_compatible_model" type="text" class="text_pole" maxlength="500" value="${this.defaultSettings.model}"/>
<label for="openai_compatible_tts_voices">Available Voices (comma separated):</label>
<input id="openai_compatible_tts_voices" type="text" class="text_pole" maxlength="250" value="${this.defaultSettings.available_voices.join()}"/>
<input id="openai_compatible_tts_voices" type="text" class="text_pole" value="${this.defaultSettings.available_voices.join()}"/>
<label for="openai_compatible_tts_speed">Speed: <span id="openai_compatible_tts_speed_output"></span></label>
<input type="range" id="openai_compatible_tts_speed" value="1" min="0.25" max="4" step="0.05">`;
return html;

View File

@ -30,6 +30,10 @@
<input type="checkbox" id="tts_periodic_auto_generation">
<small data-i18n="Narrate by paragraphs (when streaming)">Narrate by paragraphs (when streaming)</small>
</label>
<label class="checkbox_label" for="tts_narrate_by_paragraphs">
<input type="checkbox" id="tts_narrate_by_paragraphs">
<small data-i18n="Narrate by paragraphs (when not streaming)">Narrate by paragraphs (when not streaming)</small>
</label>
<label class="checkbox_label" for="tts_narrate_quoted">
<input type="checkbox" id="tts_narrate_quoted">
<small data-i18n="Only narrate quotes">Only narrate "quotes"</small>

View File

@ -1,6 +1,5 @@
import { isMobile } from '../../RossAscends-mods.js';
import { getPreviewString } from './index.js';
import { talkingAnimation } from './index.js';
import { saveTtsProviderSettings } from './index.js';
export { SystemTtsProvider };
@ -70,7 +69,6 @@ var speechUtteranceChunker = function (utt, settings, callback) {
//placing the speak invocation inside a callback fixes ordering and onend issues.
setTimeout(function () {
speechSynthesis.speak(newUtt);
talkingAnimation(true);
}, 0);
};
@ -240,7 +238,6 @@ class SystemTtsProvider {
//some code to execute when done
resolve(silence);
console.log('System TTS done');
talkingAnimation(false);
});
});
}

View File

@ -561,9 +561,9 @@ async function retrieveFileChunks(queryText, collectionId) {
*/
async function vectorizeFile(fileText, fileName, collectionId, chunkSize, overlapPercent) {
try {
if (settings.translate_files && typeof window['translate'] === 'function') {
if (settings.translate_files && typeof globalThis.translate === 'function') {
console.log(`Vectors: Translating file ${fileName} to English...`);
const translatedText = await window['translate'](fileText, 'en');
const translatedText = await globalThis.translate(fileText, 'en');
fileText = translatedText;
}
@ -745,6 +745,44 @@ async function getQueryText(chat, initiator) {
return collapseNewlines(queryText).trim();
}
/**
* Gets common body parameters for vector requests.
* @returns {object}
*/
function getVectorsRequestBody() {
const body = {};
switch (settings.source) {
case 'extras':
body.extrasUrl = extension_settings.apiUrl;
body.extrasKey = extension_settings.apiKey;
break;
case 'togetherai':
body.model = extension_settings.vectors.togetherai_model;
break;
case 'openai':
body.model = extension_settings.vectors.openai_model;
break;
case 'cohere':
body.model = extension_settings.vectors.cohere_model;
break;
case 'ollama':
body.model = extension_settings.vectors.ollama_model;
body.apiUrl = textgenerationwebui_settings.server_urls[textgen_types.OLLAMA];
body.keep = !!extension_settings.vectors.ollama_keep;
break;
case 'llamacpp':
body.apiUrl = textgenerationwebui_settings.server_urls[textgen_types.LLAMACPP];
break;
case 'vllm':
body.apiUrl = textgenerationwebui_settings.server_urls[textgen_types.VLLM];
body.model = extension_settings.vectors.vllm_model;
break;
default:
break;
}
return body;
}
/**
* Gets the saved hashes for a collection
* @param {string} collectionId
@ -753,8 +791,9 @@ async function getQueryText(chat, initiator) {
async function getSavedHashes(collectionId) {
const response = await fetch('/api/vector/list', {
method: 'POST',
headers: getVectorHeaders(),
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
source: settings.source,
}),
@ -768,54 +807,6 @@ async function getSavedHashes(collectionId) {
return hashes;
}
function getVectorHeaders() {
const headers = getRequestHeaders();
switch (settings.source) {
case 'extras':
Object.assign(headers, {
'X-Extras-Url': extension_settings.apiUrl,
'X-Extras-Key': extension_settings.apiKey,
});
break;
case 'togetherai':
Object.assign(headers, {
'X-Togetherai-Model': extension_settings.vectors.togetherai_model,
});
break;
case 'openai':
Object.assign(headers, {
'X-OpenAI-Model': extension_settings.vectors.openai_model,
});
break;
case 'cohere':
Object.assign(headers, {
'X-Cohere-Model': extension_settings.vectors.cohere_model,
});
break;
case 'ollama':
Object.assign(headers, {
'X-Ollama-Model': extension_settings.vectors.ollama_model,
'X-Ollama-URL': textgenerationwebui_settings.server_urls[textgen_types.OLLAMA],
'X-Ollama-Keep': !!extension_settings.vectors.ollama_keep,
});
break;
case 'llamacpp':
Object.assign(headers, {
'X-LlamaCpp-URL': textgenerationwebui_settings.server_urls[textgen_types.LLAMACPP],
});
break;
case 'vllm':
Object.assign(headers, {
'X-Vllm-URL': textgenerationwebui_settings.server_urls[textgen_types.VLLM],
'X-Vllm-Model': extension_settings.vectors.vllm_model,
});
break;
default:
break;
}
return headers;
}
/**
* Inserts vector items into a collection
* @param {string} collectionId - The collection to insert into
@ -825,12 +816,11 @@ function getVectorHeaders() {
async function insertVectorItems(collectionId, items) {
throwIfSourceInvalid();
const headers = getVectorHeaders();
const response = await fetch('/api/vector/insert', {
method: 'POST',
headers: headers,
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
items: items,
source: settings.source,
@ -879,8 +869,9 @@ function throwIfSourceInvalid() {
async function deleteVectorItems(collectionId, hashes) {
const response = await fetch('/api/vector/delete', {
method: 'POST',
headers: getVectorHeaders(),
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
hashes: hashes,
source: settings.source,
@ -899,12 +890,11 @@ async function deleteVectorItems(collectionId, hashes) {
* @returns {Promise<{ hashes: number[], metadata: object[]}>} - Hashes of the results
*/
async function queryCollection(collectionId, searchText, topK) {
const headers = getVectorHeaders();
const response = await fetch('/api/vector/query', {
method: 'POST',
headers: headers,
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
searchText: searchText,
topK: topK,
@ -929,12 +919,11 @@ async function queryCollection(collectionId, searchText, topK) {
* @returns {Promise<Record<string, { hashes: number[], metadata: object[] }>>} - Results mapped to collection IDs
*/
async function queryMultipleCollections(collectionIds, searchText, topK, threshold) {
const headers = getVectorHeaders();
const response = await fetch('/api/vector/query-multi', {
method: 'POST',
headers: headers,
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionIds: collectionIds,
searchText: searchText,
topK: topK,
@ -965,8 +954,9 @@ async function purgeFileVectorIndex(fileUrl) {
const response = await fetch('/api/vector/purge', {
method: 'POST',
headers: getVectorHeaders(),
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
}),
});
@ -994,8 +984,9 @@ async function purgeVectorIndex(collectionId) {
const response = await fetch('/api/vector/purge', {
method: 'POST',
headers: getVectorHeaders(),
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
collectionId: collectionId,
}),
});
@ -1019,7 +1010,10 @@ async function purgeAllVectorIndexes() {
try {
const response = await fetch('/api/vector/purge-all', {
method: 'POST',
headers: getVectorHeaders(),
headers: getRequestHeaders(),
body: JSON.stringify({
...getVectorsRequestBody(),
}),
});
if (!response.ok) {
@ -1638,14 +1632,12 @@ jQuery(async () => {
}
return textResult;
};
if (args.return === 'chunks') {
return getChunksText();
}
// @ts-ignore
return slashCommandReturnHelper.doReturn(args.return ?? 'object', urls, { objectToStringFunc: list => list.join('\n') });
},
aliases: ['databank-search', 'data-bank-search'],
helpString: 'Search the Data Bank for a specific query using vector similarity. Returns a list of file URLs with the most relevant content.',
@ -1660,10 +1652,10 @@ jQuery(async () => {
defaultValue: 'object',
enumList: [
new SlashCommandEnumValue('chunks', 'Return the actual content chunks', enumTypes.enum, '{}'),
...slashCommandReturnHelper.enumList({ allowObject: true })
...slashCommandReturnHelper.enumList({ allowObject: true }),
],
forceEnum: true,
})
}),
],
unnamedArgumentList: [
new SlashCommandArgument('Query to search by.', ARGUMENT_TYPE.STRING, true, false),

View File

@ -11,7 +11,7 @@
</label>
<select id="vectors_source" class="text_pole">
<option value="cohere">Cohere</option>
<option value="extras">Extras</option>
<option value="extras">Extras (deprecated)</option>
<option value="palm">Google AI Studio</option>
<option value="llamacpp">llama.cpp</option>
<option value="transformers" data-i18n="Local (Transformers)">Local (Transformers)</option>

View File

@ -1,18 +1,30 @@
////////////////// LOCAL STORAGE HANDLING /////////////////////
/**
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
*/
export function SaveLocal(target, val) {
localStorage.setItem(target, val);
console.debug('SaveLocal -- ' + target + ' : ' + val);
}
/**
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
*/
export function LoadLocal(target) {
console.debug('LoadLocal -- ' + target);
return localStorage.getItem(target);
}
/**
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
*/
export function LoadLocalBool(target) {
let result = localStorage.getItem(target) === 'true';
return result;
}
/**
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
*/
export function CheckLocal() {
console.log('----------local storage---------');
var i;
@ -22,6 +34,9 @@ export function CheckLocal() {
console.log('------------------------------');
}
/**
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
*/
export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); }
/////////////////////////////////////////////////////////////////////////

View File

@ -78,6 +78,7 @@ import { FILTER_TYPES, FilterHelper } from './filters.js';
import { isExternalMediaAllowed } from './chats.js';
import { POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
import { t } from './i18n.js';
import { accountStorage } from './util/AccountStorage.js';
export {
selected_group,
@ -292,10 +293,11 @@ export function getGroupNames() {
/**
* Finds the character ID for a group member.
* @param {string} arg 0-based member index or character name
* @returns {number} 0-based character ID
* @param {number|string} arg 0-based member index or character name
* @param {Boolean} full Whether to return a key-value object containing extra data
* @returns {number|Object} 0-based character ID or key-value object if full is true
*/
export function findGroupMemberId(arg) {
export function findGroupMemberId(arg, full = false) {
arg = arg?.trim();
if (!arg) {
@ -311,15 +313,19 @@ export function findGroupMemberId(arg) {
}
const index = parseInt(arg);
const searchByName = isNaN(index);
const searchByString = isNaN(index);
if (searchByName) {
const memberNames = group.members.map(x => ({ name: characters.find(y => y.avatar === x)?.name, index: characters.findIndex(y => y.avatar === x) }));
const fuse = new Fuse(memberNames, { keys: ['name'] });
if (searchByString) {
const memberNames = group.members.map(x => ({
avatar: x,
name: characters.find(y => y.avatar === x)?.name,
index: characters.findIndex(y => y.avatar === x),
}));
const fuse = new Fuse(memberNames, { keys: ['avatar', 'name'] });
const result = fuse.search(arg);
if (!result.length) {
console.warn(`WARN: No group member found with name ${arg}`);
console.warn(`WARN: No group member found using string ${arg}`);
return;
}
@ -330,9 +336,11 @@ export function findGroupMemberId(arg) {
return;
}
console.log(`Triggering group member ${chid} (${arg}) from search result`, result[0]);
return chid;
} else {
console.log(`Targeting group member ${chid} (${arg}) from search result`, result[0]);
return !full ? chid : { ...{ id: chid }, ...result[0].item };
}
else {
const memberAvatar = group.members[index];
if (memberAvatar === undefined) {
@ -347,8 +355,14 @@ export function findGroupMemberId(arg) {
return;
}
console.log(`Triggering group member ${memberAvatar} at index ${index}`);
return chid;
console.log(`Targeting group member ${memberAvatar} at index ${index}`);
return !full ? chid : {
id: chid,
avatar: memberAvatar,
name: characters.find(y => y.avatar === memberAvatar)?.name,
index: index,
};
}
}
@ -805,7 +819,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
/** @type {any} Caution: JS war crimes ahead */
let textResult = '';
let typingIndicator = $('#chat .typing_indicator');
const group = groups.find((x) => x.id === selected_group);
if (!group || !Array.isArray(group.members) || !group.members.length) {
@ -821,14 +834,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
setCharacterId(undefined);
const userInput = String($('#send_textarea').val());
if (typingIndicator.length === 0 && !isStreamingEnabled()) {
typingIndicator = $(
'#typing_indicator_template .typing_indicator',
).clone();
typingIndicator.hide();
$('#chat').append(typingIndicator);
}
// id of this specific batch for regeneration purposes
group_generation_id = Date.now();
const lastMessage = chat[chat.length - 1];
@ -906,14 +911,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
}
await eventSource.emit(event_types.GROUP_MEMBER_DRAFTED, chId);
if (type !== 'swipe' && type !== 'impersonate' && !isStreamingEnabled()) {
// update indicator and scroll down
typingIndicator
.find('.typing_indicator_name')
.text(characters[chId].name);
typingIndicator.show();
}
// Wait for generation to finish
textResult = await Generate(generateType, { automatic_trigger: by_auto_mode, ...(params || {}) });
let messageChunk = textResult?.messageChunk;
@ -930,8 +927,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
}
}
} finally {
typingIndicator.hide();
is_group_generating = false;
setSendButtonState(false);
setCharacterId(undefined);
@ -1315,10 +1310,10 @@ function printGroupCandidates() {
formatNavigator: PAGINATION_TEMPLATE,
showNavigator: true,
showSizeChanger: true,
pageSize: Number(localStorage.getItem(storageKey)) || 5,
pageSize: Number(accountStorage.getItem(storageKey)) || 5,
sizeChangerOptions: [5, 10, 25, 50, 100, 200, 500, 1000],
afterSizeSelectorChange: function (e) {
localStorage.setItem(storageKey, e.target.value);
accountStorage.setItem(storageKey, e.target.value);
},
callback: function (data) {
$('#rm_group_add_members').empty();
@ -1342,10 +1337,10 @@ function printGroupMembers() {
formatNavigator: PAGINATION_TEMPLATE,
showNavigator: true,
showSizeChanger: true,
pageSize: Number(localStorage.getItem(storageKey)) || 5,
pageSize: Number(accountStorage.getItem(storageKey)) || 5,
sizeChangerOptions: [5, 10, 25, 50, 100, 200, 500, 1000],
afterSizeSelectorChange: function (e) {
localStorage.setItem(storageKey, e.target.value);
accountStorage.setItem(storageKey, e.target.value);
},
callback: function (data) {
$('.rm_group_members').empty();
@ -1669,12 +1664,12 @@ function updateFavButtonState(state) {
export async function openGroupById(groupId) {
if (isChatSaving) {
toastr.info(t`Please wait until the chat is saved before switching characters.`, t`Your chat is still saving...`);
return;
return false;
}
if (!groups.find(x => x.id === groupId)) {
console.log('Group not found', groupId);
return;
return false;
}
if (!is_send_press && !is_group_generating) {
@ -1691,8 +1686,11 @@ export async function openGroupById(groupId) {
updateChatMetadata({}, true);
chat.length = 0;
await getGroupChat(groupId);
return true;
}
}
return false;
}
function openCharacterDefinition(characterSelect) {

View File

@ -27,21 +27,42 @@ export async function hideLoader() {
}
return new Promise((resolve) => {
// Spinner blurs/fades out
$('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
const spinner = $('#load-spinner');
if (!spinner.length) {
console.warn('Spinner element not found, skipping animation');
cleanup();
return;
}
// Check if transitions are enabled
const transitionDuration = spinner[0] ? getComputedStyle(spinner[0]).transitionDuration : '0s';
const hasTransitions = parseFloat(transitionDuration) > 0;
if (hasTransitions) {
Promise.race([
new Promise((r) => setTimeout(r, 500)), // Fallback timeout
new Promise((r) => spinner.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', r)),
]).finally(cleanup);
} else {
cleanup();
}
function cleanup() {
$('#loader').remove();
// Yoink preloader entirely; it only exists to cover up unstyled content while loading JS
// If it's present, we remove it once and then it's gone.
yoinkPreloader();
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE).then(() => {
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE)
.catch((err) => console.error('Error completing loaderPopup:', err))
.finally(() => {
loaderPopup = null;
resolve();
});
});
}
$('#load-spinner')
.css({
// Apply the styles
spinner.css({
'filter': 'blur(15px)',
'opacity': '0',
});

View File

@ -73,6 +73,7 @@ import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js
import { Popup, POPUP_RESULT } from './popup.js';
import { t } from './i18n.js';
import { ToolManager } from './tool-calling.js';
import { accountStorage } from './util/AccountStorage.js';
export {
openai_messages_count,
@ -82,7 +83,6 @@ export {
setOpenAIMessageExamples,
setupChatCompletionPromptManager,
sendOpenAIRequest,
getChatCompletionModel,
TokenHandler,
IdentifierNotFoundError,
Message,
@ -258,8 +258,8 @@ const default_settings = {
ai21_model: 'jamba-1.5-large',
mistralai_model: 'mistral-large-latest',
cohere_model: 'command-r-plus',
perplexity_model: 'llama-3.1-70b-instruct',
groq_model: 'llama-3.1-70b-versatile',
perplexity_model: 'sonar-pro',
groq_model: 'llama-3.3-70b-versatile',
nanogpt_model: 'gpt-4o-mini',
zerooneai_model: 'yi-large',
blockentropy_model: 'be-70b-base-llama3.1',
@ -298,7 +298,8 @@ const default_settings = {
names_behavior: character_names_behavior.DEFAULT,
continue_postfix: continue_postfix_types.SPACE,
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
show_thoughts: false,
show_thoughts: true,
reasoning_effort: 'medium',
seed: -1,
n: 1,
};
@ -337,7 +338,7 @@ const oai_settings = {
ai21_model: 'jamba-1.5-large',
mistralai_model: 'mistral-large-latest',
cohere_model: 'command-r-plus',
perplexity_model: 'llama-3.1-70b-instruct',
perplexity_model: 'sonar-pro',
groq_model: 'llama-3.1-70b-versatile',
nanogpt_model: 'gpt-4o-mini',
zerooneai_model: 'yi-large',
@ -377,7 +378,8 @@ const oai_settings = {
names_behavior: character_names_behavior.DEFAULT,
continue_postfix: continue_postfix_types.SPACE,
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
show_thoughts: false,
show_thoughts: true,
reasoning_effort: 'medium',
seed: -1,
n: 1,
};
@ -412,7 +414,7 @@ async function validateReverseProxy() {
throw err;
}
const rememberKey = `Proxy_SkipConfirm_${getStringHash(oai_settings.reverse_proxy)}`;
const skipConfirm = localStorage.getItem(rememberKey) === 'true';
const skipConfirm = accountStorage.getItem(rememberKey) === 'true';
const confirmation = skipConfirm || await Popup.show.confirm(t`Connecting To Proxy`, await renderTemplateAsync('proxyConnectionWarning', { proxyURL: DOMPurify.sanitize(oai_settings.reverse_proxy) }));
@ -423,7 +425,7 @@ async function validateReverseProxy() {
throw new Error('Proxy connection denied.');
}
localStorage.setItem(rememberKey, String(true));
accountStorage.setItem(rememberKey, String(true));
}
/**
@ -1443,9 +1445,7 @@ async function sendWindowAIRequest(messages, signal, stream) {
}
const onStreamResult = (res, err) => {
if (err) {
return;
}
if (err) return;
const thisContent = res?.message?.content;
@ -1497,7 +1497,7 @@ async function sendWindowAIRequest(messages, signal, stream) {
}
}
function getChatCompletionModel() {
export function getChatCompletionModel() {
switch (oai_settings.chat_completion_source) {
case chat_completion_sources.CLAUDE:
return oai_settings.claude_model;
@ -1869,7 +1869,7 @@ async function sendOpenAIRequest(type, messages, signal) {
const isQuiet = type === 'quiet';
const isImpersonate = type === 'impersonate';
const isContinue = type === 'continue';
const stream = oai_settings.stream_openai && !isQuiet && !isScale && !(isGoogle && oai_settings.google_model.includes('bison')) && !(isOAI && oai_settings.openai_model.startsWith('o1-'));
const stream = oai_settings.stream_openai && !isQuiet && !isScale && !(isOAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model));
const useLogprobs = !!power_user.request_token_probabilities;
const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom);
@ -1913,9 +1913,14 @@ async function sendOpenAIRequest(type, messages, signal) {
'user_name': name1,
'char_name': name2,
'group_names': getGroupNames(),
'show_thoughts': Boolean(oai_settings.show_thoughts),
'include_reasoning': Boolean(oai_settings.show_thoughts),
'reasoning_effort': String(oai_settings.reasoning_effort),
};
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
await ToolManager.registerFunctionToolsOpenAI(generate_data);
}
// Empty array will produce a validation error
if (!Array.isArray(generate_data.stop) || !generate_data.stop.length) {
delete generate_data.stop;
@ -2039,6 +2044,8 @@ async function sendOpenAIRequest(type, messages, signal) {
delete generate_data.top_logprobs;
delete generate_data.logprobs;
delete generate_data.logit_bias;
delete generate_data.tools;
delete generate_data.tool_choice;
}
}
@ -2046,11 +2053,7 @@ async function sendOpenAIRequest(type, messages, signal) {
generate_data['seed'] = oai_settings.seed;
}
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
await ToolManager.registerFunctionToolsOpenAI(generate_data);
}
if (isOAI && oai_settings.openai_model.startsWith('o1-')) {
if (isOAI && (oai_settings.openai_model.startsWith('o1') || oai_settings.openai_model.startsWith('o3'))) {
generate_data.messages.forEach((msg) => {
if (msg.role === 'system') {
msg.role = 'user';
@ -2058,7 +2061,6 @@ async function sendOpenAIRequest(type, messages, signal) {
});
generate_data.max_completion_tokens = generate_data.max_tokens;
delete generate_data.max_tokens;
delete generate_data.stream;
delete generate_data.logprobs;
delete generate_data.top_logprobs;
delete generate_data.n;
@ -2069,8 +2071,7 @@ async function sendOpenAIRequest(type, messages, signal) {
delete generate_data.tools;
delete generate_data.tool_choice;
delete generate_data.stop;
// It does support logit_bias, but the tokenizer used and its effect is yet unknown.
// delete generate_data.logit_bias;
delete generate_data.logit_bias;
}
await eventSource.emit(event_types.CHAT_COMPLETION_SETTINGS_READY, generate_data);
@ -2166,6 +2167,14 @@ function getStreamingReply(data, state) {
state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
}
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
} else if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) {
if (oai_settings.show_thoughts) {
state.reasoning +=
data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning ??
'';
}
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
} else {
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
}
@ -3124,6 +3133,7 @@ function loadOpenAISettings(data, settings) {
oai_settings.inline_image_quality = settings.inline_image_quality ?? default_settings.inline_image_quality;
oai_settings.bypass_status_check = settings.bypass_status_check ?? default_settings.bypass_status_check;
oai_settings.show_thoughts = settings.show_thoughts ?? default_settings.show_thoughts;
oai_settings.reasoning_effort = settings.reasoning_effort ?? default_settings.reasoning_effort;
oai_settings.seed = settings.seed ?? default_settings.seed;
oai_settings.n = settings.n ?? default_settings.n;
@ -3253,6 +3263,9 @@ function loadOpenAISettings(data, settings) {
$('#n_openai').val(oai_settings.n);
$('#openai_show_thoughts').prop('checked', oai_settings.show_thoughts);
$('#openai_reasoning_effort').val(oai_settings.reasoning_effort);
$(`#openai_reasoning_effort option[value="${oai_settings.reasoning_effort}"]`).prop('selected', true);
if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy;
$('#openai_reverse_proxy').val(oai_settings.reverse_proxy);
@ -3513,6 +3526,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
continue_postfix: settings.continue_postfix,
function_calling: settings.function_calling,
show_thoughts: settings.show_thoughts,
reasoning_effort: settings.reasoning_effort,
seed: settings.seed,
n: settings.n,
};
@ -3971,6 +3985,7 @@ function onSettingsPresetChange() {
continue_postfix: ['#continue_postfix', 'continue_postfix', false],
function_calling: ['#openai_function_calling', 'function_calling', true],
show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true],
reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false],
seed: ['#seed_openai', 'seed', false],
n: ['#n_openai', 'n', false],
};
@ -4027,7 +4042,7 @@ function getMaxContextOpenAI(value) {
if (oai_settings.max_context_unlocked) {
return unlocked_max;
}
else if (value.startsWith('o1-')) {
else if (value.startsWith('o1') || value.startsWith('o3')) {
return max_128k;
}
else if (value.includes('chatgpt-4o-latest') || value.includes('gpt-4-turbo') || value.includes('gpt-4o') || value.includes('gpt-4-1106') || value.includes('gpt-4-0125') || value.includes('gpt-4-vision')) {
@ -4100,6 +4115,40 @@ function getMaxContextWindowAI(value) {
}
}
/**
* Get the maximum context size for the Groq model
* @param {string} model Model identifier
* @param {boolean} isUnlocked Whether context limits are unlocked
* @returns {number} Maximum context size in tokens
*/
function getGroqMaxContext(model, isUnlocked) {
if (isUnlocked) {
return unlocked_max;
}
const contextMap = {
'gemma2-9b-it': max_8k,
'llama-3.3-70b-versatile': max_128k,
'llama-3.1-8b-instant': max_128k,
'llama3-70b-8192': max_8k,
'llama3-8b-8192': max_8k,
'llama-guard-3-8b': max_8k,
'mixtral-8x7b-32768': max_32k,
'deepseek-r1-distill-llama-70b': max_128k,
'llama-3.3-70b-specdec': max_8k,
'llama-3.2-1b-preview': max_128k,
'llama-3.2-3b-preview': max_128k,
'llama-3.2-11b-vision-preview': max_128k,
'llama-3.2-90b-vision-preview': max_128k,
'qwen-2.5-32b': max_128k,
'deepseek-r1-distill-qwen-32b': max_128k,
'deepseek-r1-distill-llama-70b-specdec': max_128k,
};
// Return context size if model found, otherwise default to 128k
return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_128k;
}
async function onModelChange() {
biasCache = undefined;
let value = String($(this).val() || '');
@ -4232,9 +4281,9 @@ async function onModelChange() {
$('#openai_max_context').attr('max', max_2mil);
} else if (value.includes('gemini-exp-1114') || value.includes('gemini-exp-1121') || value.includes('gemini-2.0-flash-thinking-exp-1219')) {
$('#openai_max_context').attr('max', max_32k);
} else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206')) {
} else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206') || value.includes('gemini-2.0-pro')) {
$('#openai_max_context').attr('max', max_2mil);
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash-exp') || value.includes('gemini-2.0-flash-thinking-exp')) {
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash')) {
$('#openai_max_context').attr('max', max_1mil);
} else if (value.includes('gemini-1.0-pro') || value === 'gemini-pro') {
$('#openai_max_context').attr('max', max_32k);
@ -4380,28 +4429,19 @@ async function onModelChange() {
if (oai_settings.max_context_unlocked) {
$('#openai_max_context').attr('max', unlocked_max);
}
else if (['sonar', 'sonar-reasoning', 'sonar-reasoning-pro', 'r1-1776'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', 127000);
}
else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', 200000);
}
else if (oai_settings.perplexity_model.includes('llama-3.1')) {
const isOnline = oai_settings.perplexity_model.includes('online');
const contextSize = isOnline ? 128 * 1024 - 4000 : 128 * 1024;
$('#openai_max_context').attr('max', contextSize);
}
else if (['llama-3-sonar-small-32k-chat', 'llama-3-sonar-large-32k-chat'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', max_32k);
}
else if (['llama-3-sonar-small-32k-online', 'llama-3-sonar-large-32k-online'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', 28000);
}
else if (['sonar-small-chat', 'sonar-medium-chat', 'codellama-70b-instruct', 'mistral-7b-instruct', 'mixtral-8x7b-instruct', 'mixtral-8x22b-instruct'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', max_16k);
}
else if (['llama-3-8b-instruct', 'llama-3-70b-instruct'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', max_8k);
}
else if (['sonar-small-online', 'sonar-medium-online'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', 12000);
}
else {
$('#openai_max_context').attr('max', max_4k);
$('#openai_max_context').attr('max', max_128k);
}
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
@ -4410,27 +4450,8 @@ async function onModelChange() {
}
if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
if (oai_settings.max_context_unlocked) {
$('#openai_max_context').attr('max', unlocked_max);
}
else if (oai_settings.groq_model.includes('llama-3.2') && oai_settings.groq_model.includes('-preview')) {
$('#openai_max_context').attr('max', max_8k);
}
else if (oai_settings.groq_model.includes('llama-3.3') || oai_settings.groq_model.includes('llama-3.2') || oai_settings.groq_model.includes('llama-3.1')) {
$('#openai_max_context').attr('max', max_128k);
}
else if (oai_settings.groq_model.includes('llama3-groq')) {
$('#openai_max_context').attr('max', max_8k);
}
else if (['llama3-8b-8192', 'llama3-70b-8192', 'gemma-7b-it', 'gemma2-9b-it'].includes(oai_settings.groq_model)) {
$('#openai_max_context').attr('max', max_8k);
}
else if (['mixtral-8x7b-32768'].includes(oai_settings.groq_model)) {
$('#openai_max_context').attr('max', max_32k);
}
else {
$('#openai_max_context').attr('max', max_4k);
}
const maxContext = getGroqMaxContext(oai_settings.groq_model, oai_settings.max_context_unlocked);
$('#openai_max_context').attr('max', maxContext);
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai);
@ -4930,6 +4951,12 @@ export function isImageInliningSupported() {
// gultra just isn't being offered as multimodal, thanks google.
const visionSupportedModels = [
'gpt-4-vision',
'gemini-2.0-pro-exp',
'gemini-2.0-pro-exp-02-05',
'gemini-2.0-flash-lite-preview',
'gemini-2.0-flash-lite-preview-02-05',
'gemini-2.0-flash',
'gemini-2.0-flash-001',
'gemini-2.0-flash-thinking-exp-1219',
'gemini-2.0-flash-thinking-exp-01-21',
'gemini-2.0-flash-thinking-exp',
@ -4957,6 +4984,8 @@ export function isImageInliningSupported() {
'gpt-4-turbo',
'gpt-4o',
'gpt-4o-mini',
'o1',
'o1-2024-12-17',
'chatgpt-4o-latest',
'yi-vision',
'pixtral-latest',
@ -5515,6 +5544,11 @@ export function initOpenAI() {
saveSettingsDebounced();
});
$('#openai_reasoning_effort').on('input', function () {
oai_settings.reasoning_effort = String($(this).val());
saveSettingsDebounced();
});
if (!CSS.supports('field-sizing', 'content')) {
$(document).on('input', '#openai_settings .autoSetHeight', function () {
resetScrollHeight($(this));

View File

@ -30,6 +30,7 @@ import { t } from './i18n.js';
import { openWorldInfoEditor, world_names } from './world-info.js';
import { renderTemplateAsync } from './templates.js';
import { saveMetadataDebounced } from './extensions.js';
import { accountStorage } from './util/AccountStorage.js';
/**
* @typedef {object} PersonaConnection A connection between a character and a character or group entity
@ -67,7 +68,7 @@ export function isPersonaPanelOpen() {
}
function switchPersonaGridView() {
const state = localStorage.getItem(GRID_STORAGE_KEY) === 'true';
const state = accountStorage.getItem(GRID_STORAGE_KEY) === 'true';
$('#user_avatar_block').toggleClass('gridView', state);
}
@ -218,7 +219,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
const storageKey = 'Personas_PerPage';
const listId = '#user_avatar_block';
const perPage = Number(localStorage.getItem(storageKey)) || 5;
const perPage = Number(accountStorage.getItem(storageKey)) || 5;
$('#persona_pagination_container').pagination({
dataSource: entities,
@ -241,7 +242,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
updatePersonaUIStates();
},
afterSizeSelectorChange: function (e) {
localStorage.setItem(storageKey, e.target.value);
accountStorage.setItem(storageKey, e.target.value);
},
afterPaging: function (e) {
savePersonasPage = e;
@ -1631,8 +1632,8 @@ export function initPersonas() {
saveSettingsDebounced();
});
$('#persona_grid_toggle').on('click', () => {
const state = localStorage.getItem(GRID_STORAGE_KEY) === 'true';
localStorage.setItem(GRID_STORAGE_KEY, String(!state));
const state = accountStorage.getItem(GRID_STORAGE_KEY) === 'true';
accountStorage.setItem(GRID_STORAGE_KEY, String(!state));
switchPersonaGridView();
});

View File

@ -24,6 +24,15 @@ export const POPUP_RESULT = {
AFFIRMATIVE: 1,
NEGATIVE: 0,
CANCELLED: null,
CUSTOM1: 1001,
CUSTOM2: 1002,
CUSTOM3: 1003,
CUSTOM4: 1004,
CUSTOM5: 1005,
CUSTOM6: 1006,
CUSTOM7: 1007,
CUSTOM8: 1008,
CUSTOM9: 1009,
};
/**
@ -37,6 +46,7 @@ export const POPUP_RESULT = {
* @property {boolean?} [transparent=false] - Whether to display the popup in transparent mode (no background, border, shadow or anything, only its content)
* @property {boolean?} [allowHorizontalScrolling=false] - Whether to allow horizontal scrolling in the popup
* @property {boolean?} [allowVerticalScrolling=false] - Whether to allow vertical scrolling in the popup
* @property {boolean?} [leftAlign=false] - Whether the popup content should be left-aligned by default
* @property {'slow'|'fast'|'none'?} [animation='slow'] - Animation speed for the popup (opening, closing, ...)
* @property {POPUP_RESULT|number?} [defaultResult=POPUP_RESULT.AFFIRMATIVE] - The default result of this popup when Enter is pressed. Can be changed from `POPUP_RESULT.AFFIRMATIVE`.
* @property {CustomPopupButton[]|string[]?} [customButtons=null] - Custom buttons to add to the popup. If only strings are provided, the buttons will be added with default options, and their result will be in order from `2` onward.
@ -164,7 +174,7 @@ export class Popup {
* @param {string} [inputValue=''] - The initial value of the input field
* @param {PopupOptions} [options={}] - Additional options for the popup
*/
constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {
constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, leftAlign = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {
Popup.util.popups.push(this);
// Make this popup uniquely identifiable
@ -209,6 +219,7 @@ export class Popup {
if (transparent) this.dlg.classList.add('transparent_dialogue_popup');
if (allowHorizontalScrolling) this.dlg.classList.add('horizontal_scrolling_dialogue_popup');
if (allowVerticalScrolling) this.dlg.classList.add('vertical_scrolling_dialogue_popup');
if (leftAlign) this.dlg.classList.add('left_aligned_dialogue_popup');
if (animation) this.dlg.classList.add('popup--animation-' + animation);
// If custom button captions are provided, we set them beforehand

View File

@ -54,6 +54,7 @@ import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCom
import { POPUP_TYPE, callGenericPopup } from './popup.js';
import { loadSystemPrompts } from './sysprompt.js';
import { fuzzySearchCategories } from './filters.js';
import { accountStorage } from './util/AccountStorage.js';
export {
loadPowerUserSettings,
@ -254,7 +255,10 @@ let power_user = {
},
reasoning: {
auto_parse: false,
add_to_prompts: false,
auto_expand: false,
show_hidden: false,
prefix: '<think>\n',
suffix: '\n</think>',
separator: '\n\n',
@ -1843,14 +1847,15 @@ async function loadContextSettings() {
/**
* Common function to perform fuzzy search with optional caching
* @template T
* @param {string} type - Type of search from fuzzySearchCategories
* @param {any[]} data - Data array to search in
* @param {Array<{name: string, weight: number, getFn?: (obj: any) => string}>} keys - Fuse.js keys configuration
* @param {T[]} data - Data array to search in
* @param {Array<{name: string, weight: number, getFn?: (obj: T) => string}>} keys - Fuse.js keys configuration
* @param {string} searchValue - The search term
* @param {Object.<string, { resultMap: Map<string, any> }>} [fuzzySearchCaches=null] - Optional fuzzy search caches
* @returns {import('fuse.js').FuseResult<any>[]} Results as items with their score
* @returns {import('fuse.js').FuseResult<T>[]} Results as items with their score
*/
function performFuzzySearch(type, data, keys, searchValue, fuzzySearchCaches = null) {
export function performFuzzySearch(type, data, keys, searchValue, fuzzySearchCaches = null) {
// Check cache if provided
if (fuzzySearchCaches) {
const cache = fuzzySearchCaches[type];
@ -2019,7 +2024,7 @@ export function renderStoryString(params) {
*/
function validateStoryString(storyString, params) {
/** @type {{hashCache: {[hash: string]: {fieldsWarned: {[key: string]: boolean}}}}} */
const cache = JSON.parse(localStorage.getItem(storage_keys.storyStringValidationCache)) ?? { hashCache: {} };
const cache = JSON.parse(accountStorage.getItem(storage_keys.storyStringValidationCache)) ?? { hashCache: {} };
const hash = getStringHash(storyString);
@ -2056,7 +2061,7 @@ function validateStoryString(storyString, params) {
toastr.warning(`The story string does not contain the following fields, but they would contain content: ${fieldsList}`, 'Story String Validation');
}
localStorage.setItem(storage_keys.storyStringValidationCache, JSON.stringify(cache));
accountStorage.setItem(storage_keys.storyStringValidationCache, JSON.stringify(cache));
}
@ -2451,7 +2456,7 @@ async function resetMovablePanels(type) {
}
saveSettingsDebounced();
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
await eventSource.emit(event_types.MOVABLE_PANELS_RESET);
eventSource.once(event_types.SETTINGS_UPDATED, () => {
$('.resizing').removeClass('resizing');
@ -2918,6 +2923,46 @@ export function flushEphemeralStoppingStrings() {
EPHEMERAL_STOPPING_STRINGS.splice(0, EPHEMERAL_STOPPING_STRINGS.length);
}
/**
* Checks if the generated text should be filtered based on the auto-swipe settings.
* @param {string} text The text to check
* @returns {boolean} If the generated text should be filtered
*/
export function generatedTextFiltered(text) {
/**
* Checks if the given text contains any of the blacklisted words.
* @param {string} text The text to check
* @param {string[]} blacklist The list of blacklisted words
* @param {number} threshold The number of blacklisted words that need to be present to trigger the check
* @returns {boolean} Whether the text contains blacklisted words
*/
function containsBlacklistedWords(text, blacklist, threshold) {
const regex = new RegExp(`\\b(${blacklist.join('|')})\\b`, 'gi');
const matches = text.match(regex) || [];
return matches.length >= threshold;
}
// Make sure a generated text is non-empty
// Otherwise we might get in a loop with a broken API
text = text.trim();
if (text.length > 0) {
if (power_user.auto_swipe_minimum_length) {
if (text.length < power_user.auto_swipe_minimum_length) {
console.log('Generated text size too small');
return true;
}
}
if (power_user.auto_swipe_blacklist.length && power_user.auto_swipe_blacklist_threshold) {
if (containsBlacklistedWords(text, power_user.auto_swipe_blacklist, power_user.auto_swipe_blacklist_threshold)) {
console.log('Generated text has blacklisted words');
return true;
}
}
}
return false;
}
/**
* Gets the custom stopping strings from the power user settings.
* @param {number | undefined} limit Number of strings to return. If 0 or undefined, returns all strings.
@ -3899,9 +3944,9 @@ $(document).ready(() => {
helpString: 'Start a new chat with a random character. If an argument is provided, only considers characters that have the specified tag.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'delmode',
name: 'del',
callback: doDelMode,
aliases: ['del'],
aliases: ['delete', 'delmode'],
unnamedArgumentList: [
new SlashCommandArgument(
'optional number', [ARGUMENT_TYPE.NUMBER], false,
@ -4084,4 +4129,45 @@ $(document).ready(() => {
],
helpString: 'activates a movingUI preset by name',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'stop-strings',
aliases: ['stopping-strings', 'custom-stopping-strings', 'custom-stop-strings'],
helpString: `
<div>
Sets a list of custom stopping strings. Gets the list if no value is provided.
</div>
<div>
<strong>Examples:</strong>
</div>
<ul>
<li>Value must be a JSON-serialized array: <pre><code class="language-stscript">/stop-strings ["goodbye", "farewell"]</code></pre></li>
<li>Pipe characters must be escaped with a backslash: <pre><code class="language-stscript">/stop-strings ["left\\|right"]</code></pre></li>
</ul>
`,
returns: ARGUMENT_TYPE.LIST,
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'list of strings',
typeList: [ARGUMENT_TYPE.LIST],
acceptsMultiple: false,
isRequired: false,
}),
],
callback: (_, value) => {
if (String(value ?? '').trim()) {
const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value);
if (!parsedValue || !Array.isArray(parsedValue)) {
throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.');
}
parsedValue.forEach((item, index) => {
parsedValue[index] = String(item);
});
power_user.custom_stopping_strings = JSON.stringify(parsedValue);
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
saveSettingsDebounced();
}
return power_user.custom_stopping_strings;
},
}));
});

View File

@ -586,6 +586,9 @@ class PresetManager {
'tabby_model',
'derived',
'generic_model',
'include_reasoning',
'global_banned_tokens',
'send_banned_tokens',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@ -1,13 +1,32 @@
import { chat, closeMessageEditor, saveChatConditional, saveSettingsDebounced, substituteParams, updateMessageBlock } from '../script.js';
import { t } from './i18n.js';
import {
moment,
} from '../lib.js';
import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFormatting, saveChatConditional, saveSettingsDebounced, substituteParams, updateMessageBlock } from '../script.js';
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
import { getCurrentLocale, t, translate } from './i18n.js';
import { MacrosParser } from './macros.js';
import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';
import { Popup } from './popup.js';
import { power_user } from './power-user.js';
import { SlashCommand } from './slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js';
import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
import { enumTypes, SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js';
import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
import { copyText } from './utils.js';
import { textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
import { copyText, escapeRegex, isFalseBoolean, setDatasetProperty, trimSpaces } from './utils.js';
/**
* Enum representing the type of the reasoning for a message (where it came from)
* @enum {string}
* @readonly
*/
export const ReasoningType = {
Model: 'model',
Parsed: 'parsed',
Manual: 'manual',
Edited: 'edited',
};
/**
* Gets a message from a jQuery element.
@ -21,13 +40,474 @@ function getMessageFromJquery(element) {
return { messageId: messageId, message, messageBlock };
}
/**
* Toggles the auto-expand state of reasoning blocks.
*/
function toggleReasoningAutoExpand() {
const reasoningBlocks = document.querySelectorAll('details.mes_reasoning_details');
reasoningBlocks.forEach((block) => {
if (block instanceof HTMLDetailsElement) {
block.open = power_user.reasoning.auto_expand;
}
});
}
/**
* Extracts the reasoning from the response data.
* @param {object} data Response data
* @returns {string} Extracted reasoning
*/
export function extractReasoningFromData(data) {
switch (main_api) {
case 'textgenerationwebui':
switch (textgenerationwebui_settings.type) {
case textgen_types.OPENROUTER:
return data?.choices?.[0]?.reasoning ?? '';
}
break;
case 'openai':
if (!oai_settings.show_thoughts) break;
switch (oai_settings.chat_completion_source) {
case chat_completion_sources.DEEPSEEK:
return data?.choices?.[0]?.message?.reasoning_content ?? '';
case chat_completion_sources.OPENROUTER:
return data?.choices?.[0]?.message?.reasoning ?? '';
case chat_completion_sources.MAKERSUITE:
return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';
case chat_completion_sources.CUSTOM: {
return data?.choices?.[0]?.message?.reasoning_content
?? data?.choices?.[0]?.message?.reasoning
?? '';
}
}
break;
}
return '';
}
/**
* Check if the model supports reasoning, but does not send back the reasoning
* @returns {boolean} True if the model supports reasoning
*/
export function isHiddenReasoningModel() {
if (main_api !== 'openai') {
return false;
}
/** @typedef {{ (currentModel: string, supportedModel: string): boolean }} MatchingFunc */
/** @type {Record.<string, MatchingFunc>} */
const FUNCS = {
equals: (currentModel, supportedModel) => currentModel === supportedModel,
startsWith: (currentModel, supportedModel) => currentModel.startsWith(supportedModel),
};
/** @type {{ name: string; func: MatchingFunc; }[]} */
const hiddenReasoningModels = [
{ name: 'o1', func: FUNCS.startsWith },
{ name: 'o3', func: FUNCS.startsWith },
{ name: 'gemini-2.0-flash-thinking-exp', func: FUNCS.startsWith },
{ name: 'gemini-2.0-pro-exp', func: FUNCS.startsWith },
];
const model = getChatCompletionModel() || '';
const isHidden = hiddenReasoningModels.some(({ name, func }) => func(model, name));
return isHidden;
}
/**
* Updates the Reasoning UI for a specific message
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement The message ID or the message element
* @param {Object} [options={}] - Optional arguments
* @param {boolean} [options.reset=false] - Whether to reset state, and not take the current mess properties (for example when swiping)
*/
export function updateReasoningUI(messageIdOrElement, { reset = false } = {}) {
const handler = new ReasoningHandler();
handler.initHandleMessage(messageIdOrElement, { reset });
}
/**
* Enum for representing the state of reasoning
* @enum {string}
* @readonly
*/
export const ReasoningState = {
None: 'none',
Thinking: 'thinking',
Done: 'done',
Hidden: 'hidden',
};
/**
* Handles reasoning-specific logic and DOM updates for messages.
* This class is used inside the {@link StreamingProcessor} to manage reasoning states and UI updates.
*/
export class ReasoningHandler {
/** @type {boolean} True if the model supports reasoning, but hides the reasoning output */
#isHiddenReasoningModel;
/** @type {boolean} True if the handler is currently handling a manual parse of reasoning blocks */
#isParsingReasoning = false;
/** @type {number?} When reasoning is being parsed manually, and the reasoning has ended, this will be the index at which the actual messages starts */
#parsingReasoningMesStartIndex = null;
/**
* @param {Date?} [timeStarted=null] - When the generation started
*/
constructor(timeStarted = null) {
/** @type {ReasoningState} The current state of the reasoning process */
this.state = ReasoningState.None;
/** @type {ReasoningType?} The type of the reasoning (where it came from) */
this.type = null;
/** @type {string} The reasoning output */
this.reasoning = '';
/** @type {Date} When the reasoning started */
this.startTime = null;
/** @type {Date} When the reasoning ended */
this.endTime = null;
/** @type {Date} Initial starting time of the generation */
this.initialTime = timeStarted ?? new Date();
this.#isHiddenReasoningModel = isHiddenReasoningModel();
// Cached DOM elements for reasoning
/** @type {HTMLElement} Main message DOM element `.mes` */
this.messageDom = null;
/** @type {HTMLDetailsElement} Reasoning details DOM element `.mes_reasoning_details` */
this.messageReasoningDetailsDom = null;
/** @type {HTMLElement} Reasoning content DOM element `.mes_reasoning` */
this.messageReasoningContentDom = null;
/** @type {HTMLElement} Reasoning header DOM element `.mes_reasoning_header_title` */
this.messageReasoningHeaderDom = null;
}
/**
* Initializes the reasoning handler for a specific message.
*
* Can be used to update the DOM elements or read other reasoning states.
* It will internally take the message-saved data and write the states back into the handler, as if during streaming of the message.
* The state will always be either done/hidden or none.
*
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement - The message ID or the message element
* @param {Object} [options={}] - Optional arguments
* @param {boolean} [options.reset=false] - Whether to reset state of the handler, and not take the current mess properties (for example when swiping)
*/
initHandleMessage(messageIdOrElement, { reset = false } = {}) {
/** @type {HTMLElement} */
const messageElement = typeof messageIdOrElement === 'number'
? document.querySelector(`#chat [mesid="${messageIdOrElement}"]`)
: messageIdOrElement instanceof HTMLElement
? messageIdOrElement
: $(messageIdOrElement)[0];
const messageId = Number(messageElement.getAttribute('mesid'));
if (isNaN(messageId) || !chat[messageId]) return;
if (!chat[messageId].extra) {
chat[messageId].extra = {};
}
const extra = chat[messageId].extra;
if (extra.reasoning) {
this.state = ReasoningState.Done;
} else if (extra.reasoning_duration) {
this.state = ReasoningState.Hidden;
}
this.type = extra?.reasoning_type;
this.reasoning = extra?.reasoning ?? '';
if (this.state !== ReasoningState.None) {
this.initialTime = new Date(chat[messageId].gen_started);
this.startTime = this.initialTime;
this.endTime = new Date(this.startTime.getTime() + (extra?.reasoning_duration ?? 0));
}
// Prefill main dom element, as message might not have been rendered yet
this.messageDom = messageElement;
// Make sure reset correctly clears all relevant states
if (reset) {
this.state = this.#isHiddenReasoningModel ? ReasoningState.Thinking : ReasoningState.None;
this.type = null;
this.reasoning = '';
this.initialTime = new Date();
this.startTime = null;
this.endTime = null;
}
this.updateDom(messageId);
if (power_user.reasoning.auto_expand && this.state !== ReasoningState.Hidden) {
this.messageReasoningDetailsDom.open = true;
}
}
/**
* Gets the duration of the reasoning in milliseconds.
*
* @returns {number?} The duration in milliseconds, or null if the start or end time is not set
*/
getDuration() {
if (this.startTime && this.endTime) {
return this.endTime.getTime() - this.startTime.getTime();
}
return null;
}
/**
* Updates the reasoning text/string for a message.
*
* @param {number} messageId - The ID of the message to update
* @param {string?} [reasoning=null] - The reasoning text to update - If null or empty, uses the current reasoning
* @param {Object} [options={}] - Optional arguments
* @param {boolean} [options.persist=false] - Whether to persist the reasoning to the message object
* @param {boolean} [options.allowReset=false] - Whether to allow empty reasoning provided to reset the reasoning, instead of just taking the existing one
* @returns {boolean} - Returns true if the reasoning was changed, otherwise false
*/
updateReasoning(messageId, reasoning = null, { persist = false, allowReset = false } = {}) {
if (messageId == -1 || !chat[messageId]) {
return false;
}
reasoning = allowReset ? reasoning ?? this.reasoning : reasoning || this.reasoning;
reasoning = trimSpaces(reasoning);
// Ensure the chat extra exists
if (!chat[messageId].extra) {
chat[messageId].extra = {};
}
const extra = chat[messageId].extra;
const reasoningChanged = extra.reasoning !== reasoning;
this.reasoning = getRegexedString(reasoning ?? '', regex_placement.REASONING);
this.type = (this.#isParsingReasoning || this.#parsingReasoningMesStartIndex) ? ReasoningType.Parsed : ReasoningType.Model;
if (persist) {
// Build and save the reasoning data to message extras
extra.reasoning = this.reasoning;
extra.reasoning_duration = this.getDuration();
extra.reasoning_type = (this.#isParsingReasoning || this.#parsingReasoningMesStartIndex) ? ReasoningType.Parsed : ReasoningType.Model;
}
return reasoningChanged;
}
/**
* Handles processing of reasoning for a message.
*
* This is usually called by the message processor when a message is changed.
*
* @param {number} messageId - The ID of the message to process
* @param {boolean} mesChanged - Whether the message has changed
* @returns {Promise<void>}
*/
async process(messageId, mesChanged) {
mesChanged = this.#autoParseReasoningFromMessage(messageId, mesChanged);
if (!this.reasoning && !this.#isHiddenReasoningModel)
return;
// Ensure reasoning string is updated and regexes are applied correctly
const reasoningChanged = this.updateReasoning(messageId, null, { persist: true });
if ((this.#isHiddenReasoningModel || reasoningChanged) && this.state === ReasoningState.None) {
this.state = ReasoningState.Thinking;
this.startTime = this.initialTime;
}
if ((this.#isHiddenReasoningModel || !reasoningChanged) && mesChanged && this.state === ReasoningState.Thinking) {
this.endTime = new Date();
await this.finish(messageId);
}
}
#autoParseReasoningFromMessage(messageId, mesChanged) {
if (!power_user.reasoning.auto_parse)
return;
if (!power_user.reasoning.prefix || !power_user.reasoning.suffix)
return mesChanged;
/** @type {{ mes: string, [key: string]: any}} */
const message = chat[messageId];
if (!message) return mesChanged;
// If we are done with reasoning parse, we just split the message correctly so the reasoning doesn't show up inside of it.
if (this.#parsingReasoningMesStartIndex) {
message.mes = trimSpaces(message.mes.slice(this.#parsingReasoningMesStartIndex));
return mesChanged;
}
if (this.state === ReasoningState.None || this.#isHiddenReasoningModel) {
// If streamed message starts with the opening, cut it out and put all inside reasoning
if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) {
this.#isParsingReasoning = true;
// Manually set starting state here, as we might already have received the ending suffix
this.state = ReasoningState.Thinking;
this.startTime = this.startTime ?? this.initialTime;
this.endTime = null;
}
}
if (!this.#isParsingReasoning)
return mesChanged;
// If we are in manual parsing mode, all currently streaming mes tokens will go the the reasoning block
const originalMes = message.mes;
this.reasoning = originalMes.slice(power_user.reasoning.prefix.length);
message.mes = '';
// If the reasoning contains the ending suffix, we cut that off and continue as message streaming
if (this.reasoning.includes(power_user.reasoning.suffix)) {
this.reasoning = this.reasoning.slice(0, this.reasoning.indexOf(power_user.reasoning.suffix));
this.#parsingReasoningMesStartIndex = originalMes.indexOf(power_user.reasoning.suffix) + power_user.reasoning.suffix.length;
message.mes = trimSpaces(originalMes.slice(this.#parsingReasoningMesStartIndex));
this.#isParsingReasoning = false;
}
// Only return the original mesChanged value if we haven't cut off the complete message
return message.mes.length ? mesChanged : false;
}
/**
* Completes the reasoning process for a message.
*
* Records the finish time if it was not set during streaming and updates the reasoning state.
* Emits an event to signal the completion of reasoning and updates the DOM elements accordingly.
*
* @param {number} messageId - The ID of the message to complete reasoning for
* @returns {Promise<void>}
*/
async finish(messageId) {
if (this.state === ReasoningState.None) return;
// Make sure the finish time is recorded if a reasoning was in process and it wasn't ended correctly during streaming
if (this.startTime !== null && this.endTime === null) {
this.endTime = new Date();
}
if (this.state === ReasoningState.Thinking) {
this.state = this.#isHiddenReasoningModel ? ReasoningState.Hidden : ReasoningState.Done;
this.updateReasoning(messageId, null, { persist: true });
await eventSource.emit(event_types.STREAM_REASONING_DONE, this.reasoning, this.getDuration(), messageId, this.state);
}
this.updateDom(messageId);
}
/**
* Updates the reasoning UI elements for a message.
*
* Toggles the CSS class, updates states, reasoning message, and duration.
*
* @param {number} messageId - The ID of the message to update
*/
updateDom(messageId) {
this.#checkDomElements(messageId);
// Main CSS class to show this message includes reasoning
this.messageDom.classList.toggle('reasoning', this.state !== ReasoningState.None);
// Update states to the relevant DOM elements
setDatasetProperty(this.messageDom, 'reasoningState', this.state !== ReasoningState.None ? this.state : null);
setDatasetProperty(this.messageReasoningDetailsDom, 'state', this.state);
setDatasetProperty(this.messageReasoningDetailsDom, 'type', this.type);
// Update the reasoning message
const reasoning = trimSpaces(this.reasoning);
const displayReasoning = messageFormatting(reasoning, '', false, false, messageId, {}, true);
this.messageReasoningContentDom.innerHTML = displayReasoning;
// Update tooltip for hidden reasoning edit
/** @type {HTMLElement} */
const button = this.messageDom.querySelector('.mes_edit_add_reasoning');
button.title = this.state === ReasoningState.Hidden ? t`Hidden reasoning - Add reasoning block` : t`Add reasoning block`;
// Make sure that hidden reasoning headers are collapsed by default, to not show a useless edit button
if (this.state === ReasoningState.Hidden) {
this.messageReasoningDetailsDom.open = false;
}
// Update the reasoning duration in the UI
this.#updateReasoningTimeUI();
}
/**
* Finds and caches reasoning-related DOM elements for the given message.
*
* @param {number} messageId - The ID of the message to cache the DOM elements for
*/
#checkDomElements(messageId) {
// Make sure we reset dom elements if we are checking for a different message (shouldn't happen, but be sure)
if (this.messageDom !== null && this.messageDom.getAttribute('mesid') !== messageId.toString()) {
this.messageDom = null;
}
// Cache the DOM elements once
if (this.messageDom === null) {
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
if (this.messageDom === null) throw new Error('message dom does not exist');
}
if (this.messageReasoningDetailsDom === null) {
this.messageReasoningDetailsDom = this.messageDom.querySelector('.mes_reasoning_details');
}
if (this.messageReasoningContentDom === null) {
this.messageReasoningContentDom = this.messageDom.querySelector('.mes_reasoning');
}
if (this.messageReasoningHeaderDom === null) {
this.messageReasoningHeaderDom = this.messageDom.querySelector('.mes_reasoning_header_title');
}
}
/**
* Updates the reasoning time display in the UI.
*
* Shows the duration in a human-readable format with a tooltip for exact seconds.
* Displays "Thinking..." if still processing, or a generic message otherwise.
*/
#updateReasoningTimeUI() {
const element = this.messageReasoningHeaderDom;
const duration = this.getDuration();
let data = null;
let title = '';
if (duration) {
const seconds = moment.duration(duration).asSeconds();
const durationStr = moment.duration(duration).locale(getCurrentLocale()).humanize({ s: 50, ss: 3 });
element.textContent = t`Thought for ${durationStr}`;
data = String(seconds);
title = `${seconds} seconds`;
} else if ([ReasoningState.Done, ReasoningState.Hidden].includes(this.state)) {
element.textContent = t`Thought for some time`;
data = 'unknown';
} else {
element.textContent = t`Thinking...`;
data = null;
}
if (this.type !== ReasoningType.Model) {
title += ` [${translate(this.type)}]`;
title = title.trim();
}
element.title = title;
setDatasetProperty(this.messageReasoningDetailsDom, 'duration', data);
setDatasetProperty(element, 'duration', data);
}
}
/**
* Helper class for adding reasoning to messages.
* Keeps track of the number of reasoning additions.
*/
export class PromptReasoning {
static REASONING_PLACEHOLDER = '\u200B';
static REASONING_PLACEHOLDER_REGEX = new RegExp(`${PromptReasoning.REASONING_PLACEHOLDER}$`);
constructor() {
this.counter = 0;
@ -49,15 +529,16 @@ export class PromptReasoning {
* Add reasoning to a message according to the power user settings.
* @param {string} content Message content
* @param {string} reasoning Message reasoning
* @param {boolean} isPrefix Whether this is the last message prefix
* @returns {string} Message content with reasoning
*/
addToMessage(content, reasoning) {
addToMessage(content, reasoning, isPrefix) {
// Disabled or reached limit of additions
if (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions) {
if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
return content;
}
// No reasoning provided or a placeholder
// No reasoning provided or a legacy placeholder
if (!reasoning || reasoning === PromptReasoning.REASONING_PLACEHOLDER) {
return content;
}
@ -70,6 +551,11 @@ export class PromptReasoning {
const separator = substituteParams(power_user.reasoning.separator || '');
const suffix = substituteParams(power_user.reasoning.suffix || '');
// Combine parts with reasoning only
if (isPrefix && !content) {
return `${prefix}${reasoning}`;
}
// Combine parts with reasoning and content
return `${prefix}${reasoning}${suffix}${separator}${content}`;
}
@ -105,11 +591,34 @@ function loadReasoningSettings() {
power_user.reasoning.max_additions = Number($(this).val());
saveSettingsDebounced();
});
$('#reasoning_auto_parse').prop('checked', power_user.reasoning.auto_parse);
$('#reasoning_auto_parse').on('change', function () {
power_user.reasoning.auto_parse = !!$(this).prop('checked');
saveSettingsDebounced();
});
$('#reasoning_auto_expand').prop('checked', power_user.reasoning.auto_expand);
$('#reasoning_auto_expand').on('change', function () {
power_user.reasoning.auto_expand = !!$(this).prop('checked');
toggleReasoningAutoExpand();
saveSettingsDebounced();
});
toggleReasoningAutoExpand();
$('#reasoning_show_hidden').prop('checked', power_user.reasoning.show_hidden);
$('#reasoning_show_hidden').on('change', function () {
power_user.reasoning.show_hidden = !!$(this).prop('checked');
$('#chat').attr('data-show-hidden-reasoning', power_user.reasoning.show_hidden ? 'true' : null);
saveSettingsDebounced();
});
$('#chat').attr('data-show-hidden-reasoning', power_user.reasoning.show_hidden ? 'true' : null);
}
function registerReasoningSlashCommands() {
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'reasoning-get',
aliases: ['get-reasoning'],
returns: ARGUMENT_TYPE.STRING,
helpString: t`Get the contents of a reasoning block of a message. Returns an empty string if the message does not have a reasoning block.`,
unnamedArgumentList: [
@ -120,15 +629,16 @@ function registerReasoningSlashCommands() {
}),
],
callback: (_args, value) => {
const messageId = !isNaN(Number(value)) ? Number(value) : chat.length - 1;
const messageId = !isNaN(parseInt(value.toString())) ? parseInt(value.toString()) : chat.length - 1;
const message = chat[messageId];
const reasoning = String(message?.extra?.reasoning ?? '');
return reasoning.replace(PromptReasoning.REASONING_PLACEHOLDER_REGEX, '');
return reasoning;
},
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'reasoning-set',
aliases: ['set-reasoning'],
returns: ARGUMENT_TYPE.STRING,
helpString: t`Set the reasoning block of a message. Returns the reasoning block content.`,
namedArgumentList: [
@ -146,13 +656,18 @@ function registerReasoningSlashCommands() {
}),
],
callback: async (args, value) => {
const messageId = !isNaN(Number(args[0])) ? Number(args[0]) : chat.length - 1;
const messageId = !isNaN(Number(args.at)) ? Number(args.at) : chat.length - 1;
const message = chat[messageId];
if (!message?.extra) {
if (!message) {
return '';
}
// Make sure the message has an extra object
if (!message.extra || typeof message.extra !== 'object') {
message.extra = {};
}
message.extra.reasoning = String(value ?? '');
message.extra.reasoning_type = ReasoningType.Manual;
await saveChatConditional();
closeMessageEditor('reasoning');
@ -160,6 +675,77 @@ function registerReasoningSlashCommands() {
return message.extra.reasoning;
},
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'reasoning-parse',
aliases: ['parse-reasoning'],
returns: 'reasoning string',
helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`,
namedArgumentList: [
SlashCommandNamedArgument.fromProps({
name: 'regex',
description: 'Whether to apply regex scripts to the reasoning content.',
typeList: [ARGUMENT_TYPE.BOOLEAN],
defaultValue: 'true',
isRequired: false,
enumList: commonEnumProviders.boolean('trueFalse')(),
}),
SlashCommandNamedArgument.fromProps({
name: 'return',
description: 'Whether to return the parsed reasoning or the content without reasoning',
typeList: [ARGUMENT_TYPE.STRING],
defaultValue: 'reasoning',
isRequired: false,
enumList: [
new SlashCommandEnumValue('reasoning', null, enumTypes.enum, enumIcons.reasoning),
new SlashCommandEnumValue('content', null, enumTypes.enum, enumIcons.message),
],
}),
SlashCommandNamedArgument.fromProps({
name: 'strict',
description: 'Whether to require the reasoning block to be at the beginning of the string (excluding whitespaces).',
typeList: [ARGUMENT_TYPE.BOOLEAN],
defaultValue: 'true',
isRequired: false,
enumList: commonEnumProviders.boolean('trueFalse')(),
}),
],
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'input string',
typeList: [ARGUMENT_TYPE.STRING],
}),
],
callback: (args, value) => {
if (!value || typeof value !== 'string') {
return '';
}
if (!power_user.reasoning.prefix || !power_user.reasoning.suffix) {
toastr.warning(t`Both prefix and suffix must be set in the Reasoning Formatting settings.`, t`Reasoning Parse`);
return value;
}
if (typeof args.return !== 'string' || !['reasoning', 'content'].includes(args.return)) {
toastr.warning(t`Invalid return type '${args.return}', defaulting to 'reasoning'.`, t`Reasoning Parse`);
}
const returnMessage = args.return === 'content';
const parsedReasoning = parseReasoningFromString(value, { strict: !isFalseBoolean(String(args.strict ?? '')) });
if (!parsedReasoning) {
return returnMessage ? value : '';
}
if (returnMessage) {
return parsedReasoning.content;
}
const applyRegex = !isFalseBoolean(String(args.regex ?? ''));
return applyRegex
? getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING)
: parsedReasoning.reasoning;
},
}));
}
function registerReasoningMacros() {
@ -169,6 +755,31 @@ function registerReasoningMacros() {
}
function setReasoningEventHandlers() {
$(document).on('click', '.mes_reasoning_details', function (e) {
if (!e.target.closest('.mes_reasoning_actions') && !e.target.closest('.mes_reasoning_header')) {
e.preventDefault();
}
});
$(document).on('click', '.mes_reasoning_header', function (e) {
const details = $(this).closest('.mes_reasoning_details');
// Along with the CSS rules to mark blocks not toggle-able when they are empty, prevent them from actually being toggled, or being edited
if (details.find('.mes_reasoning').is(':empty')) {
e.preventDefault();
return;
}
// If we are in message edit mode and reasoning area is closed, a click opens and edits it
const mes = $(this).closest('.mes');
const mesEditArea = mes.find('#curEditTextarea');
if (mesEditArea.length) {
const summary = $(mes).find('.mes_reasoning_summary');
if (!summary.attr('open')) {
summary.find('.mes_reasoning_edit').trigger('click');
}
}
});
$(document).on('click', '.mes_reasoning_copy', (e) => {
e.stopPropagation();
e.preventDefault();
@ -187,7 +798,7 @@ function setReasoningEventHandlers(){
const textarea = document.createElement('textarea');
const reasoningBlock = messageBlock.find('.mes_reasoning');
textarea.classList.add('reasoning_edit_textarea');
textarea.value = reasoning.replace(PromptReasoning.REASONING_PLACEHOLDER_REGEX, '');
textarea.value = reasoning;
$(textarea).insertBefore(reasoningBlock);
if (!CSS.supports('field-sizing', 'content')) {
@ -224,11 +835,14 @@ function setReasoningEventHandlers(){
}
const textarea = messageBlock.find('.reasoning_edit_textarea');
const reasoning = String(textarea.val());
const reasoning = getRegexedString(String(textarea.val()), regex_placement.REASONING, { isEdit: true });
message.extra.reasoning = reasoning;
message.extra.reasoning_type = message.extra.reasoning_type ? ReasoningType.Edited : ReasoningType.Manual;
await saveChatConditional();
updateMessageBlock(messageId, message);
textarea.remove();
messageBlock.find('.mes_edit_done:visible').trigger('click');
});
$(document).on('click', '.mes_reasoning_edit_cancel', function (e) {
@ -238,10 +852,14 @@ function setReasoningEventHandlers(){
const { messageBlock } = getMessageFromJquery(this);
const textarea = messageBlock.find('.reasoning_edit_textarea');
textarea.remove();
messageBlock.find('.mes_reasoning_edit_cancel:visible').trigger('click');
updateReasoningUI(messageBlock);
});
$(document).on('click', '.mes_edit_add_reasoning', async function () {
const { message, messageId } = getMessageFromJquery(this);
const { message, messageBlock } = getMessageFromJquery(this);
if (!message?.extra) {
return;
}
@ -251,34 +869,46 @@ function setReasoningEventHandlers(){
return;
}
message.extra.reasoning = PromptReasoning.REASONING_PLACEHOLDER;
messageBlock.addClass('reasoning');
// To make hidden reasoning blocks editable, we just set them to "Done" here already.
// They will be done on save anyway - and on cancel the reasoning block gets rerendered too.
if (messageBlock.attr('data-reasoning-state') === ReasoningState.Hidden) {
messageBlock.attr('data-reasoning-state', ReasoningState.Done);
}
// Open the reasoning area so we can actually edit it
messageBlock.find('.mes_reasoning_details').attr('open', '');
messageBlock.find('.mes_reasoning_edit').trigger('click');
await saveChatConditional();
closeMessageEditor();
updateMessageBlock(messageId, message);
});
$(document).on('click', '.mes_reasoning_delete', async function (e) {
e.stopPropagation();
e.preventDefault();
const confirm = await Popup.show.confirm(t`Are you sure you want to clear the reasoning?`, t`Visible message contents will stay intact.`);
const confirm = await Popup.show.confirm(t`Remove Reasoning`, t`Are you sure you want to clear the reasoning?<br />Visible message contents will stay intact.`);
if (!confirm) {
return;
}
const { message, messageId } = getMessageFromJquery(this);
const { message, messageId, messageBlock } = getMessageFromJquery(this);
if (!message?.extra) {
return;
}
message.extra.reasoning = '';
delete message.extra.reasoning_type;
delete message.extra.reasoning_duration;
await saveChatConditional();
updateMessageBlock(messageId, message);
const textarea = messageBlock.find('.reasoning_edit_textarea');
textarea.remove();
});
$(document).on('pointerup', '.mes_reasoning_copy', async function () {
const { message } = getMessageFromJquery(this);
const reasoning = String(message?.extra?.reasoning ?? '').replace(PromptReasoning.REASONING_PLACEHOLDER_REGEX, '');
const reasoning = String(message?.extra?.reasoning ?? '');
if (!reasoning) {
return;
@ -289,9 +919,123 @@ function setReasoningEventHandlers(){
});
}
/**
* Removes reasoning from a string if auto-parsing is enabled.
* @param {string} str Input string
* @returns {string} Output string
*/
export function removeReasoningFromString(str) {
if (!power_user.reasoning.auto_parse) {
return str;
}
const parsedReasoning = parseReasoningFromString(str);
return parsedReasoning?.content ?? str;
}
/**
* Parses reasoning from a string using the power user reasoning settings.
* @typedef {Object} ParsedReasoning
* @property {string} reasoning Reasoning block
* @property {string} content Message content
* @param {string} str Content of the message
* @param {Object} options Optional arguments
* @param {boolean} [options.strict=true] Whether the reasoning block **has** to be at the beginning of the provided string (excluding whitespaces), or can be anywhere in it
* @returns {ParsedReasoning|null} Parsed reasoning block and message content
*/
function parseReasoningFromString(str, { strict = true } = {}) {
// Both prefix and suffix must be defined
if (!power_user.reasoning.prefix || !power_user.reasoning.suffix) {
return null;
}
try {
const regex = new RegExp(`${(strict ? '^\\s*?' : '')}${escapeRegex(power_user.reasoning.prefix)}(.*?)${escapeRegex(power_user.reasoning.suffix)}`, 's');
let didReplace = false;
let reasoning = '';
let content = String(str).replace(regex, (_match, captureGroup) => {
didReplace = true;
reasoning = captureGroup;
return '';
});
if (didReplace) {
reasoning = trimSpaces(reasoning);
content = trimSpaces(content);
}
return { reasoning, content };
} catch (error) {
console.error('[Reasoning] Error parsing reasoning block', error);
return null;
}
}
function registerReasoningAppEvents() {
eventSource.makeFirst(event_types.MESSAGE_RECEIVED, (/** @type {number} */ idx) => {
if (!power_user.reasoning.auto_parse) {
return;
}
console.debug('[Reasoning] Auto-parsing reasoning block for message', idx);
const message = chat[idx];
if (!message) {
console.warn('[Reasoning] Message not found', idx);
return null;
}
if (!message.mes || message.mes === '...') {
console.debug('[Reasoning] Message content is empty or a placeholder', idx);
return null;
}
if (message.extra?.reasoning) {
console.debug('[Reasoning] Message already has reasoning', idx);
return null;
}
const parsedReasoning = parseReasoningFromString(message.mes);
// No reasoning block found
if (!parsedReasoning) {
return;
}
// Make sure the message has an extra object
if (!message.extra || typeof message.extra !== 'object') {
message.extra = {};
}
const contentUpdated = !!parsedReasoning.reasoning || parsedReasoning.content !== message.mes;
// If reasoning was found, add it to the message
if (parsedReasoning.reasoning) {
message.extra.reasoning = getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING);
message.extra.reasoning_type = ReasoningType.Parsed;
}
// Update the message text if it was changed
if (parsedReasoning.content !== message.mes) {
message.mes = parsedReasoning.content;
}
// Find if a message already exists in DOM and must be updated
if (contentUpdated) {
const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;
if (messageRendered) {
console.debug('[Reasoning] Updating message block', idx);
updateMessageBlock(idx, message);
}
}
});
}
export function initReasoning() {
loadReasoningSettings();
setReasoningEventHandlers();
registerReasoningSlashCommands();
registerReasoningMacros();
registerReasoningAppEvents();
}

View File

@ -40,6 +40,8 @@ export const SECRET_KEYS = {
BFL: 'api_key_bfl',
GENERIC: 'api_key_generic',
DEEPSEEK: 'api_key_deepseek',
SERPER: 'api_key_serper',
FALAI: 'api_key_falai',
};
const INPUT_MAP = {

View File

@ -59,7 +59,7 @@ import { autoSelectPersona, isPersonaLocked, retriggerFirstMessageOnEmptyChat, s
import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';
import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js';
import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
import { registerVariableCommands, resolveVariable } from './variables.js';
import { background_settings } from './backgrounds.js';
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
@ -76,6 +76,7 @@ import { SlashCommandBreakController } from './slash-commands/SlashCommandBreakC
import { SlashCommandExecutionError } from './slash-commands/SlashCommandExecutionError.js';
import { slashCommandReturnHelper } from './slash-commands/SlashCommandReturnHelper.js';
import { t } from './i18n.js';
import { accountStorage } from './util/AccountStorage.js';
export {
executeSlashCommands, executeSlashCommandsWithOptions, getSlashCommandsHelp, registerSlashCommand,
};
@ -283,7 +284,6 @@ export function initDefaultSlashCommands() {
description: 'Character name - or unique character identifier (avatar key)',
typeList: [ARGUMENT_TYPE.STRING],
enumProvider: commonEnumProviders.characters('character'),
forceEnum: false,
}),
],
helpString: `
@ -322,7 +322,6 @@ export function initDefaultSlashCommands() {
typeList: [ARGUMENT_TYPE.STRING],
isRequired: true,
enumProvider: commonEnumProviders.characters('character'),
forceEnum: false,
}),
SlashCommandNamedArgument.fromProps({
name: 'avatar',
@ -566,7 +565,6 @@ export function initDefaultSlashCommands() {
typeList: [ARGUMENT_TYPE.STRING],
isRequired: true,
enumProvider: commonEnumProviders.characters('all'),
forceEnum: true,
}),
],
helpString: 'Opens up a chat with the character or group by its name',
@ -781,6 +779,57 @@ export function initDefaultSlashCommands() {
],
helpString: 'Unhides a message from the prompt.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'member-get',
aliases: ['getmember', 'memberget'],
callback: (async ({ field = 'name' }, arg) => {
if (!selected_group) {
toastr.warning('Cannot run /member-get command outside of a group chat.');
return '';
}
if (field === '') {
toastr.warning('\'/member-get field=\' argument required!');
return '';
}
field = field.toString();
arg = arg.toString();
if (!['name', 'index', 'id', 'avatar'].includes(field)) {
toastr.warning('\'/member-get field=\' argument required!');
return '';
}
const isId = !isNaN(parseInt(arg));
const groupMember = findGroupMemberId(arg, true);
if (!groupMember) {
toastr.warn(`No group member found using ${isId ? 'id' : 'string'} ${arg}`);
return '';
}
return groupMember[field];
}),
namedArgumentList: [
SlashCommandNamedArgument.fromProps({
name: 'field',
description: 'Whether to retrieve the name, index, id, or avatar.',
typeList: [ARGUMENT_TYPE.STRING],
isRequired: true,
defaultValue: 'name',
enumList: [
new SlashCommandEnumValue('name', 'Character name'),
new SlashCommandEnumValue('index', 'Group member index'),
new SlashCommandEnumValue('avatar', 'Character avatar'),
new SlashCommandEnumValue('id', 'Character index'),
],
}),
],
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'member index (starts with 0), name, or avatar',
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
isRequired: true,
enumProvider: commonEnumProviders.groupMembers(),
}),
],
helpString: 'Retrieves a group member\'s name, index, id, or avatar.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'member-disable',
callback: disableGroupMemberCallback,
@ -891,7 +940,8 @@ export function initDefaultSlashCommands() {
helpString: 'Moves a group member down in the group chat list.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'peek',
name: 'member-peek',
aliases: ['peek', 'memberpeek', 'peekmember'],
callback: peekCallback,
unnamedArgumentList: [
SlashCommandArgument.fromProps({
@ -1057,7 +1107,6 @@ export function initDefaultSlashCommands() {
typeList: [ARGUMENT_TYPE.STRING],
defaultValue: 'System',
enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)],
forceEnum: false,
}),
new SlashCommandNamedArgument(
'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
@ -1951,7 +2000,7 @@ export function initDefaultSlashCommands() {
returns: 'uppercase string',
unnamedArgumentList: [
new SlashCommandArgument(
'string', [ARGUMENT_TYPE.STRING], true, false,
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
),
],
helpString: 'Converts the provided string to uppercase.',
@ -1963,7 +2012,7 @@ export function initDefaultSlashCommands() {
returns: 'lowercase string',
unnamedArgumentList: [
new SlashCommandArgument(
'string', [ARGUMENT_TYPE.STRING], true, false,
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
),
],
helpString: 'Converts the provided string to lowercase.',
@ -1983,7 +2032,7 @@ export function initDefaultSlashCommands() {
],
unnamedArgumentList: [
new SlashCommandArgument(
'string', [ARGUMENT_TYPE.STRING], true, false,
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
),
],
helpString: `
@ -2047,6 +2096,62 @@ export function initDefaultSlashCommands() {
return '';
},
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'replace',
aliases: ['re'],
callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
if (pattern === '')
throw new Error('Argument of \'pattern=\' cannot be empty');
switch (mode) {
case 'literal':
return text.replaceAll(pattern, replacer);
case 'regex':
return text.replace(regexFromString(pattern), replacer);
default:
throw new Error('Invalid \'/replace mode=\' argument specified!');
}
}),
returns: 'replaced text',
namedArgumentList: [
SlashCommandNamedArgument.fromProps({
name: 'mode',
description: 'Replaces occurrence(s) of a pattern',
typeList: [ARGUMENT_TYPE.STRING],
defaultValue: 'literal',
enumList: ['literal', 'regex'],
}),
new SlashCommandNamedArgument(
'pattern', 'pattern to search with', [ARGUMENT_TYPE.STRING], true, false,
),
new SlashCommandNamedArgument(
'replacer', 'replacement text for matches', [ARGUMENT_TYPE.STRING], false, false, '',
),
],
unnamedArgumentList: [
new SlashCommandArgument(
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
),
],
helpString: `
<div>
Replaces text within the provided string based on the pattern.
</div>
<div>
If <code>mode</code> is <code>literal</code> (or omitted), <code>pattern</code> is a literal search string (case-sensitive).<br />
If <code>mode</code> is <code>regex</code>, <code>pattern</code> is parsed as an ECMAScript Regular Expression.<br />
The <code>replacer</code> replaces based on the <code>pattern</code> in the input text.<br />
If <code>replacer</code> is omitted, the replacement(s) will be an empty string.<br />
</div>
<div>
<strong>Example:</strong>
<pre>/let x Blue house and blue car || </pre>
<pre>/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</pre>
<pre>/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</pre>
<pre>/replace mode=regex pattern="/blue/i" replacer="red" {{var::x}} | /echo |/# red house and blue car ||</pre>
<pre>/replace mode=regex pattern="/blue/gi" replacer="red" {{var::x}} | /echo |/# red house and red car ||</pre>
</div>
`,
}));
registerVariableCommands();
}
@ -3039,7 +3144,7 @@ function performGroupMemberAction(chid, action) {
async function disableGroupMemberCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /disable command outside of a group chat.');
toastr.warning('Cannot run /member-disable command outside of a group chat.');
return '';
}
@ -3056,7 +3161,7 @@ async function disableGroupMemberCallback(_, arg) {
async function enableGroupMemberCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /enable command outside of a group chat.');
toastr.warning('Cannot run /member-enable command outside of a group chat.');
return '';
}
@ -3073,7 +3178,7 @@ async function enableGroupMemberCallback(_, arg) {
async function moveGroupMemberUpCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /memberup command outside of a group chat.');
toastr.warning('Cannot run /member-up command outside of a group chat.');
return '';
}
@ -3090,7 +3195,7 @@ async function moveGroupMemberUpCallback(_, arg) {
async function moveGroupMemberDownCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /memberdown command outside of a group chat.');
toastr.warning('Cannot run /member-down command outside of a group chat.');
return '';
}
@ -3107,12 +3212,12 @@ async function moveGroupMemberDownCallback(_, arg) {
async function peekCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /peek command outside of a group chat.');
toastr.warning('Cannot run /member-peek command outside of a group chat.');
return '';
}
if (is_group_generating) {
toastr.warning('Cannot run /peek command while the group reply is generating.');
toastr.warning('Cannot run /member-peek command while the group reply is generating.');
return '';
}
@ -3129,12 +3234,7 @@ async function peekCallback(_, arg) {
async function removeGroupMemberCallback(_, arg) {
if (!selected_group) {
toastr.warning('Cannot run /memberremove command outside of a group chat.');
return '';
}
if (is_group_generating) {
toastr.warning('Cannot run /memberremove command while the group reply is generating.');
toastr.warning('Cannot run /member-remove command outside of a group chat.');
return '';
}
@ -3242,12 +3342,7 @@ function findPersonaByName(name) {
}
async function sendUserMessageCallback(args, text) {
if (!text) {
toastr.warning('You must specify text to send');
return;
}
text = text.trim();
text = String(text ?? '').trim();
const compact = isTrueBoolean(args?.compact);
const bias = extractMessageBias(text);
@ -3562,24 +3657,18 @@ export function getNameAndAvatarForMessage(character, name = null) {
}
export async function sendMessageAs(args, text) {
if (!text) {
toastr.warning('You must specify text to send as');
return '';
}
let name = args.name?.trim();
let mesText;
if (!name) {
const namelessWarningKey = 'sendAsNamelessWarningShown';
if (localStorage.getItem(namelessWarningKey) !== 'true') {
if (accountStorage.getItem(namelessWarningKey) !== 'true') {
toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
localStorage.setItem(namelessWarningKey, 'true');
accountStorage.setItem(namelessWarningKey, 'true');
}
name = name2;
}
mesText = text.trim();
let mesText = String(text ?? '').trim();
// Requires a regex check after the slash command is pushed to output
mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND, { characterOverride: name });
@ -3657,11 +3746,7 @@ export async function sendMessageAs(args, text) {
}
export async function sendNarratorMessage(args, text) {
if (!text) {
toastr.warning('You must specify text to send');
return '';
}
text = String(text ?? '');
const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
// Messages that do nothing but set bias will be hidden from the context
const bias = extractMessageBias(text);
@ -3752,18 +3837,13 @@ export async function promptQuietForLoudResponse(who, text) {
}
async function sendCommentMessage(args, text) {
if (!text) {
toastr.warning('You must specify text to send');
return '';
}
const compact = isTrueBoolean(args?.compact);
const message = {
name: COMMENT_NAME_DEFAULT,
is_user: false,
is_system: true,
send_date: getMessageTimeStamp(),
mes: substituteParams(text.trim()),
mes: substituteParams(String(text ?? '').trim()),
force_avatar: comment_avatar,
extra: {
type: system_message_types.COMMENT,

View File

@ -34,6 +34,7 @@ export const enumIcons = {
preset: '⚙️',
file: '📄',
message: '💬',
reasoning: '💡',
voice: '🎤',
server: '🖥️',
popup: '🗔',

View File

@ -68,10 +68,14 @@ import { tag_map, tags } from './tags.js';
import { textgenerationwebui_settings } from './textgen-settings.js';
import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';
import { ToolManager } from './tool-calling.js';
import { accountStorage } from './util/AccountStorage.js';
import { timestampToMoment, uuidv4 } from './utils.js';
import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
import { convertCharacterBook, loadWorldInfo, saveWorldInfo, updateWorldInfoList } from './world-info.js';
export function getContext() {
return {
accountStorage,
chat,
characters,
groups,
@ -175,6 +179,20 @@ export function getContext() {
humanizedDateTime,
updateMessageBlock,
appendMediaToMessage,
variables: {
local: {
get: getLocalVariable,
set: setLocalVariable,
},
global: {
get: getGlobalVariable,
set: setGlobalVariable,
},
},
loadWorldInfo,
saveWorldInfo,
updateWorldInfoList,
convertCharacterBook,
};
}

View File

@ -146,5 +146,5 @@
</div>
<hr>
<div id="rawPromptPopup" class="list-group">
<div id="rawPromptWrapper" class="tokenItemizingSubclass"></div>
<div id="rawPromptWrapper" class="tokenItemizingMaintext"></div>
</div>

View File

@ -6,6 +6,7 @@ import { tokenizers } from './tokenizers.js';
import { renderTemplateAsync } from './templates.js';
import { POPUP_TYPE, callGenericPopup } from './popup.js';
import { t } from './i18n.js';
import { accountStorage } from './util/AccountStorage.js';
let mancerModels = [];
let togetherModels = [];
@ -54,6 +55,17 @@ const OPENROUTER_PROVIDERS = [
'xAI',
'Cloudflare',
'SF Compute',
'Minimax',
'Nineteen',
'Liquid',
'InferenceNet',
'Friendli',
'AionLabs',
'Alibaba',
'Nebius',
'Chutes',
'Kluster',
'Targon',
'01.AI',
'HuggingFace',
'Mancer',
@ -330,7 +342,7 @@ export async function loadFeatherlessModels(data) {
populateClassSelection(data);
// Retrieve the stored number of items per page or default to 10
const perPage = Number(localStorage.getItem(storageKey)) || 10;
const perPage = Number(accountStorage.getItem(storageKey)) || 10;
// Initialize pagination
applyFiltersAndSort();
@ -406,7 +418,7 @@ export async function loadFeatherlessModels(data) {
},
afterSizeSelectorChange: function (e) {
const newPerPage = e.target.value;
localStorage.setItem('Models_PerPage', newPerPage);
accountStorage.setItem(storageKey, newPerPage);
setupPagination(models, Number(newPerPage), featherlessCurrentPage); // Use the stored current page number
},
});
@ -507,7 +519,7 @@ export async function loadFeatherlessModels(data) {
const currentModelIndex = filteredModels.findIndex(x => x.id === textgen_settings.featherless_model);
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
setupPagination(filteredModels, Number(accountStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
}
// Required to keep the /model command function

View File

@ -10,6 +10,7 @@ import {
setOnlineStatus,
substituteParams,
} from '../script.js';
import { t } from './i18n.js';
import { BIAS_CACHE, createNewLogitBiasEntry, displayLogitBias, getLogitBiasListResult } from './logit-bias.js';
import { power_user, registerDebugFunction } from './power-user.js';
@ -172,6 +173,7 @@ const settings = {
//truncation_length: 2048,
ban_eos_token: false,
skip_special_tokens: true,
include_reasoning: true,
streaming: false,
mirostat_mode: 0,
mirostat_tau: 5,
@ -181,6 +183,8 @@ const settings = {
grammar_string: '',
json_schema: {},
banned_tokens: '',
global_banned_tokens: '',
send_banned_tokens: true,
sampler_priority: OOBA_DEFAULT_ORDER,
samplers: LLAMACPP_DEFAULT_ORDER,
samplers_priorities: APHRODITE_DEFAULT_ORDER,
@ -263,6 +267,7 @@ export const setting_names = [
'add_bos_token',
'ban_eos_token',
'skip_special_tokens',
'include_reasoning',
'streaming',
'mirostat_mode',
'mirostat_tau',
@ -272,6 +277,8 @@ export const setting_names = [
'grammar_string',
'json_schema',
'banned_tokens',
'global_banned_tokens',
'send_banned_tokens',
'ignore_eos_token',
'spaces_between_special_tokens',
'speculative_ngram',
@ -304,7 +311,7 @@ export function validateTextGenUrl() {
const formattedUrl = formatTextGenURL(url);
if (!formattedUrl) {
toastr.error('Enter a valid API URL', 'Text Completion API');
toastr.error(t`Enter a valid API URL`, 'Text Completion API');
return;
}
@ -392,7 +399,7 @@ function getTokenizerForTokenIds() {
* @returns {TokenBanResult} String with comma-separated banned token IDs
*/
function getCustomTokenBans() {
if (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length) {
if (!settings.send_banned_tokens || (!settings.banned_tokens && !settings.global_banned_tokens && !textgenerationwebui_banned_in_macros.length)) {
return {
banned_tokens: '',
banned_strings: [],
@ -402,8 +409,9 @@ function getCustomTokenBans() {
const tokenizer = getTokenizerForTokenIds();
const banned_tokens = [];
const banned_strings = [];
const sequences = settings.banned_tokens
.split('\n')
const sequences = []
.concat(settings.banned_tokens.split('\n'))
.concat(settings.global_banned_tokens.split('\n'))
.concat(textgenerationwebui_banned_in_macros)
.filter(x => x.length > 0)
.filter(onlyUnique);
@ -450,6 +458,18 @@ function getCustomTokenBans() {
};
}
/**
* Sets the banned strings kill switch toggle.
* @param {boolean} isEnabled Kill switch state
* @param {string} title Label title
*/
function toggleBannedStringsKillSwitch(isEnabled, title) {
$('#send_banned_tokens_textgenerationwebui').prop('checked', isEnabled);
$('#send_banned_tokens_label').find('.menu_button').toggleClass('toggleEnabled', isEnabled).prop('title', title);
settings.send_banned_tokens = isEnabled;
saveSettingsDebounced();
}
/**
* Calculates logit bias object from the logit bias list.
* @returns {object} Logit bias object
@ -501,7 +521,7 @@ export function loadTextGenSettings(data, loadedSettings) {
for (const [type, selector] of Object.entries(SERVER_INPUTS)) {
const control = $(selector);
control.val(settings.server_urls[type] ?? '').on('input', function () {
settings.server_urls[type] = String($(this).val());
settings.server_urls[type] = String($(this).val()).trim();
saveSettingsDebounced();
});
}
@ -592,6 +612,14 @@ function sortAphroditeItemsByOrder(orderArray) {
}
jQuery(function () {
$('#send_banned_tokens_textgenerationwebui').on('change', function () {
const checked = !!$(this).prop('checked');
toggleBannedStringsKillSwitch(checked,
checked
? t`Banned tokens/strings are being sent in the request.`
: t`Banned tokens/strings are NOT being sent in the request.`);
});
$('#koboldcpp_order').sortable({
delay: getSortableDelay(),
stop: function () {
@ -740,6 +768,7 @@ jQuery(function () {
'add_bos_token_textgenerationwebui': true,
'temperature_last_textgenerationwebui': true,
'skip_special_tokens_textgenerationwebui': true,
'include_reasoning_textgenerationwebui': true,
'top_a_textgenerationwebui': 0,
'top_a_counter_textgenerationwebui': 0,
'mirostat_mode_textgenerationwebui': 0,
@ -929,6 +958,10 @@ function setSettingByName(setting, value, trigger) {
if (isCheckbox) {
const val = Boolean(value);
$(`#${setting}_textgenerationwebui`).prop('checked', val);
if ('send_banned_tokens' === setting) {
$(`#${setting}_textgenerationwebui`).trigger('change');
}
}
else if (isText) {
$(`#${setting}_textgenerationwebui`).val(value);
@ -986,7 +1019,7 @@ export async function generateTextGenWithStreaming(generate_data, signal) {
let logprobs = null;
const swipes = [];
const toolCalls = [];
const state = {};
const state = { reasoning: '' };
while (true) {
const { done, value } = await reader.read();
if (done) return;
@ -1003,6 +1036,7 @@ export async function generateTextGenWithStreaming(generate_data, signal) {
const newText = data?.choices?.[0]?.text || data?.content || '';
text += newText;
logprobs = parseTextgenLogprobs(newText, data.choices?.[0]?.logprobs || data?.completion_probabilities);
state.reasoning += data?.choices?.[0]?.reasoning ?? '';
}
yield { text, swipes, logprobs, toolCalls, state };
@ -1153,7 +1187,7 @@ export function getTextGenModel() {
return settings.aphrodite_model;
case OLLAMA:
if (!settings.ollama_model) {
toastr.error('No Ollama model selected.', 'Text Completion API');
toastr.error(t`No Ollama model selected.`, 'Text Completion API');
throw new Error('No Ollama model selected');
}
return settings.ollama_model;
@ -1217,7 +1251,7 @@ function replaceMacrosInList(str) {
}
}
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
export async function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
const dynatemp = isDynamicTemperatureSupported();
const { banned_tokens, banned_strings } = getCustomTokenBans();
@ -1266,6 +1300,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
'truncation_length': max_context,
'ban_eos_token': settings.ban_eos_token,
'skip_special_tokens': settings.skip_special_tokens,
'include_reasoning': settings.include_reasoning,
'top_a': settings.top_a,
'tfs': settings.tfs,
'epsilon_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.epsilon_cutoff : undefined,
@ -1444,7 +1479,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
}
}
eventSource.emitAndWait(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
await eventSource.emit(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
// Grammar conflicts with with json_schema
if (settings.type === LLAMACPP) {

View File

@ -679,6 +679,9 @@ export function getTokenizerModel() {
}
if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {
if (oai_settings.perplexity_model.includes('sonar-reasoning') || oai_settings.perplexity_model.includes('r1-1776')) {
return deepseekTokenizer;
}
if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {
return llama3Tokenizer;
}
@ -691,6 +694,9 @@ export function getTokenizerModel() {
}
if (oai_settings.chat_completion_source === chat_completion_sources.GROQ) {
if (oai_settings.groq_model.includes('qwen')) {
return qwen2Tokenizer;
}
if (oai_settings.groq_model.includes('llama-3') || oai_settings.groq_model.includes('llama3')) {
return llama3Tokenizer;
}

View File

@ -563,6 +563,7 @@ export class ToolManager {
chat_completion_sources.OPENROUTER,
chat_completion_sources.GROQ,
chat_completion_sources.COHERE,
chat_completion_sources.DEEPSEEK,
];
return supportedSources.includes(oai_settings.chat_completion_source);
}

View File

@ -9,6 +9,9 @@ import { ensureImageFormatSupported, getBase64Async, humanFileSize } from './uti
export let currentUser = null;
export let accountsEnabled = false;
// Extend the session every 30 minutes
const SESSION_EXTEND_INTERVAL = 30 * 60 * 1000;
/**
* Enable or disable user account controls in the UI.
* @param {boolean} isEnabled User account controls enabled
@ -43,6 +46,14 @@ export function isAdmin() {
return Boolean(currentUser.admin);
}
/**
* Gets the handle string of the current user.
* @returns {string} User handle
*/
export function getCurrentUserHandle() {
return currentUser?.handle || 'default-user';
}
/**
* Get the current user.
* @returns {Promise<void>}
@ -886,6 +897,24 @@ async function slugify(text) {
}
}
/**
* Pings the server to extend the user session.
*/
async function extendUserSession() {
try {
const response = await fetch('/api/ping?extend=1', {
method: 'GET',
headers: getRequestHeaders(),
});
if (!response.ok) {
throw new Error('Ping did not succeed', { cause: response.status });
}
} catch (error) {
console.error('Failed to extend user session', error);
}
}
jQuery(() => {
$('#logout_button').on('click', () => {
logout();
@ -896,4 +925,9 @@ jQuery(() => {
$('#account_button').on('click', () => {
openUserProfile();
});
setInterval(async () => {
if (currentUser) {
await extendUserSession();
}
}, SESSION_EXTEND_INTERVAL);
});

View File

@ -0,0 +1,139 @@
import { saveSettingsDebounced } from '../../script.js';
const MIGRATED_MARKER = '__migrated';
const MIGRATABLE_KEYS = [
/^AlertRegex_/,
/^AlertWI_/,
/^Assets_SkipConfirm_/,
/^Characters_PerPage$/,
/^DataBank_sortField$/,
/^DataBank_sortOrder$/,
/^extension_update_nag$/,
/^extensions_sortByName$/,
/^FeatherlessModels_PerPage$/,
/^GroupMembers_PerPage$/,
/^GroupCandidates_PerPage$/,
/^LNavLockOn$/,
/^LNavOpened$/,
/^mediaWarningShown:/,
/^NavLockOn$/,
/^NavOpened$/,
/^Personas_PerPage$/,
/^Personas_GridView$/,
/^Proxy_SkipConfirm_/,
/^qr--executeShortcut$/,
/^qr--syntax$/,
/^qr--tabSize$/,
/^qr--wrap$/,
/^RegenerateWithCtrlEnter$/,
/^SelectedNavTab$/,
/^sendAsNamelessWarningShown$/,
/^StoryStringValidationCache$/,
/^WINavOpened$/,
/^WI_PerPage$/,
/^world_info_sort_order$/,
];
/**
* Provides access to account storage of arbitrary key-value pairs.
*/
class AccountStorage {
/**
* @type {Record<string, string>} Storage state
*/
#state = {};
/**
* @type {boolean} If the storage was initialized
*/
#ready = false;
#migrateLocalStorage() {
const localStorageKeys = [];
for (let i = 0; i < globalThis.localStorage.length; i++) {
localStorageKeys.push(globalThis.localStorage.key(i));
}
for (const key of localStorageKeys) {
if (MIGRATABLE_KEYS.some(k => k.test(key))) {
const value = globalThis.localStorage.getItem(key);
this.#state[key] = value;
globalThis.localStorage.removeItem(key);
}
}
}
/**
* Initialize the account storage.
* @param {Object} state Initial state
*/
init(state) {
if (state && typeof state === 'object') {
this.#state = Object.assign(this.#state, state);
}
if (!Object.hasOwn(this.#state, MIGRATED_MARKER)) {
this.#migrateLocalStorage();
this.#state[MIGRATED_MARKER] = '1';
saveSettingsDebounced();
}
this.#ready = true;
}
/**
* Get the value of a key in account storage.
* @param {string} key Key to get
* @returns {string|null} Value of the key
*/
getItem(key) {
if (!this.#ready) {
console.warn(`AccountStorage not ready (trying to read from ${key})`);
}
return Object.hasOwn(this.#state, key) ? String(this.#state[key]) : null;
}
/**
* Set a key in account storage.
* @param {string} key Key to set
* @param {string} value Value to set
*/
setItem(key, value) {
if (!this.#ready) {
console.warn(`AccountStorage not ready (trying to write to ${key})`);
}
this.#state[key] = String(value);
saveSettingsDebounced();
}
/**
* Remove a key from account storage.
* @param {string} key Key to remove
*/
removeItem(key) {
if (!this.#ready) {
console.warn(`AccountStorage not ready (trying to remove ${key})`);
}
if (!Object.hasOwn(this.#state, key)) {
return;
}
delete this.#state[key];
saveSettingsDebounced();
}
/**
* Gets a snapshot of the storage state.
* @returns {Record<string, string>} A deep clone of the storage state
*/
getState() {
return structuredClone(this.#state);
}
}
/**
* Account storage instance.
*/
export const accountStorage = new AccountStorage();

View File

@ -8,7 +8,7 @@ import {
import { getContext } from './extensions.js';
import { characters, getRequestHeaders, this_chid } from '../script.js';
import { isMobile } from './RossAscends-mods.js';
import { collapseNewlines } from './power-user.js';
import { collapseNewlines, power_user } from './power-user.js';
import { debounce_timeout } from './constants.js';
import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
@ -676,6 +676,19 @@ export function sortByCssOrder(a, b) {
return _a - _b;
}
/**
* Trims leading and trailing whitespace from the input string based on a configuration setting.
* @param {string} input - The string to be trimmed
* @returns {string} The trimmed string if trimming is enabled; otherwise, returns the original string
*/
export function trimSpaces(input) {
if (!input || typeof input !== 'string') {
return input;
}
return power_user.trim_spaces ? input.trim() : input;
}
/**
* Trims a string to the end of a nearest sentence.
* @param {string} input The string to trim.
@ -994,13 +1007,18 @@ export function getImageSizeFromDataURL(dataUrl) {
});
}
export function getCharaFilename(chid) {
/**
* Gets the filename of the character avatar without extension
* @param {number?} [chid=null] - Character ID. If not provided, uses the current character ID
* @param {object} [options={}] - Options arguments
* @param {string?} [options.manualAvatarKey=null] - Manually take the following avatar key, instead of using the chid to determine the name
* @returns {string?} The filename of the character avatar without extension, or null if the character ID is invalid
*/
export function getCharaFilename(chid = null, { manualAvatarKey = null } = {}) {
const context = getContext();
const fileName = context.characters[chid ?? context.characterId]?.avatar;
const fileName = manualAvatarKey ?? context.characters[chid ?? context.characterId]?.avatar;
if (fileName) {
return fileName.replace(/\.[^/.]+$/, '');
}
return fileName?.replace(/\.[^/.]+$/, '') ?? null;
}
/**
@ -1733,17 +1751,17 @@ export function hasAnimation(control) {
/**
* Run an action once an animation on a control ends. If the control has no animation, the action will be executed immediately.
*
* The action will be executed after the animation ends or after the timeout, whichever comes first.
* @param {HTMLElement} control - The control element to listen for animation end event
* @param {(control:*?) => void} callback - The callback function to be executed when the animation ends
* @param {number} [timeout=500] - The timeout in milliseconds to wait for the animation to end before executing the callback
*/
export function runAfterAnimation(control, callback) {
export function runAfterAnimation(control, callback, timeout = 500) {
if (hasAnimation(control)) {
const onAnimationEnd = () => {
control.removeEventListener('animationend', onAnimationEnd);
callback(control);
};
control.addEventListener('animationend', onAnimationEnd);
Promise.race([
new Promise((r) => setTimeout(r, timeout)), // Fallback timeout
new Promise((r) => control.addEventListener('animationend', r, { once: true })),
]).finally(() => callback(control));
} else {
callback(control);
}
@ -2059,6 +2077,23 @@ export function toggleDrawer(drawer, expand = true) {
}
}
/**
* Sets or removes a dataset property on an HTMLElement
*
* Utility function to make it easier to reset dataset properties on null, without them being "null" as value.
*
* @param {HTMLElement} element - The element to modify
* @param {string} name - The name of the dataset property
* @param {string|null} value - The value to set - If null, the dataset property will be removed
*/
export function setDatasetProperty(element, name, value) {
if (value === null) {
delete element.dataset[name];
} else {
element.dataset[name] = value;
}
}
export async function fetchFaFile(name) {
const style = document.createElement('style');
style.innerHTML = await (await fetch(`/css/${name}`)).text();

View File

@ -19,7 +19,7 @@ import { isFalseBoolean, convertValueType, isTrueBoolean } from './utils.js';
const MAX_LOOPS = 100;
function getLocalVariable(name, args = {}) {
export function getLocalVariable(name, args = {}) {
if (!chat_metadata.variables) {
chat_metadata.variables = {};
}
@ -45,7 +45,7 @@ function getLocalVariable(name, args = {}) {
return (localVariable?.trim?.() === '' || isNaN(Number(localVariable))) ? (localVariable || '') : Number(localVariable);
}
function setLocalVariable(name, value, args = {}) {
export function setLocalVariable(name, value, args = {}) {
if (!name) {
throw new Error('Variable name cannot be empty or undefined.');
}
@ -80,7 +80,7 @@ function setLocalVariable(name, value, args = {}) {
return value;
}
function getGlobalVariable(name, args = {}) {
export function getGlobalVariable(name, args = {}) {
let globalVariable = extension_settings.variables.global[args.key ?? name];
if (args.index !== undefined) {
try {
@ -102,7 +102,7 @@ function getGlobalVariable(name, args = {}) {
return (globalVariable?.trim?.() === '' || isNaN(Number(globalVariable))) ? (globalVariable || '') : Number(globalVariable);
}
function setGlobalVariable(name, value, args = {}) {
export function setGlobalVariable(name, value, args = {}) {
if (!name) {
throw new Error('Variable name cannot be empty or undefined.');
}

View File

@ -21,6 +21,7 @@ import { callGenericPopup, Popup, POPUP_TYPE } from './popup.js';
import { StructuredCloneMap } from './util/StructuredCloneMap.js';
import { renderTemplateAsync } from './templates.js';
import { t } from './i18n.js';
import { accountStorage } from './util/AccountStorage.js';
export const world_info_insertion_strategy = {
evenly: 0,
@ -399,6 +400,12 @@ class WorldInfoTimedEffects {
*/
#entries = [];
/**
* Is this a dry run?
* @type {boolean}
*/
#isDryRun = false;
/**
* Buffer for active timed effects.
* @type {Record<TimedEffectType, WIScanEntry[]>}
@ -448,10 +455,12 @@ class WorldInfoTimedEffects {
* Initialize the timed effects with the given messages.
* @param {string[]} chat Array of chat messages
* @param {WIScanEntry[]} entries Array of entries
* @param {boolean} isDryRun Whether the operation is a dry run
*/
constructor(chat, entries) {
constructor(chat, entries, isDryRun = false) {
this.#chat = chat;
this.#entries = entries;
this.#isDryRun = isDryRun;
this.#ensureChatMetadata();
}
@ -583,8 +592,10 @@ class WorldInfoTimedEffects {
* Checks for timed effects on chat messages.
*/
checkTimedEffects() {
if (!this.#isDryRun) {
this.#checkTimedEffectOfType('sticky', this.#buffer.sticky, this.#onEnded.sticky.bind(this));
this.#checkTimedEffectOfType('cooldown', this.#buffer.cooldown, this.#onEnded.cooldown.bind(this));
}
this.#checkDelayEffect(this.#buffer.delay);
}
@ -629,6 +640,7 @@ class WorldInfoTimedEffects {
* @param {WIScanEntry[]} activatedEntries Entries that were activated
*/
setTimedEffects(activatedEntries) {
if (this.#isDryRun) return;
for (const entry of activatedEntries) {
this.#setTimedEffectOfType('sticky', entry);
this.#setTimedEffectOfType('cooldown', entry);
@ -645,6 +657,9 @@ class WorldInfoTimedEffects {
if (!this.isValidEffectType(type)) {
return;
}
if (this.#isDryRun && type !== 'delay') {
return;
}
const key = this.#getEntryKey(entry);
delete chat_metadata.timedWorldInfo[type][key];
@ -858,7 +873,7 @@ export function setWorldInfoSettings(settings, data) {
$('#world_editor_select').append(`<option value='${i}'>${item}</option>`);
});
$('#world_info_sort_order').val(localStorage.getItem(SORT_ORDER_KEY) || '0');
$('#world_info_sort_order').val(accountStorage.getItem(SORT_ORDER_KEY) || '0');
$('#world_info').trigger('change');
$('#world_editor_select').trigger('change');
@ -1708,7 +1723,7 @@ export async function loadWorldInfo(name) {
return null;
}
async function updateWorldInfoList() {
export async function updateWorldInfoList() {
const result = await fetch('/api/settings/get', {
method: 'POST',
headers: getRequestHeaders(),
@ -1933,13 +1948,13 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
if (typeof navigation === 'number' && Number(navigation) >= 0) {
const data = getDataArray();
const uidIndex = data.findIndex(x => x.uid === navigation);
const perPage = Number(localStorage.getItem(storageKey)) || perPageDefault;
const perPage = Number(accountStorage.getItem(storageKey)) || perPageDefault;
startPage = Math.floor(uidIndex / perPage) + 1;
}
$('#world_info_pagination').pagination({
dataSource: getDataArray,
pageSize: Number(localStorage.getItem(storageKey)) || perPageDefault,
pageSize: Number(accountStorage.getItem(storageKey)) || perPageDefault,
sizeChangerOptions: [10, 25, 50, 100, 500, 1000],
showSizeChanger: true,
pageRange: 1,
@ -1969,7 +1984,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
worldEntriesList.append(blocks);
},
afterSizeSelectorChange: function (e) {
localStorage.setItem(storageKey, e.target.value);
accountStorage.setItem(storageKey, e.target.value);
},
afterPaging: function () {
$('#world_popup_entries_list textarea[name="comment"]').each(function () {
@ -2174,7 +2189,7 @@ function verifyWorldInfoSearchSortRule() {
// If search got cleared, we make sure to hide the option and go back to the one before
if (!searchTerm && !isHidden) {
searchOption.attr('hidden', '');
selector.val(localStorage.getItem(SORT_ORDER_KEY) || '0');
selector.val(accountStorage.getItem(SORT_ORDER_KEY) || '0');
}
}
@ -2423,7 +2438,9 @@ export async function getWorldEntry(name, data, entry) {
setWIOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]);
await saveWorldInfo(name, data);
}
$(this).toggleClass('empty', !data.entries[uid][entryPropName].length);
});
input.toggleClass('empty', !entry[entryPropName].length);
input.on('select2:select', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data]));
input.on('select2:unselect', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data], { remove: true }));
@ -2458,6 +2475,7 @@ export async function getWorldEntry(name, data, entry) {
data.entries[uid][entryPropName] = splitKeywordsAndRegexes(value);
setWIOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]);
await saveWorldInfo(name, data);
$(this).toggleClass('empty', !data.entries[uid][entryPropName].length);
}
});
input.val(entry[entryPropName].join(', ')).trigger('input', { skipReset: true });
@ -3435,7 +3453,7 @@ async function _save(name, data) {
headers: getRequestHeaders(),
body: JSON.stringify({ name: name, data: data }),
});
eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
await eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
}
@ -3847,7 +3865,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
const context = getContext();
const buffer = new WorldInfoBuffer(chat);
console.debug(`[WI] --- START WI SCAN (on ${chat.length} messages) ---`);
console.debug(`[WI] --- START WI SCAN (on ${chat.length} messages)${isDryRun ? ' (DRY RUN)' : ''} ---`);
// Combine the chat
@ -3879,9 +3897,9 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
console.debug(`[WI] Context size: ${maxContext}; WI budget: ${budget} (max% = ${world_info_budget}%, cap = ${world_info_budget_cap})`);
const sortedEntries = await getSortedEntries();
const timedEffects = new WorldInfoTimedEffects(chat, sortedEntries);
const timedEffects = new WorldInfoTimedEffects(chat, sortedEntries, isDryRun);
!isDryRun && timedEffects.checkTimedEffects();
timedEffects.checkTimedEffects();
if (sortedEntries.length === 0) {
return { worldInfoBefore: '', worldInfoAfter: '', WIDepthEntries: [], EMEntries: [], allActivatedEntries: new Set() };
@ -4324,12 +4342,12 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
context.setExtensionPrompt(NOTE_MODULE_NAME, ANWithWI, chat_metadata[metadata_keys.position], chat_metadata[metadata_keys.depth], extension_settings.note.allowWIScan, chat_metadata[metadata_keys.role]);
}
!isDryRun && timedEffects.setTimedEffects(Array.from(allActivatedEntries.values()));
timedEffects.setTimedEffects(Array.from(allActivatedEntries.values()));
buffer.resetExternalEffects();
timedEffects.cleanUp();
console.log(`[WI] Adding ${allActivatedEntries.size} entries to prompt`, Array.from(allActivatedEntries.values()));
console.debug('[WI] --- DONE ---');
console.log(`[WI] ${isDryRun ? 'Hypothetically adding' : 'Adding'} ${allActivatedEntries.size} entries to prompt`, Array.from(allActivatedEntries.values()));
console.debug(`[WI] --- DONE${isDryRun ? ' (DRY RUN)' : ''} ---`);
return { worldInfoBefore, worldInfoAfter, EMEntries, WIDepthEntries, allActivatedEntries: new Set(allActivatedEntries.values()) };
}
@ -4658,7 +4676,7 @@ function convertNovelLorebook(inputObj) {
return outputObj;
}
function convertCharacterBook(characterBook) {
export function convertCharacterBook(characterBook) {
const result = { entries: {}, originalData: characterBook };
characterBook.entries.forEach((entry, index) => {
@ -4736,8 +4754,8 @@ export function checkEmbeddedWorld(chid) {
// Only show the alert once per character
const checkKey = `AlertWI_${characters[chid].avatar}`;
const worldName = characters[chid]?.data?.extensions?.world;
if (!localStorage.getItem(checkKey) && (!worldName || !world_names.includes(worldName))) {
localStorage.setItem(checkKey, 'true');
if (!accountStorage.getItem(checkKey) && (!worldName || !world_names.includes(worldName))) {
accountStorage.setItem(checkKey, 'true');
if (power_user.world_import_dialog) {
const html = `<h3>This character has an embedded World/Lorebook.</h3>
@ -5181,7 +5199,7 @@ jQuery(() => {
$('#world_info_sort_order').on('change', function () {
const value = String($(this).find(':selected').val());
// Save sort order, but do not save search sorting, as this is a temporary sorting option
if (value !== 'search') localStorage.setItem(SORT_ORDER_KEY, value);
if (value !== 'search') accountStorage.setItem(SORT_ORDER_KEY, value);
updateEditor(navigation_option.none);
});

View File

@ -55,6 +55,10 @@
--interactable-outline-color: var(--white100);
--interactable-outline-color-faint: var(--white20a);
--reasoning-body-color: var(--SmartThemeEmColor);
--reasoning-em-color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
--reasoning-saturation: 0.5;
/*Default Theme, will be changed by ToolCool Color Picker*/
--SmartThemeBodyColor: rgb(220, 220, 210);
@ -106,6 +110,8 @@
--tool-cool-color-picker-btn-bg: transparent;
--tool-cool-color-picker-btn-border-color: transparent;
--mes-right-spacing: 30px;
--avatar-base-height: 50px;
--avatar-base-width: 50px;
--avatar-base-border-radius: 2px;
@ -291,6 +297,10 @@ input[type='checkbox']:focus-visible {
color: var(--SmartThemeEmColor);
}
.tokenItemizingMaintext {
font-size: calc(var(--mainFontSize) * 0.8);
}
.tokenGraph {
border-radius: 10px;
border: 1px solid var(--SmartThemeBorderColor);
@ -373,18 +383,56 @@ input[type='checkbox']:focus-visible {
.mes_reasoning {
display: block;
border: 1px solid var(--SmartThemeBorderColor);
background-color: var(--black30a);
border-radius: 5px;
border-left: 2px solid var(--reasoning-body-color);
border-radius: 2px;
padding: 5px;
margin: 5px 0;
padding-left: 14px;
margin-bottom: 0.5em;
overflow-y: auto;
color: hsl(from var(--reasoning-body-color) h calc(s * var(--reasoning-saturation)) l);
}
.mes_reasoning_summary {
.mes_reasoning_details {
margin-right: var(--mes-right-spacing);
}
.mes_reasoning_details .mes_reasoning_summary {
list-style: none;
margin-right: calc(var(--mes-right-spacing) * -1);
}
.mes_reasoning_details summary::-webkit-details-marker {
display: none;
}
.mes_reasoning *:last-child {
margin-bottom: 0;
}
.mes_reasoning_header_block {
flex-grow: 1;
}
.mes_reasoning_header {
cursor: pointer;
position: relative;
margin: 2px;
user-select: none;
margin: 0.5em 2px;
padding: 7px 14px;
padding-right: calc(0.7em + 14px);
border-radius: 5px;
background-color: var(--grey30);
font-size: calc(var(--mainFontSize) * 0.9);
align-items: baseline;
}
.mes:has(.mes_reasoning:empty) .mes_reasoning_header {
cursor: default;
}
/* TWIMC: Remove with custom CSS to show the icon */
.mes_reasoning_header>.icon-svg {
display: none;
}
@supports not selector(:has(*)) {
@ -394,29 +442,41 @@ input[type='checkbox']:focus-visible {
}
.mes_bias:empty,
.mes_reasoning:empty,
.mes_reasoning_details:has(.mes_reasoning:empty),
.mes_block:has(.edit_textarea) .mes_reasoning_details,
.mes:not(.reasoning) .mes_reasoning_details,
.mes_reasoning_details:not([open]) .mes_reasoning_actions,
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning,
.mes_reasoning_details:not(:has(.reasoning_edit_textarea)) .mes_reasoning_actions .mes_button.mes_reasoning_edit_done,
.mes_reasoning_details:not(:has(.reasoning_edit_textarea)) .mes_reasoning_actions .mes_button.mes_reasoning_edit_cancel,
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning_actions .mes_button:not(.mes_reasoning_edit_done, .mes_reasoning_edit_cancel) {
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning_header,
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning_actions .mes_button:not(.edit_button),
.mes_reasoning_details:not(:has(.reasoning_edit_textarea)) .mes_reasoning_actions .edit_button,
.mes_block:has(.edit_textarea):has(.reasoning_edit_textarea) .mes_reasoning_actions,
.mes.reasoning:not([data-reasoning-state="hidden"]) .mes_edit_add_reasoning,
.mes:has(.mes_reasoning:empty) .mes_reasoning_arrow,
.mes:has(.mes_reasoning:empty) .mes_reasoning,
.mes:has(.mes_reasoning:empty) .mes_reasoning_copy {
display: none;
}
.mes_reasoning_actions {
position: absolute;
right: 0;
top: 0;
.mes[data-reasoning-state="hidden"] .mes_edit_add_reasoning {
background-color: color-mix(in srgb, var(--SmartThemeQuoteColor) 33%, var(--SmartThemeBlurTintColor) 66%);
}
display: flex;
gap: 4px;
flex-wrap: nowrap;
justify-content: flex-end;
transition: all 200ms;
overflow-x: hidden;
padding: 1px;
/** If hidden reasoning should not be shown, we hide all blocks that don't have content */
#chat:not([data-show-hidden-reasoning="true"]):not(:has(.reasoning_edit_textarea)) .mes:has(.mes_reasoning:empty) .mes_reasoning_details {
display: none;
}
.mes_reasoning_details .mes_reasoning_arrow {
position: absolute;
top: 50%;
right: 7px;
transform: translateY(-50%);
font-size: calc(var(--mainFontSize) * 0.7);
width: calc(var(--mainFontSize) * 0.7);
height: calc(var(--mainFontSize) * 0.7);
}
.mes_reasoning_details:not([open]) .mes_reasoning_arrow {
transform: translateY(-50%) rotate(180deg);
}
.mes_reasoning_summary>span {
@ -424,21 +484,36 @@ input[type='checkbox']:focus-visible {
}
.mes_text i,
.mes_text em,
.mes_reasoning i,
.mes_reasoning em {
.mes_text em {
color: var(--SmartThemeEmColor);
}
.mes_text u,
.mes_reasoning u {
color: var(--SmartThemeUnderlineColor);
.mes_reasoning i,
.mes_reasoning em {
color: hsl(from var(--reasoning-em-color) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text q,
.mes_reasoning q {
.mes_text q i,
.mes_text q em {
color: inherit;
}
.mes_reasoning q i,
.mes_reasoning q em {
color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text u {
color: var(--SmartThemeUnderlineColor);
}
.mes_reasoning u {
color: hsl(from var(--SmartThemeUnderlineColor) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text q {
color: var(--SmartThemeQuoteColor);
}
.mes_reasoning q {
color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text font[color] em,
.mes_text font[color] i,
@ -1126,13 +1201,8 @@ body .panelControlBar {
/*only affects bubblechat to make it sit nicely at the bottom*/
}
.last_mes:has(.mes_text:empty):has(.mes_reasoning_details[open]) .mes_reasoning:not(:empty) {
margin-bottom: 30px;
}
.last_mes .mes_reasoning,
.last_mes .mes_text {
padding-right: 30px;
.last_mes:has(.mes_text:empty):has(.mes_reasoning_details) .mes_reasoning:not(:empty) {
margin-bottom: var(--mes-right-spacing);
}
/* SWIPE RELATED STYLES*/
@ -1363,6 +1433,7 @@ body.swipeAllMessages .mes:not(.last_mes) .swipes-counter {
padding-left: 0;
padding-top: 5px;
padding-bottom: 5px;
padding-right: var(--mes-right-spacing);
}
br {
@ -2849,9 +2920,8 @@ select option:not(:checked) {
color: var(--active) !important;
}
#instruct_enabled_label .menu_button:not(.toggleEnabled),
#sysprompt_enabled_label .menu_button:not(.toggleEnabled) {
color: Red;
.menu_button.togglable:not(.toggleEnabled) {
color: red;
}
.displayBlock {
@ -3048,6 +3118,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
.mes_block .ch_name {
max-width: 100%;
min-height: 22px;
align-items: flex-start;
}
/*applies to both groups and solos chars in the char list*/
@ -4275,7 +4346,13 @@ input[type="range"]::-webkit-slider-thumb {
transition: 0.3s ease-in-out;
}
.mes_edit_buttons .menu_button {
.mes_reasoning_actions {
margin: 0;
margin-top: 0.5em;
}
.mes_edit_buttons .menu_button,
.mes_reasoning_actions .edit_button {
opacity: 0.5;
padding: 0px;
font-size: 1rem;
@ -4288,6 +4365,12 @@ input[type="range"]::-webkit-slider-thumb {
align-items: center;
}
.mes_reasoning_actions .edit_button {
margin-bottom: 0.5em;
opacity: 1;
filter: brightness(0.7);
}
.mes_reasoning_edit_cancel,
.mes_edit_cancel.menu_button {
background-color: var(--crimson70a);
@ -4314,6 +4397,14 @@ input[type="range"]::-webkit-slider-thumb {
field-sizing: content;
}
body[data-generating="true"] #send_but,
body[data-generating="true"] #mes_continue,
body[data-generating="true"] #mes_impersonate,
body[data-generating="true"] #chat .last_mes .mes_buttons,
body[data-generating="true"] #chat .last_mes .mes_reasoning_actions {
display: none;
}
#anchor_order {
margin-bottom: 15px;
}
@ -4653,23 +4744,6 @@ body .ui-widget-content li:hover {
opacity: 1;
}
.typing_indicator {
position: sticky;
bottom: 10px;
margin: 10px;
opacity: 0.85;
text-shadow: 0px 0px calc(var(--shadowWidth) * 1px) var(--SmartThemeShadowColor);
order: 9999;
}
.typing_indicator:after {
display: inline-block;
vertical-align: bottom;
animation: ellipsis steps(4, end) 1500ms infinite;
content: "";
width: 0px;
}
#group_avatar_preview .missing-avatar {
display: inline;
vertical-align: middle;
@ -5758,11 +5832,13 @@ body:not(.movingUI) .drawer-content.maximized {
overflow-wrap: anywhere;
}
#SystemPromptColumn summary,
#InstructSequencesColumn summary {
font-size: 0.95em;
cursor: pointer;
}
#SystemPromptColumn details,
#InstructSequencesColumn details:not(:last-of-type) {
margin-bottom: 5px;
}
@ -5927,6 +6003,18 @@ body:not(.movingUI) .drawer-content.maximized {
flex: 1;
}
.oneline-dropdown label {
margin-top: 3px;
margin-bottom: 5px;
flex-grow: 1;
text-align: left;
}
.oneline-dropdown select {
min-width: fit-content;
width: 40%;
}
.multiline {
white-space: pre-wrap;
}

295
server.js
View File

@ -4,6 +4,7 @@
import fs from 'node:fs';
import http from 'node:http';
import https from 'node:https';
import os from 'os';
import path from 'node:path';
import util from 'node:util';
import net from 'node:net';
@ -29,6 +30,7 @@ import bodyParser from 'body-parser';
// net related library imports
import fetch from 'node-fetch';
import ipRegex from 'ip-regex';
// Unrestrict console logs display limit
util.inspect.defaultOptions.maxArrayLength = null;
@ -56,8 +58,10 @@ import {
import getWebpackServeMiddleware from './src/middleware/webpack-serve.js';
import basicAuthMiddleware from './src/middleware/basicAuth.js';
import whitelistMiddleware from './src/middleware/whitelist.js';
import accessLoggerMiddleware, { getAccessLogPath, migrateAccessLog } from './src/middleware/accessLogWriter.js';
import multerMonkeyPatch from './src/middleware/multerMonkeyPatch.js';
import initRequestProxy from './src/request-proxy.js';
import getCacheBusterMiddleware from './src/middleware/cacheBuster.js';
import {
getVersion,
getConfigValue,
@ -65,7 +69,11 @@ import {
forwardFetchResponse,
removeColorFormatting,
getSeparator,
stringToBool,
urlHostnameToIPv6,
canResolve,
safeReadFileSync,
setupLogLevel,
} from './src/util.js';
import { UPLOADS_DIRECTORY } from './src/constants.js';
import { ensureThumbnailCache } from './src/endpoints/thumbnails.js';
@ -125,6 +133,8 @@ if (process.versions && process.versions.node && process.versions.node.match(/20
const DEFAULT_PORT = 8000;
const DEFAULT_AUTORUN = false;
const DEFAULT_LISTEN = false;
const DEFAULT_LISTEN_ADDRESS_IPV6 = '[::]';
const DEFAULT_LISTEN_ADDRESS_IPV4 = '0.0.0.0';
const DEFAULT_CORS_PROXY = false;
const DEFAULT_WHITELIST = true;
const DEFAULT_ACCOUNTS = false;
@ -149,11 +159,11 @@ const DEFAULT_PROXY_BYPASS = [];
const cliArguments = yargs(hideBin(process.argv))
.usage('Usage: <your-start-script> <command> [options]')
.option('enableIPv6', {
type: 'boolean',
type: 'string',
default: null,
describe: `Enables IPv6.\n[config default: ${DEFAULT_ENABLE_IPV6}]`,
}).option('enableIPv4', {
type: 'boolean',
type: 'string',
default: null,
describe: `Enables IPv4.\n[config default: ${DEFAULT_ENABLE_IPV4}]`,
}).option('port', {
@ -180,6 +190,14 @@ const cliArguments = yargs(hideBin(process.argv))
type: 'boolean',
default: null,
describe: `SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If false, will limit it only to internal localhost (127.0.0.1).\nIf not provided falls back to yaml config 'listen'.\n[config default: ${DEFAULT_LISTEN}]`,
}).option('listenAddressIPv6', {
type: 'string',
default: null,
describe: 'Set SillyTavern to listen to a specific IPv6 address. If not set, it will fallback to listen to all.\n[config default: [::] ]',
}).option('listenAddressIPv4', {
type: 'string',
default: null,
describe: 'Set SillyTavern to listen to a specific IPv4 address. If not set, it will fallback to listen to all.\n[config default: 0.0.0.0 ]',
}).option('corsProxy', {
type: 'boolean',
default: null,
@ -226,7 +244,6 @@ const cliArguments = yargs(hideBin(process.argv))
describe: 'Request proxy URL (HTTP or SOCKS protocols)',
}).option('requestProxyBypass', {
type: 'array',
default: null,
describe: 'Request proxy bypass list (space separated list of hosts)',
}).parseSync();
@ -242,27 +259,46 @@ app.use(helmet({
app.use(compression());
app.use(responseTime());
/** @type {number} */
const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT);
/** @type {boolean} */
const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl;
/** @type {boolean} */
const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN);
/** @type {string} */
const listenAddressIPv6 = cliArguments.listenAddressIPv6 ?? getConfigValue('listenAddress.ipv6', DEFAULT_LISTEN_ADDRESS_IPV6);
/** @type {string} */
const listenAddressIPv4 = cliArguments.listenAddressIPv4 ?? getConfigValue('listenAddress.ipv4', DEFAULT_LISTEN_ADDRESS_IPV4);
/** @type {boolean} */
const enableCorsProxy = cliArguments.corsProxy ?? getConfigValue('enableCorsProxy', DEFAULT_CORS_PROXY);
const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode', DEFAULT_WHITELIST);
/** @type {string} */
const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data');
/** @type {boolean} */
const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED);
const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH);
const perUserBasicAuth = getConfigValue('perUserBasicAuth', DEFAULT_PER_USER_BASIC_AUTH);
/** @type {boolean} */
const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS);
const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY);
const enableIPv6 = cliArguments.enableIPv6 ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);
const enableIPv4 = cliArguments.enableIPv4 ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);
/** @type {boolean | "auto"} */
let enableIPv6 = stringToBool(cliArguments.enableIPv6) ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);
/** @type {boolean | "auto"} */
let enableIPv4 = stringToBool(cliArguments.enableIPv4) ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);
/** @type {string} */
const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME);
/** @type {number} */
const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT);
/** @type {boolean} */
const dnsPreferIPv6 = cliArguments.dnsPreferIPv6 ?? getConfigValue('dnsPreferIPv6', DEFAULT_PREFER_IPV6);
/** @type {boolean} */
const avoidLocalhost = cliArguments.avoidLocalhost ?? getConfigValue('avoidLocalhost', DEFAULT_AVOID_LOCALHOST);
const proxyEnabled = cliArguments.requestProxyEnabled ?? getConfigValue('requestProxy.enabled', DEFAULT_PROXY_ENABLED);
@ -279,7 +315,19 @@ if (dnsPreferIPv6) {
console.log('Preferring IPv4 for DNS resolution');
}
if (!enableIPv6 && !enableIPv4) {
const ipOptions = [true, 'auto', false];
if (!ipOptions.includes(enableIPv6)) {
console.warn(color.red('`protocol: ipv6` option invalid'), '\n use:', ipOptions, '\n setting to:', DEFAULT_ENABLE_IPV6);
enableIPv6 = DEFAULT_ENABLE_IPV6;
}
if (!ipOptions.includes(enableIPv4)) {
console.warn(color.red('`protocol: ipv4` option invalid'), '\n use:', ipOptions, '\n setting to:', DEFAULT_ENABLE_IPV4);
enableIPv4 = DEFAULT_ENABLE_IPV4;
}
if (enableIPv6 === false && enableIPv4 === false) {
console.error('error: You can\'t disable all internet protocols: at least IPv6 or IPv4 must be enabled.');
process.exit(1);
}
@ -292,9 +340,17 @@ const CORS = cors({
app.use(CORS);
if (listen && basicAuthMode) app.use(basicAuthMiddleware);
if (listen && basicAuthMode) {
app.use(basicAuthMiddleware);
}
app.use(whitelistMiddleware(enableWhitelist, listen));
if (enableWhitelist) {
app.use(whitelistMiddleware());
}
if (listen) {
app.use(accessLoggerMiddleware());
}
if (enableCorsProxy) {
app.use(bodyParser.json({
@ -364,6 +420,55 @@ function getSessionCookieAge() {
return undefined;
}
/**
* Checks the network interfaces to determine the presence of IPv6 and IPv4 addresses.
*
* @returns {Promise<[boolean, boolean, boolean, boolean]>} A promise that resolves to an array containing:
* - [0]: `hasIPv6` (boolean) - Whether the computer has any IPv6 address, including (`::1`).
* - [1]: `hasIPv4` (boolean) - Whether the computer has any IPv4 address, including (`127.0.0.1`).
* - [2]: `hasIPv6Local` (boolean) - Whether the computer has local IPv6 address (`::1`).
* - [3]: `hasIPv4Local` (boolean) - Whether the computer has local IPv4 address (`127.0.0.1`).
*/
async function getHasIP() {
let hasIPv6 = false;
let hasIPv6Local = false;
let hasIPv4 = false;
let hasIPv4Local = false;
const interfaces = os.networkInterfaces();
for (const iface of Object.values(interfaces)) {
if (iface === undefined) {
continue;
}
for (const info of iface) {
if (info.family === 'IPv6') {
hasIPv6 = true;
if (info.address === '::1') {
hasIPv6Local = true;
}
}
if (info.family === 'IPv4') {
hasIPv4 = true;
if (info.address === '127.0.0.1') {
hasIPv4Local = true;
}
}
if (hasIPv6 && hasIPv4 && hasIPv6Local && hasIPv4Local) break;
}
if (hasIPv6 && hasIPv4 && hasIPv6Local && hasIPv4Local) break;
}
return [
hasIPv6,
hasIPv4,
hasIPv6Local,
hasIPv4Local,
];
}
app.use(cookieSession({
name: getCookieSessionName(),
sameSite: 'strict',
@ -419,7 +524,7 @@ if (!disableCsrf) {
// Static files
// Host index page
app.get('/', (request, response) => {
app.get('/', getCacheBusterMiddleware(), (request, response) => {
if (shouldRedirectToLogin(request)) {
const query = request.url.split('?')[1];
const redirectUrl = query ? `/login?${query}` : '/login';
@ -459,7 +564,13 @@ app.use('/api/users', usersPublicRouter);
// Everything below this line requires authentication
app.use(requireLoginMiddleware);
app.get('/api/ping', (_, response) => response.sendStatus(204));
app.get('/api/ping', (request, response) => {
if (request.query.extend && request.session) {
request.session.touch = Date.now();
}
response.sendStatus(204);
});
// File uploads
app.use(multer({ dest: uploadsPath, limits: { fieldSize: 10 * 1024 * 1024 } }).single('avatar'));
@ -627,13 +738,13 @@ app.use('/api/azure', azureRouter);
const tavernUrlV6 = new URL(
(cliArguments.ssl ? 'https://' : 'http://') +
(listen ? '[::]' : '[::1]') +
(listen ? (ipRegex.v6({ exact: true }).test(listenAddressIPv6) ? listenAddressIPv6 : '[::]') : '[::1]') +
(':' + server_port),
);
const tavernUrl = new URL(
(cliArguments.ssl ? 'https://' : 'http://') +
(listen ? '0.0.0.0' : '127.0.0.1') +
(listen ? (ipRegex.v4({ exact: true }).test(listenAddressIPv4) ? listenAddressIPv4 : '0.0.0.0') : '127.0.0.1') +
(':' + server_port),
);
@ -657,6 +768,7 @@ const preSetupTasks = async function () {
await checkForNewContent(directories);
await ensureThumbnailCache();
cleanUploads();
migrateAccessLog();
await settingsInit();
await statsInit();
@ -693,20 +805,23 @@ const preSetupTasks = async function () {
/**
* Gets the hostname to use for autorun in the browser.
* @returns {string} The hostname to use for autorun
* @param {boolean} useIPv6 If use IPv6
* @param {boolean} useIPv4 If use IPv4
* @returns Promise<string> The hostname to use for autorun
*/
function getAutorunHostname() {
async function getAutorunHostname(useIPv6, useIPv4) {
if (autorunHostname === 'auto') {
if (enableIPv6 && enableIPv4) {
if (avoidLocalhost) return '[::1]';
return 'localhost';
let localhostResolve = await canResolve('localhost', useIPv6, useIPv4);
if (useIPv6 && useIPv4) {
return (avoidLocalhost || !localhostResolve) ? '[::1]' : 'localhost';
}
if (enableIPv6) {
if (useIPv6) {
return '[::1]';
}
if (enableIPv4) {
if (useIPv4) {
return '127.0.0.1';
}
}
@ -718,11 +833,13 @@ function getAutorunHostname() {
* Tasks that need to be run after the server starts listening.
* @param {boolean} v6Failed If the server failed to start on IPv6
* @param {boolean} v4Failed If the server failed to start on IPv4
* @param {boolean} useIPv6 If the server is using IPv6
* @param {boolean} useIPv4 If the server is using IPv4
*/
const postSetupTasks = async function (v6Failed, v4Failed) {
const postSetupTasks = async function (v6Failed, v4Failed, useIPv6, useIPv4) {
const autorunUrl = new URL(
(cliArguments.ssl ? 'https://' : 'http://') +
(getAutorunHostname()) +
(await getAutorunHostname(useIPv6, useIPv4)) +
(':') +
((autorunPortOverride >= 0) ? autorunPortOverride : server_port),
);
@ -735,36 +852,48 @@ const postSetupTasks = async function (v6Failed, v4Failed) {
let logListen = 'SillyTavern is listening on';
if (enableIPv6 && !v6Failed) {
logListen += color.green(' IPv6: ' + tavernUrlV6.host);
if (useIPv6 && !v6Failed) {
logListen += color.green(
' IPv6: ' + tavernUrlV6.host,
);
}
if (enableIPv4 && !v4Failed) {
logListen += color.green(' IPv4: ' + tavernUrl.host);
if (useIPv4 && !v4Failed) {
logListen += color.green(
' IPv4: ' + tavernUrl.host,
);
}
const goToLog = 'Go to: ' + color.blue(autorunUrl) + ' to open SillyTavern';
const plainGoToLog = removeColorFormatting(goToLog);
console.log(logListen);
if (listen) {
console.log();
console.log('To limit connections to internal localhost only ([::1] or 127.0.0.1), change the setting in config.yaml to "listen: false".');
console.log('Check the "access.log" file in the data directory to inspect incoming connections:', color.green(getAccessLogPath()));
}
console.log('\n' + getSeparator(plainGoToLog.length) + '\n');
console.log(goToLog);
console.log('\n' + getSeparator(plainGoToLog.length) + '\n');
if (listen) {
console.log('[::] or 0.0.0.0 means SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If you want to limit it only to internal localhost ([::1] or 127.0.0.1), change the setting in config.yaml to "listen: false". Check "access.log" file in the SillyTavern directory if you want to inspect incoming connections.\n');
}
if (basicAuthMode) {
if (perUserBasicAuth && !enableAccounts) {
console.error(color.red('Per-user basic authentication is enabled, but user accounts are disabled. This configuration may be insecure.'));
console.error(color.red(
'Per-user basic authentication is enabled, but user accounts are disabled. This configuration may be insecure.',
));
} else if (!perUserBasicAuth) {
const basicAuthUser = getConfigValue('basicAuthUser', {});
if (!basicAuthUser?.username || !basicAuthUser?.password) {
console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!'));
console.warn(color.yellow(
'Basic Authentication is enabled, but username or password is not set or empty!',
));
}
}
}
setupLogLevel();
};
/**
@ -814,14 +943,16 @@ function logSecurityAlert(message) {
* Handles the case where the server failed to start on one or both protocols.
* @param {boolean} v6Failed If the server failed to start on IPv6
* @param {boolean} v4Failed If the server failed to start on IPv4
* @param {boolean} useIPv6 If use IPv6
* @param {boolean} useIPv4 If use IPv4
*/
function handleServerListenFail(v6Failed, v4Failed) {
if (v6Failed && !enableIPv4) {
function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
if (v6Failed && !useIPv4) {
console.error(color.red('fatal error: Failed to start server on IPv6 and IPv4 disabled'));
process.exit(1);
}
if (v4Failed && !enableIPv6) {
if (v4Failed && !useIPv6) {
console.error(color.red('fatal error: Failed to start server on IPv4 and IPv6 disabled'));
process.exit(1);
}
@ -835,10 +966,11 @@ function handleServerListenFail(v6Failed, v4Failed) {
/**
* Creates an HTTPS server.
* @param {URL} url The URL to listen on
* @param {number} ipVersion the ip version to use
* @returns {Promise<void>} A promise that resolves when the server is listening
* @throws {Error} If the server fails to start
*/
function createHttpsServer(url) {
function createHttpsServer(url, ipVersion) {
return new Promise((resolve, reject) => {
const server = https.createServer(
{
@ -847,34 +979,56 @@ function createHttpsServer(url) {
}, app);
server.on('error', reject);
server.on('listening', resolve);
server.listen(Number(url.port || 443), url.hostname);
let host = url.hostname;
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
server.listen({
host: host,
port: Number(url.port || 443),
// see https://nodejs.org/api/net.html#serverlisten for why ipv6Only is used
ipv6Only: true,
});
});
}
/**
* Creates an HTTP server.
* @param {URL} url The URL to listen on
* @param {number} ipVersion the ip version to use
* @returns {Promise<void>} A promise that resolves when the server is listening
* @throws {Error} If the server fails to start
*/
function createHttpServer(url) {
function createHttpServer(url, ipVersion) {
return new Promise((resolve, reject) => {
const server = http.createServer(app);
server.on('error', reject);
server.on('listening', resolve);
server.listen(Number(url.port || 80), url.hostname);
let host = url.hostname;
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
server.listen({
host: host,
port: Number(url.port || 80),
// see https://nodejs.org/api/net.html#serverlisten for why ipv6Only is used
ipv6Only: true,
});
});
}
async function startHTTPorHTTPS() {
/**
* Starts the server using http or https depending on config
* @param {boolean} useIPv6 If use IPv6
* @param {boolean} useIPv4 If use IPv4
*/
async function startHTTPorHTTPS(useIPv6, useIPv4) {
let v6Failed = false;
let v4Failed = false;
const createFunc = cliArguments.ssl ? createHttpsServer : createHttpServer;
if (enableIPv6) {
if (useIPv6) {
try {
await createFunc(tavernUrlV6);
await createFunc(tavernUrlV6, 6);
} catch (error) {
console.error('non-fatal error: failed to start server on IPv6');
console.error(error);
@ -883,9 +1037,9 @@ async function startHTTPorHTTPS() {
}
}
if (enableIPv4) {
if (useIPv4) {
try {
await createFunc(tavernUrl);
await createFunc(tavernUrl, 4);
} catch (error) {
console.error('non-fatal error: failed to start server on IPv4');
console.error(error);
@ -898,10 +1052,59 @@ async function startHTTPorHTTPS() {
}
async function startServer() {
const [v6Failed, v4Failed] = await startHTTPorHTTPS();
let useIPv6 = (enableIPv6 === true);
let useIPv4 = (enableIPv4 === true);
handleServerListenFail(v6Failed, v4Failed);
postSetupTasks(v6Failed, v4Failed);
let hasIPv6 = false,
hasIPv4 = false,
hasIPv6Local = false,
hasIPv4Local = false,
hasIPv6Any = false,
hasIPv4Any = false;
if (enableIPv6 === 'auto' || enableIPv4 === 'auto') {
[hasIPv6Any, hasIPv4Any, hasIPv6Local, hasIPv4Local] = await getHasIP();
hasIPv6 = listen ? hasIPv6Any : hasIPv6Local;
if (enableIPv6 === 'auto') {
useIPv6 = hasIPv6;
}
if (hasIPv6) {
if (useIPv6) {
console.log(color.green('IPv6 support detected'));
} else {
console.log('IPv6 support detected (but disabled)');
}
}
hasIPv4 = listen ? hasIPv4Any : hasIPv4Local;
if (enableIPv4 === 'auto') {
useIPv4 = hasIPv4;
}
if (hasIPv4) {
if (useIPv4) {
console.log(color.green('IPv4 support detected'));
} else {
console.log('IPv4 support detected (but disabled)');
}
}
if (enableIPv6 === 'auto' && enableIPv4 === 'auto') {
if (!hasIPv6 && !hasIPv4) {
console.error('Both IPv6 and IPv4 are not detected');
process.exit(1);
}
}
}
if (!useIPv6 && !useIPv4) {
console.error('Both IPv6 and IPv4 are disabled,\nP.S. you should never see this error, at least at one point it was checked for before this, with the rest of the config options');
process.exit(1);
}
const [v6Failed, v4Failed] = await startHTTPorHTTPS(useIPv6, useIPv4);
handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4);
postSetupTasks(v6Failed, v4Failed, useIPv6, useIPv4);
}
async function verifySecuritySettings() {
@ -911,7 +1114,7 @@ async function verifySecuritySettings() {
}
if (!enableAccounts) {
logSecurityAlert('Your SillyTavern is currently insecurely open to the public. Enable whitelisting, basic authentication or user accounts.');
logSecurityAlert('Your current SillyTavern configuration is insecure (listening to non-localhost). Enable whitelisting, basic authentication or user accounts.');
}
const users = await getAllEnabledUsers();

View File

@ -139,19 +139,19 @@ export const UNSAFE_EXTENSIONS = [
export const GEMINI_SAFETY = [
{
category: 'HARM_CATEGORY_HARASSMENT',
threshold: 'BLOCK_NONE',
threshold: 'OFF',
},
{
category: 'HARM_CATEGORY_HATE_SPEECH',
threshold: 'BLOCK_NONE',
threshold: 'OFF',
},
{
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
threshold: 'BLOCK_NONE',
threshold: 'OFF',
},
{
category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
threshold: 'BLOCK_NONE',
threshold: 'OFF',
},
{
category: 'HARM_CATEGORY_CIVIC_INTEGRITY',
@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [
export const OLLAMA_KEYS = [
'num_predict',
'num_ctx',
'num_batch',
'stop',
'temperature',
'repeat_penalty',
@ -369,6 +370,7 @@ export const OPENROUTER_KEYS = [
'prompt',
'stop',
'provider',
'include_reasoning',
];
// https://github.com/vllm-project/vllm/blob/0f8a91401c89ac0a8018def3756829611b57727f/vllm/entrypoints/openai/protocol.py#L220
@ -413,3 +415,10 @@ export const VLLM_KEYS = [
'guided_decoding_backend',
'guided_whitespace_pattern',
];
export const LOG_LEVELS = {
DEBUG: 0,
INFO: 1,
WARN: 2,
ERROR: 3,
};

View File

@ -32,7 +32,7 @@ router.post('/caption-image', jsonParser, async (request, response) => {
max_tokens: 4096,
};
console.log('Multimodal captioning request', body);
console.debug('Multimodal captioning request', body);
const result = await fetch(url, {
body: JSON.stringify(body),
@ -46,14 +46,14 @@ router.post('/caption-image', jsonParser, async (request, response) => {
if (!result.ok) {
const text = await result.text();
console.log(`Claude API returned error: ${result.status} ${result.statusText}`, text);
console.warn(`Claude API returned error: ${result.status} ${result.statusText}`, text);
return response.status(result.status).send({ error: true });
}
/** @type {any} */
const generateResponseJson = await result.json();
const caption = generateResponseJson.content[0].text;
console.log('Claude response:', generateResponseJson);
console.debug('Claude response:', generateResponseJson);
if (!caption) {
return response.status(500).send('No caption found');

View File

@ -176,7 +176,7 @@ router.post('/get', jsonParser, async (request, response) => {
}
}
catch (err) {
console.log(err);
console.error(err);
}
return response.send(output);
});
@ -200,7 +200,7 @@ router.post('/download', jsonParser, async (request, response) => {
category = i;
if (category === null) {
console.debug('Bad request: unsupported asset category.');
console.error('Bad request: unsupported asset category.');
return response.sendStatus(400);
}
@ -212,7 +212,7 @@ router.post('/download', jsonParser, async (request, response) => {
const temp_path = path.join(request.user.directories.assets, 'temp', request.body.filename);
const file_path = path.join(request.user.directories.assets, category, request.body.filename);
console.debug('Request received to download', url, 'to', file_path);
console.info('Request received to download', url, 'to', file_path);
try {
// Download to temp
@ -241,13 +241,13 @@ router.post('/download', jsonParser, async (request, response) => {
}
// Move into asset place
console.debug('Download finished, moving file from', temp_path, 'to', file_path);
console.info('Download finished, moving file from', temp_path, 'to', file_path);
fs.copyFileSync(temp_path, file_path);
fs.rmSync(temp_path);
response.sendStatus(200);
}
catch (error) {
console.log(error);
console.error(error);
response.sendStatus(500);
}
});
@ -270,7 +270,7 @@ router.post('/delete', jsonParser, async (request, response) => {
category = i;
if (category === null) {
console.debug('Bad request: unsupported asset category.');
console.error('Bad request: unsupported asset category.');
return response.sendStatus(400);
}
@ -280,7 +280,7 @@ router.post('/delete', jsonParser, async (request, response) => {
return response.status(400).send(validation.message);
const file_path = path.join(request.user.directories.assets, category, request.body.filename);
console.debug('Request received to delete', category, file_path);
console.info('Request received to delete', category, file_path);
try {
// Delete if previous download failed
@ -288,17 +288,17 @@ router.post('/delete', jsonParser, async (request, response) => {
fs.unlink(file_path, (err) => {
if (err) throw err;
});
console.debug('Asset deleted.');
console.info('Asset deleted.');
}
else {
console.debug('Asset not found.');
console.error('Asset not found.');
response.sendStatus(400);
}
// Move into asset place
response.sendStatus(200);
}
catch (error) {
console.log(error);
console.error(error);
response.sendStatus(500);
}
});
@ -314,6 +314,7 @@ router.post('/delete', jsonParser, async (request, response) => {
*/
router.post('/character', jsonParser, async (request, response) => {
if (request.query.name === undefined) return response.sendStatus(400);
// For backwards compatibility, don't reject invalid character names, just sanitize them
const name = sanitize(request.query.name.toString());
const inputCategory = request.query.category;
@ -325,7 +326,7 @@ router.post('/character', jsonParser, async (request, response) => {
category = i;
if (category === null) {
console.debug('Bad request: unsupported asset category.');
console.error('Bad request: unsupported asset category.');
return response.sendStatus(400);
}
@ -364,7 +365,7 @@ router.post('/character', jsonParser, async (request, response) => {
return response.send(output);
}
catch (err) {
console.log(err);
console.error(err);
return response.sendStatus(500);
}
});

View File

@ -11,14 +11,14 @@ router.post('/list', jsonParser, async (req, res) => {
const key = readSecret(req.user.directories, SECRET_KEYS.AZURE_TTS);
if (!key) {
console.error('Azure TTS API Key not set');
console.warn('Azure TTS API Key not set');
return res.sendStatus(403);
}
const region = req.body.region;
if (!region) {
console.error('Azure TTS region not set');
console.warn('Azure TTS region not set');
return res.sendStatus(400);
}
@ -32,7 +32,7 @@ router.post('/list', jsonParser, async (req, res) => {
});
if (!response.ok) {
console.error('Azure Request failed', response.status, response.statusText);
console.warn('Azure Request failed', response.status, response.statusText);
return res.sendStatus(500);
}
@ -49,13 +49,13 @@ router.post('/generate', jsonParser, async (req, res) => {
const key = readSecret(req.user.directories, SECRET_KEYS.AZURE_TTS);
if (!key) {
console.error('Azure TTS API Key not set');
console.warn('Azure TTS API Key not set');
return res.sendStatus(403);
}
const { text, voice, region } = req.body;
if (!text || !voice || !region) {
console.error('Missing required parameters');
console.warn('Missing required parameters');
return res.sendStatus(400);
}
@ -75,7 +75,7 @@ router.post('/generate', jsonParser, async (req, res) => {
});
if (!response.ok) {
console.error('Azure Request failed', response.status, response.statusText);
console.warn('Azure Request failed', response.status, response.statusText);
return res.sendStatus(500);
}

View File

@ -114,7 +114,7 @@ async function sendClaudeRequest(request, response) {
}
if (!apiKey) {
console.log(color.red(`Claude API key is missing.\n${divider}`));
console.warn(color.red(`Claude API key is missing.\n${divider}`));
return response.status(400).send({ error: true });
}
@ -179,7 +179,7 @@ async function sendClaudeRequest(request, response) {
additionalHeaders['anthropic-beta'] = 'prompt-caching-2024-07-31';
}
console.log('Claude request:', requestBody);
console.debug('Claude request:', requestBody);
const generateResponse = await fetch(apiUrl + '/messages', {
method: 'POST',
@ -199,21 +199,21 @@ async function sendClaudeRequest(request, response) {
} else {
if (!generateResponse.ok) {
const generateResponseText = await generateResponse.text();
console.log(color.red(`Claude API returned error: ${generateResponse.status} ${generateResponse.statusText}\n${generateResponseText}\n${divider}`));
console.warn(color.red(`Claude API returned error: ${generateResponse.status} ${generateResponse.statusText}\n${generateResponseText}\n${divider}`));
return response.status(generateResponse.status).send({ error: true });
}
/** @type {any} */
const generateResponseJson = await generateResponse.json();
const responseText = generateResponseJson?.content?.[0]?.text || '';
console.log('Claude response:', generateResponseJson);
console.debug('Claude response:', generateResponseJson);
// Wrap it back to OAI format + save the original content
const reply = { choices: [{ 'message': { 'content': responseText } }], content: generateResponseJson.content };
return response.send(reply);
}
} catch (error) {
console.log(color.red(`Error communicating with Claude: ${error}\n${divider}`));
console.error(color.red(`Error communicating with Claude: ${error}\n${divider}`));
if (!response.headersSent) {
return response.status(500).send({ error: true });
}
@ -230,12 +230,12 @@ async function sendScaleRequest(request, response) {
const apiKey = readSecret(request.user.directories, SECRET_KEYS.SCALE);
if (!apiKey) {
console.log('Scale API key is missing.');
console.warn('Scale API key is missing.');
return response.status(400).send({ error: true });
}
const requestPrompt = convertTextCompletionPrompt(request.body.messages);
console.log('Scale request:', requestPrompt);
console.debug('Scale request:', requestPrompt);
try {
const controller = new AbortController();
@ -254,18 +254,18 @@ async function sendScaleRequest(request, response) {
});
if (!generateResponse.ok) {
console.log(`Scale API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
console.warn(`Scale API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
return response.status(500).send({ error: true });
}
/** @type {any} */
const generateResponseJson = await generateResponse.json();
console.log('Scale response:', generateResponseJson);
console.debug('Scale response:', generateResponseJson);
const reply = { choices: [{ 'message': { 'content': generateResponseJson.output } }] };
return response.send(reply);
} catch (error) {
console.log(error);
console.error(error);
if (!response.headersSent) {
return response.status(500).send({ error: true });
}
@ -282,13 +282,12 @@ async function sendMakerSuiteRequest(request, response) {
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MAKERSUITE);
if (!request.body.reverse_proxy && !apiKey) {
console.log('Google AI Studio API key is missing.');
console.warn('Google AI Studio API key is missing.');
return response.status(400).send({ error: true });
}
const model = String(request.body.model);
const stream = Boolean(request.body.stream);
const showThoughts = Boolean(request.body.show_thoughts);
const isThinking = model.includes('thinking');
const generationConfig = {
@ -306,8 +305,9 @@ async function sendMakerSuiteRequest(request, response) {
}
const should_use_system_prompt = (
model.includes('gemini-2.0-pro') ||
model.includes('gemini-2.0-flash') ||
model.includes('gemini-2.0-flash-thinking-exp') ||
model.includes('gemini-2.0-flash-exp') ||
model.includes('gemini-1.5-flash') ||
model.includes('gemini-1.5-pro') ||
model.startsWith('gemini-exp')
@ -316,9 +316,15 @@ async function sendMakerSuiteRequest(request, response) {
const prompt = convertGooglePrompt(request.body.messages, model, should_use_system_prompt, getPromptNames(request));
let safetySettings = GEMINI_SAFETY;
if (model.includes('gemini-2.0-flash-exp')) {
// These old models do not support setting the threshold to OFF at all.
if (['gemini-1.5-pro-001', 'gemini-1.5-flash-001', 'gemini-1.5-flash-8b-exp-0827', 'gemini-1.5-flash-8b-exp-0924', 'gemini-pro', 'gemini-1.0-pro', 'gemini-1.0-pro-001'].includes(model)) {
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' }));
}
// Interestingly, Gemini 2.0 Flash does support setting the threshold for HARM_CATEGORY_CIVIC_INTEGRITY to OFF.
else if (['gemini-2.0-flash', 'gemini-2.0-flash-001', 'gemini-2.0-flash-exp'].includes(model)) {
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'OFF' }));
}
// Most of the other models allow for setting the threshold of filters, except for HARM_CATEGORY_CIVIC_INTEGRITY, to OFF.
let body = {
contents: prompt.contents,
@ -330,17 +336,11 @@ async function sendMakerSuiteRequest(request, response) {
body.systemInstruction = prompt.system_instruction;
}
if (isThinking && showThoughts) {
generationConfig.thinkingConfig = {
includeThoughts: true,
};
}
return body;
}
const body = getGeminiBody();
console.log('Google AI Studio request:', body);
console.debug('Google AI Studio request:', body);
try {
const controller = new AbortController();
@ -366,14 +366,14 @@ async function sendMakerSuiteRequest(request, response) {
// Pipe remote SSE stream to Express response
forwardFetchResponse(generateResponse, response);
} catch (error) {
console.log('Error forwarding streaming response:', error);
console.error('Error forwarding streaming response:', error);
if (!response.headersSent) {
return response.status(500).send({ error: true });
}
}
} else {
if (!generateResponse.ok) {
console.log(`Google AI Studio API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
console.warn(`Google AI Studio API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
return response.status(generateResponse.status).send({ error: true });
}
@ -383,7 +383,7 @@ async function sendMakerSuiteRequest(request, response) {
const candidates = generateResponseJson?.candidates;
if (!candidates || candidates.length === 0) {
let message = 'Google AI Studio API returned no candidate';
console.log(message, generateResponseJson);
console.warn(message, generateResponseJson);
if (generateResponseJson?.promptFeedback?.blockReason) {
message += `\nPrompt was blocked due to : ${generateResponseJson.promptFeedback.blockReason}`;
}
@ -391,12 +391,12 @@ async function sendMakerSuiteRequest(request, response) {
}
const responseContent = candidates[0].content ?? candidates[0].output;
console.log('Google AI Studio response:', responseContent);
console.warn('Google AI Studio response:', responseContent);
const responseText = typeof responseContent === 'string' ? responseContent : responseContent?.parts?.filter(part => !part.thought)?.map(part => part.text)?.join('\n\n');
if (!responseText) {
let message = 'Google AI Studio Candidate text empty';
console.log(message, generateResponseJson);
console.warn(message, generateResponseJson);
return response.send({ error: { message } });
}
@ -405,7 +405,7 @@ async function sendMakerSuiteRequest(request, response) {
return response.send(reply);
}
} catch (error) {
console.log('Error communicating with Google AI Studio API: ', error);
console.error('Error communicating with Google AI Studio API: ', error);
if (!response.headersSent) {
return response.status(500).send({ error: true });
}
@ -419,8 +419,9 @@ async function sendMakerSuiteRequest(request, response) {
*/
async function sendAI21Request(request, response) {
if (!request.body) return response.sendStatus(400);
const controller = new AbortController();
console.log(request.body.messages);
console.debug(request.body.messages);
request.socket.removeAllListeners('close');
request.socket.on('close', function () {
controller.abort();
@ -446,7 +447,7 @@ async function sendAI21Request(request, response) {
signal: controller.signal,
};
console.log('AI21 request:', body);
console.debug('AI21 request:', body);
try {
const generateResponse = await fetch(API_AI21 + '/chat/completions', options);
@ -455,16 +456,16 @@ async function sendAI21Request(request, response) {
} else {
if (!generateResponse.ok) {
const errorText = await generateResponse.text();
console.log(`AI21 API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
console.warn(`AI21 API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
const errorJson = tryParse(errorText) ?? { error: true };
return response.status(500).send(errorJson);
}
const generateResponseJson = await generateResponse.json();
console.log('AI21 response:', generateResponseJson);
console.debug('AI21 response:', generateResponseJson);
return response.send(generateResponseJson);
}
} catch (error) {
console.log('Error communicating with AI21 API: ', error);
console.error('Error communicating with AI21 API: ', error);
if (!response.headersSent) {
response.send({ error: true });
} else {
@ -483,7 +484,7 @@ async function sendMistralAIRequest(request, response) {
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MISTRALAI);
if (!apiKey) {
console.log('MistralAI API key is missing.');
console.warn('MistralAI API key is missing.');
return response.status(400).send({ error: true });
}
@ -524,7 +525,7 @@ async function sendMistralAIRequest(request, response) {
timeout: 0,
};
console.log('MisralAI request:', requestBody);
console.debug('MisralAI request:', requestBody);
const generateResponse = await fetch(apiUrl + '/chat/completions', config);
if (request.body.stream) {
@ -532,16 +533,16 @@ async function sendMistralAIRequest(request, response) {
} else {
if (!generateResponse.ok) {
const errorText = await generateResponse.text();
console.log(`MistralAI API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
console.warn(`MistralAI API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
const errorJson = tryParse(errorText) ?? { error: true };
return response.status(500).send(errorJson);
}
const generateResponseJson = await generateResponse.json();
console.log('MistralAI response:', generateResponseJson);
console.debug('MistralAI response:', generateResponseJson);
return response.send(generateResponseJson);
}
} catch (error) {
console.log('Error communicating with MistralAI API: ', error);
console.error('Error communicating with MistralAI API: ', error);
if (!response.headersSent) {
response.send({ error: true });
} else {
@ -564,7 +565,7 @@ async function sendCohereRequest(request, response) {
});
if (!apiKey) {
console.log('Cohere API key is missing.');
console.warn('Cohere API key is missing.');
return response.status(400).send({ error: true });
}
@ -603,7 +604,7 @@ async function sendCohereRequest(request, response) {
requestBody.safety_mode = 'OFF';
}
console.log('Cohere request:', requestBody);
console.debug('Cohere request:', requestBody);
const config = {
method: 'POST',
@ -625,16 +626,16 @@ async function sendCohereRequest(request, response) {
const generateResponse = await fetch(apiUrl, config);
if (!generateResponse.ok) {
const errorText = await generateResponse.text();
console.log(`Cohere API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
console.warn(`Cohere API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
const errorJson = tryParse(errorText) ?? { error: true };
return response.status(500).send(errorJson);
}
const generateResponseJson = await generateResponse.json();
console.log('Cohere response:', generateResponseJson);
console.debug('Cohere response:', generateResponseJson);
return response.send(generateResponseJson);
}
} catch (error) {
console.log('Error communicating with Cohere API: ', error);
console.error('Error communicating with Cohere API: ', error);
if (!response.headersSent) {
response.send({ error: true });
} else {
@ -653,7 +654,7 @@ async function sendDeepSeekRequest(request, response) {
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
if (!apiKey && !request.body.reverse_proxy) {
console.log('DeepSeek API key is missing.');
console.warn('DeepSeek API key is missing.');
return response.status(400).send({ error: true });
}
@ -671,6 +672,11 @@ async function sendDeepSeekRequest(request, response) {
bodyParams['logprobs'] = true;
}
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
bodyParams['tools'] = request.body.tools;
bodyParams['tool_choice'] = request.body.tool_choice;
}
const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek';
const processedMessages = postProcessPrompt(request.body.messages, postProcessType, getPromptNames(request));
@ -698,7 +704,7 @@ async function sendDeepSeekRequest(request, response) {
signal: controller.signal,
};
console.log('DeepSeek request:', requestBody);
console.debug('DeepSeek request:', requestBody);
const generateResponse = await fetch(apiUrl + '/chat/completions', config);
@ -707,16 +713,16 @@ async function sendDeepSeekRequest(request, response) {
} else {
if (!generateResponse.ok) {
const errorText = await generateResponse.text();
console.log(`DeepSeek API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
console.warn(`DeepSeek API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
const errorJson = tryParse(errorText) ?? { error: true };
return response.status(500).send(errorJson);
}
const generateResponseJson = await generateResponse.json();
console.log('DeepSeek response:', generateResponseJson);
console.debug('DeepSeek response:', generateResponseJson);
return response.send(generateResponseJson);
}
} catch (error) {
console.log('Error communicating with DeepSeek API: ', error);
console.error('Error communicating with DeepSeek API: ', error);
if (!response.headersSent) {
response.send({ error: true });
} else {
@ -774,12 +780,12 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
api_key_openai = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
headers = {};
} else {
console.log('This chat completion source is not supported yet.');
console.warn('This chat completion source is not supported yet.');
return response_getstatus_openai.status(400).send({ error: true });
}
if (!api_key_openai && !request.body.reverse_proxy && request.body.chat_completion_source !== CHAT_COMPLETION_SOURCES.CUSTOM) {
console.log('Chat Completion API key is missing.');
console.warn('Chat Completion API key is missing.');
return response_getstatus_openai.status(400).send({ error: true });
}
@ -814,23 +820,23 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
};
});
console.log('Available OpenRouter models:', models);
console.info('Available OpenRouter models:', models);
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.MISTRALAI) {
const models = data?.data;
console.log(models);
console.info(models);
} else {
const models = data?.data;
if (Array.isArray(models)) {
const modelIds = models.filter(x => x && typeof x === 'object').map(x => x.id).sort();
console.log('Available models:', modelIds);
console.info('Available models:', modelIds);
} else {
console.log('Chat Completion endpoint did not return a list of models.');
console.warn('Chat Completion endpoint did not return a list of models.');
}
}
}
else {
console.log('Chat Completion status check failed. Either Access Token is incorrect or API endpoint is down.');
console.error('Chat Completion status check failed. Either Access Token is incorrect or API endpoint is down.');
response_getstatus_openai.send({ error: true, can_bypass: true, data: { data: [] } });
}
} catch (e) {
@ -863,7 +869,7 @@ router.post('/bias', jsonParser, async function (request, response) {
const tokenizer = getSentencepiceTokenizer(model);
const instance = await tokenizer?.get();
if (!instance) {
console.warn('Tokenizer not initialized:', model);
console.error('Tokenizer not initialized:', model);
return response.send({});
}
encodeFunction = (text) => new Uint32Array(instance.encodeIds(text));
@ -998,7 +1004,7 @@ router.post('/generate', jsonParser, function (request, response) {
bodyParams['route'] = 'fallback';
}
if (request.body.show_thoughts) {
if (request.body.include_reasoning) {
bodyParams['include_reasoning'] = true;
}
@ -1025,7 +1031,7 @@ router.post('/generate', jsonParser, function (request, response) {
mergeObjectWithYaml(headers, request.body.custom_include_headers);
if (request.body.custom_prompt_post_processing) {
console.log('Applying custom prompt post-processing of type', request.body.custom_prompt_post_processing);
console.info('Applying custom prompt post-processing of type', request.body.custom_prompt_post_processing);
request.body.messages = postProcessPrompt(
request.body.messages,
request.body.custom_prompt_post_processing,
@ -1058,12 +1064,19 @@ router.post('/generate', jsonParser, function (request, response) {
headers = {};
bodyParams = {};
} else {
console.log('This chat completion source is not supported yet.');
console.warn('This chat completion source is not supported yet.');
return response.status(400).send({ error: true });
}
// A few of OpenAIs reasoning models support reasoning effort
if ([CHAT_COMPLETION_SOURCES.CUSTOM, CHAT_COMPLETION_SOURCES.OPENAI].includes(request.body.chat_completion_source)) {
if (['o1', 'o3-mini', 'o3-mini-2025-01-31'].includes(request.body.model)) {
bodyParams['reasoning_effort'] = request.body.reasoning_effort;
}
}
if (!apiKey && !request.body.reverse_proxy && request.body.chat_completion_source !== CHAT_COMPLETION_SOURCES.CUSTOM) {
console.log('OpenAI API key is missing.');
console.warn('OpenAI API key is missing.');
return response.status(400).send({ error: true });
}
@ -1123,7 +1136,7 @@ router.post('/generate', jsonParser, function (request, response) {
signal: controller.signal,
};
console.log(requestBody);
console.debug(requestBody);
makeRequest(config, response, request);
@ -1140,7 +1153,7 @@ router.post('/generate', jsonParser, function (request, response) {
const fetchResponse = await fetch(endpointUrl, config);
if (request.body.stream) {
console.log('Streaming request in progress');
console.info('Streaming request in progress');
forwardFetchResponse(fetchResponse, response);
return;
}
@ -1149,10 +1162,10 @@ router.post('/generate', jsonParser, function (request, response) {
/** @type {any} */
let json = await fetchResponse.json();
response.send(json);
console.log(json);
console.log(json?.choices?.[0]?.message);
console.debug(json);
console.debug(json?.choices?.[0]?.message);
} else if (fetchResponse.status === 429 && retries > 0) {
console.log(`Out of quota, retrying in ${Math.round(timeout / 1000)}s`);
console.warn(`Out of quota, retrying in ${Math.round(timeout / 1000)}s`);
setTimeout(() => {
timeout *= 2;
makeRequest(config, response, request, retries - 1, timeout);
@ -1161,7 +1174,7 @@ router.post('/generate', jsonParser, function (request, response) {
await handleErrorResponse(fetchResponse);
}
} catch (error) {
console.log('Generation failed', error);
console.error('Generation failed', error);
const message = error.code === 'ECONNREFUSED'
? `Connection refused: ${error.message}`
: error.message || 'Unknown error occurred';
@ -1183,7 +1196,7 @@ router.post('/generate', jsonParser, function (request, response) {
const message = errorResponse.statusText || 'Unknown error occurred';
const quota_error = errorResponse.status === 429 && errorData?.error?.type === 'insufficient_quota';
console.log('Chat completion request error: ', message, responseText);
console.error('Chat completion request error: ', message, responseText);
if (!response.headersSent) {
response.send({ error: { message }, quota_error: quota_error });

Some files were not shown because too many files have changed in this diff Show More