Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dabf12ed7 | ||
|
|
98e2d3fa28 | ||
|
|
345660503f | ||
|
|
a6c3e4c444 | ||
|
|
60bcbe3b4f | ||
|
|
f852b7c4ea | ||
|
|
2f3b55d863 | ||
|
|
b7890bfe34 | ||
|
|
2c5229e382 | ||
|
|
8656dd3a7a | ||
|
|
1147507d06 | ||
|
|
5aa1c8fbac | ||
|
|
862c2b7ba3 | ||
|
|
f62eeb76a6 | ||
|
|
d1349b10bb | ||
|
|
dcc6ddf7ad | ||
|
|
40a46bee9d | ||
|
|
9a5235efcd | ||
|
|
57e363cae6 | ||
|
|
6221c540e4 | ||
|
|
8709162df3 | ||
|
|
b793e3e19b | ||
|
|
8687bb99f3 | ||
|
|
d134abd50e | ||
|
|
680e61d1a0 | ||
|
|
e871886b13 | ||
|
|
0ba317a318 | ||
|
|
4d98b48956 | ||
|
|
2bc503ec00 | ||
|
|
13db803bc6 | ||
|
|
005a062fe7 | ||
|
|
ff8d7d64fc | ||
|
|
fe8ebedeb2 | ||
|
|
285b09ceb7 | ||
|
|
5eea41d315 | ||
|
|
57cd001221 | ||
|
|
bc2d3300df | ||
|
|
2694ad47f3 | ||
|
|
9f257b602f | ||
|
|
c46e1a46aa | ||
|
|
e1af2fb47d | ||
|
|
ddb97d78d3 | ||
|
|
26a67b9afe | ||
|
|
80fa7f96f1 | ||
|
|
5e4bb0415e | ||
|
|
0d84fa67bd | ||
|
|
e9e14001e3 | ||
|
|
f9d1279a69 | ||
|
|
f81088f2e0 | ||
|
|
176825bdb8 | ||
|
|
12ac171979 |
+1
-1
@@ -54,4 +54,4 @@ public/scripts/extensions/third-party
|
||||
.aider*
|
||||
.env
|
||||
/StartDev.bat
|
||||
|
||||
yarn.lock
|
||||
|
||||
@@ -40,9 +40,15 @@ browserLaunch:
|
||||
port: 8000
|
||||
# -- SSL options --
|
||||
ssl:
|
||||
# Enable SSL/TLS encryption
|
||||
enabled: false
|
||||
# Path to certificate (relative to server root)
|
||||
certPath: "./certs/cert.pem"
|
||||
# Path to private key (relative to server root)
|
||||
keyPath: "./certs/privkey.pem"
|
||||
# Private key passphrase (leave empty if not needed)
|
||||
# For better security, use a CLI argument or an environment variable (SILLYTAVERN_SSL_KEYPASSPHRASE)
|
||||
keyPassphrase: ""
|
||||
# -- SECURITY CONFIGURATION --
|
||||
# Toggle whitelist mode
|
||||
whitelistMode: true
|
||||
@@ -88,6 +94,18 @@ autheliaAuth: false
|
||||
# the username and passwords for basic auth are the same as those
|
||||
# for the individual accounts
|
||||
perUserBasicAuth: false
|
||||
# Host whitelist configuration. Recommended if you're using a listen mode
|
||||
hostWhitelist:
|
||||
# Enable or disable host whitelisting
|
||||
enabled: false
|
||||
# Scan incoming requests for potential host header spoofing
|
||||
scan: true
|
||||
# List of allowed hosts. Do not include localhost or IPs, these are safe.
|
||||
# Use a dot to create subdomain patterns.
|
||||
# Examples:
|
||||
# - example.com
|
||||
# - .trycloudflare.com
|
||||
hosts: []
|
||||
|
||||
# User session timeout *in seconds* (defaults to 24 hours).
|
||||
## Set to a positive number to expire session after a certain time of inactivity
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Forbidden</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Forbidden</h1>
|
||||
<p>
|
||||
If you are the system administrator, add the hostname you are accessing from to the
|
||||
host whitelist, or disable host whitelisting in the
|
||||
<code>config.yaml</code> file located in the root directory of your installation.
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<em>Access from this host is not allowed. This attempt has been logged.</em>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Generated
+44
-34
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "sillytavern",
|
||||
"version": "1.13.3",
|
||||
"version": "1.13.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sillytavern",
|
||||
"version": "1.13.3",
|
||||
"version": "1.13.4",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@adobe/css-tools": "^4.4.3",
|
||||
"@adobe/css-tools": "^4.4.4",
|
||||
"@agnai/sentencepiece-js": "^1.1.1",
|
||||
"@agnai/web-tokenizers": "^0.1.3",
|
||||
"@iconfu/svg-inject": "^1.2.3",
|
||||
@@ -42,9 +42,9 @@
|
||||
"archiver": "^7.0.1",
|
||||
"bing-translate-api": "^4.1.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"bowser": "^2.11.0",
|
||||
"bowser": "^2.12.1",
|
||||
"bytes": "^3.1.2",
|
||||
"chalk": "^5.4.1",
|
||||
"chalk": "^5.6.0",
|
||||
"command-exists": "^1.2.9",
|
||||
"compression": "^1.8.1",
|
||||
"cookie-parser": "^1.4.6",
|
||||
@@ -64,6 +64,7 @@
|
||||
"handlebars": "^4.7.8",
|
||||
"helmet": "^8.1.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"host-validation-middleware": "^0.1.1",
|
||||
"html-entities": "^2.6.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
@@ -74,7 +75,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"mime-types": "^3.0.1",
|
||||
"moment": "^2.30.1",
|
||||
"morphdom": "^2.7.5",
|
||||
"morphdom": "^2.7.7",
|
||||
"multer": "^2.0.2",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-persist": "^4.0.4",
|
||||
@@ -90,14 +91,14 @@
|
||||
"sillytavern-transformers": "2.14.6",
|
||||
"simple-git": "^3.28.0",
|
||||
"slidetoggle": "^4.0.0",
|
||||
"tiktoken": "^1.0.21",
|
||||
"tiktoken": "^1.0.22",
|
||||
"url-join": "^5.0.0",
|
||||
"vectra": "^0.2.2",
|
||||
"wavefile": "^11.0.0",
|
||||
"webpack": "^5.98.0",
|
||||
"write-file-atomic": "^5.0.1",
|
||||
"ws": "^8.18.3",
|
||||
"yaml": "^2.8.0",
|
||||
"yaml": "^2.8.1",
|
||||
"yargs": "^17.7.1",
|
||||
"yauzl": "^3.2.0"
|
||||
},
|
||||
@@ -114,7 +115,7 @@
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/deno": "^2.3.0",
|
||||
"@types/express": "^4.17.23",
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/jquery": "^3.5.33",
|
||||
"@types/jquery-cropper": "^1.0.4",
|
||||
"@types/jquery.transit": "^0.9.33",
|
||||
"@types/jqueryui": "^1.12.24",
|
||||
@@ -149,9 +150,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@adobe/css-tools": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.3.tgz",
|
||||
"integrity": "sha512-VQKMkwriZbaOgVCby1UDY/LDk5fIjhQicCvVPFqfe+69fWaPWydbWJ3wRt59/YzIwda1I81loas3oCoHxnqvdA==",
|
||||
"version": "4.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.4.tgz",
|
||||
"integrity": "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@agnai/sentencepiece-js": {
|
||||
@@ -1911,9 +1912,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/jquery": {
|
||||
"version": "3.5.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.32.tgz",
|
||||
"integrity": "sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==",
|
||||
"version": "3.5.33",
|
||||
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.33.tgz",
|
||||
"integrity": "sha512-SeyVJXlCZpEki5F0ghuYe+L+PprQta6nRZqhONt9F13dWBtR/ftoaIbdRQ7cis7womE+X2LKhsDdDtkkDhJS6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2771,13 +2772,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz",
|
||||
"integrity": "sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.12.0.tgz",
|
||||
"integrity": "sha512-oXTDccv8PcfjZmPGlWsPSwtOJCZ/b6W5jAMCNcfwJbCzDckwG0jrYJFaWH1yvivfCXjVzV/SPDEhMB3Q+DSurg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
"form-data": "^4.0.4",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
@@ -2896,9 +2897,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/bowser": {
|
||||
"version": "2.11.0",
|
||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz",
|
||||
"integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==",
|
||||
"version": "2.12.1",
|
||||
"resolved": "https://registry.npmjs.org/bowser/-/bowser-2.12.1.tgz",
|
||||
"integrity": "sha512-z4rE2Gxh7tvshQ4hluIT7XcFrgLIQaw9X3A+kTTRdovCz5PMukm/0QC/BKSYPj3omF5Qfypn9O/c5kgpmvYUCw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
@@ -3126,9 +3127,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "5.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz",
|
||||
"integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==",
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.0.tgz",
|
||||
"integrity": "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||
@@ -5249,6 +5250,15 @@
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/host-validation-middleware": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/host-validation-middleware/-/host-validation-middleware-0.1.1.tgz",
|
||||
"integrity": "sha512-fakcpp+x4nbP0fACY5gaHWpaOfstq3w8uB6wvhbPBLqH9GV/tdiM9Ht5mclZVbUuPLGBw1bkH5yyTD6HZq057g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.0.0 || >=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-entities": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.6.0.tgz",
|
||||
@@ -6178,9 +6188,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/morphdom": {
|
||||
"version": "2.7.5",
|
||||
"resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.5.tgz",
|
||||
"integrity": "sha512-z6bfWFMra7kBqDjQGHud1LSXtq5JJC060viEkQFMBX6baIecpkNr2Ywrn2OQfWP3rXiNFQRPoFjD8/TvJcWcDg==",
|
||||
"version": "2.7.7",
|
||||
"resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.7.tgz",
|
||||
"integrity": "sha512-04GmsiBcalrSCNmzfo+UjU8tt3PhZJKzcOy+r1FlGA7/zri8wre3I1WkYN9PT3sIeIKfW9bpyElA+VzOg2E24g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ms": {
|
||||
@@ -8001,9 +8011,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tiktoken": {
|
||||
"version": "1.0.21",
|
||||
"resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.21.tgz",
|
||||
"integrity": "sha512-/kqtlepLMptX0OgbYD9aMYbM7EFrMZCL7EoHM8Psmg2FuhXoo/bH64KqOiZGGwa6oS9TPdSEDKBnV2LuB8+5vQ==",
|
||||
"version": "1.0.22",
|
||||
"resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.22.tgz",
|
||||
"integrity": "sha512-PKvy1rVF1RibfF3JlXBSP0Jrcw2uq3yXdgcEXtKTYn3QJ/cBRBHDnrJ5jHky+MENZ6DIPwNUGWpkVx+7joCpNA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/timm": {
|
||||
@@ -8610,9 +8620,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/yaml": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz",
|
||||
"integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==",
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz",
|
||||
"integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"yaml": "bin.mjs"
|
||||
|
||||
+9
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@adobe/css-tools": "^4.4.3",
|
||||
"@adobe/css-tools": "^4.4.4",
|
||||
"@agnai/sentencepiece-js": "^1.1.1",
|
||||
"@agnai/web-tokenizers": "^0.1.3",
|
||||
"@iconfu/svg-inject": "^1.2.3",
|
||||
@@ -32,9 +32,9 @@
|
||||
"archiver": "^7.0.1",
|
||||
"bing-translate-api": "^4.1.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"bowser": "^2.11.0",
|
||||
"bowser": "^2.12.1",
|
||||
"bytes": "^3.1.2",
|
||||
"chalk": "^5.4.1",
|
||||
"chalk": "^5.6.0",
|
||||
"command-exists": "^1.2.9",
|
||||
"compression": "^1.8.1",
|
||||
"cookie-parser": "^1.4.6",
|
||||
@@ -54,6 +54,7 @@
|
||||
"handlebars": "^4.7.8",
|
||||
"helmet": "^8.1.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"host-validation-middleware": "^0.1.1",
|
||||
"html-entities": "^2.6.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
@@ -64,7 +65,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"mime-types": "^3.0.1",
|
||||
"moment": "^2.30.1",
|
||||
"morphdom": "^2.7.5",
|
||||
"morphdom": "^2.7.7",
|
||||
"multer": "^2.0.2",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-persist": "^4.0.4",
|
||||
@@ -80,14 +81,14 @@
|
||||
"sillytavern-transformers": "2.14.6",
|
||||
"simple-git": "^3.28.0",
|
||||
"slidetoggle": "^4.0.0",
|
||||
"tiktoken": "^1.0.21",
|
||||
"tiktoken": "^1.0.22",
|
||||
"url-join": "^5.0.0",
|
||||
"vectra": "^0.2.2",
|
||||
"wavefile": "^11.0.0",
|
||||
"webpack": "^5.98.0",
|
||||
"write-file-atomic": "^5.0.1",
|
||||
"ws": "^8.18.3",
|
||||
"yaml": "^2.8.0",
|
||||
"yaml": "^2.8.1",
|
||||
"yargs": "^17.7.1",
|
||||
"yauzl": "^3.2.0"
|
||||
},
|
||||
@@ -112,7 +113,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
||||
},
|
||||
"version": "1.13.3",
|
||||
"version": "1.13.4",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"debug": "node --inspect server.js",
|
||||
@@ -145,7 +146,7 @@
|
||||
"@types/cors": "^2.8.19",
|
||||
"@types/deno": "^2.3.0",
|
||||
"@types/express": "^4.17.23",
|
||||
"@types/jquery": "^3.5.32",
|
||||
"@types/jquery": "^3.5.33",
|
||||
"@types/jquery-cropper": "^1.0.4",
|
||||
"@types/jquery.transit": "^0.9.33",
|
||||
"@types/jqueryui": "^1.12.24",
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/* Main Page Backgrounds */
|
||||
#bg1,
|
||||
#bg_custom {
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-size: cover;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: background-image var(--animation-duration-3x) ease-in-out;
|
||||
}
|
||||
|
||||
/* Fitting options */
|
||||
#background_fitting {
|
||||
max-width: 6em;
|
||||
}
|
||||
|
||||
/* Fill/Cover - scales to fill width while maintaining aspect ratio */
|
||||
#bg1.cover,
|
||||
#bg_custom.cover {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
/* Fit/Contain - shows entire image maintaining aspect ratio */
|
||||
#bg1.contain,
|
||||
#bg_custom.contain {
|
||||
background-size: contain;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* Stretch - stretches to fill entire space */
|
||||
#bg1.stretch,
|
||||
#bg_custom.stretch {
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
/* Center - centers without scaling */
|
||||
#bg1.center,
|
||||
#bg_custom.center {
|
||||
background-size: auto;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
body.reduced-motion #bg1,
|
||||
body.reduced-motion #bg_custom {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
#bg1 {
|
||||
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
|
||||
z-index: -3;
|
||||
}
|
||||
|
||||
#bg_custom {
|
||||
background-image: none;
|
||||
z-index: -2;
|
||||
}
|
||||
|
||||
.bg_example.flex-container.locked:not(:focus-visible) {
|
||||
outline-color: var(--golden);
|
||||
}
|
||||
|
||||
/* This is the main flex container for the entire drawer */
|
||||
#Backgrounds.drawer-content.openDrawer.bg-drawer-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100vh - var(--topBarBlockSize));
|
||||
max-height: calc(100vh - var(--topBarBlockSize));
|
||||
height: calc(100dvh - var(--topBarBlockSize));
|
||||
max-height: calc(100dvh - var(--topBarBlockSize));
|
||||
overflow: hidden;
|
||||
width: var(--sheldWidth);
|
||||
max-width: var(--sheldWidth);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#bg-header-fixed {
|
||||
flex-shrink: 0;
|
||||
padding: 5px;
|
||||
background-color: var(--SmartThemeBlurTintColor);
|
||||
border-bottom: 1px solid var(--SmartThemeBorderColor);
|
||||
}
|
||||
|
||||
#bg-header-fixed>.flex-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
#bg-scrollable-content {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 0 5px 5px;
|
||||
}
|
||||
|
||||
#bg-filter {
|
||||
font-size: calc(var(--mainFontSize) * 0.95);
|
||||
}
|
||||
|
||||
/* Thumbnail Menu & Buttons */
|
||||
.bg_example .mobile-only-menu-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example.flex-container {
|
||||
width: 30%;
|
||||
max-width: 200px;
|
||||
margin: 5px;
|
||||
aspect-ratio: 16/9;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 7px var(--black50a);
|
||||
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
border: 0px solid transparent;
|
||||
outline: 2px solid var(--SmartThemeBorderColor);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
|
||||
.bg_example.flex-container:focus-visible {
|
||||
outline-offset: inherit;
|
||||
}
|
||||
|
||||
.bg_example_img {
|
||||
position: absolute;
|
||||
top: -2px;
|
||||
left: -2px;
|
||||
right: -2px;
|
||||
bottom: -2px;
|
||||
|
||||
background-image: inherit;
|
||||
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.bg_example .jg-menu {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
border-radius: 8px;
|
||||
gap: 3px;
|
||||
padding: 3px 5px;
|
||||
z-index: 3;
|
||||
backdrop-filter: blur(4px);
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
justify-items: center;
|
||||
align-items: center;
|
||||
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: scale(0.9);
|
||||
transform-origin: center;
|
||||
transition: opacity var(--animation-duration) ease-out, visibility var(--animation-duration) ease-out, transform var(--animation-duration) ease-out;
|
||||
}
|
||||
|
||||
.bg_example:hover .jg-menu,
|
||||
.bg_example:focus-within .jg-menu {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.bg_example .jg-button {
|
||||
display: flex;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
padding: 5px;
|
||||
font-size: 1.1em;
|
||||
border-radius: 6px;
|
||||
transition: background-color var(--animation-duration) ease;
|
||||
}
|
||||
|
||||
.bg_example .jg-button:hover {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.bg_example .jg-unlock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example.locked .jg-lock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example.locked .jg-unlock {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.bg_example:not([custom="true"]) .jg-copy,
|
||||
.bg_example[custom="true"] .jg-edit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Thumbnail Title */
|
||||
.bg_example .BGSampleTitle {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
|
||||
color: var(--SmartThemeBodyColor);
|
||||
font-size: 0.9em;
|
||||
font-weight: 600;
|
||||
padding: 0px 6px 2px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
opacity: 0;
|
||||
transition: opacity var(--animation-duration) ease-in-out;
|
||||
pointer-events: none;
|
||||
border-radius: 0 0 8px 8px;
|
||||
}
|
||||
|
||||
.bg_example:hover .BGSampleTitle,
|
||||
.bg_example:focus-within .BGSampleTitle {
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -25,6 +25,87 @@
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#Backgrounds .bg_example .BGSampleTitle {
|
||||
opacity: 1;
|
||||
bottom: 0px;
|
||||
}
|
||||
|
||||
.bg_example:hover .jg-menu,
|
||||
.bg_example:focus-within .jg-menu {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example.mobile-menu-open .jg-menu {
|
||||
display: flex;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.bg_example .mobile-only-menu-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-color: rgba(0, 0, 0, 0.4);
|
||||
color: white;
|
||||
border-radius: 6px;
|
||||
z-index: 3;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
#bg-header-controls {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 10px;
|
||||
}
|
||||
|
||||
#bg-header-fixed>.flex-container {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 0px;
|
||||
}
|
||||
|
||||
#Backgrounds:not(.selection-mode-active) #bg-header-fixed>.flex-container::after {
|
||||
content: '';
|
||||
order: 1;
|
||||
flex-basis: 100%;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* --- Row 1 Item --- */
|
||||
#bg-header-fixed #bg-header-title {
|
||||
order: 1;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#bg-header-fixed #background_fitting,
|
||||
#bg-header-fixed #auto_background {
|
||||
order: 1;
|
||||
}
|
||||
|
||||
/* --- Row 2 Item --- */
|
||||
#bg-header-fixed #bg-filter {
|
||||
order: 2;
|
||||
flex-grow: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* --- Row 3 Item --- */
|
||||
#bg-header-fixed #add_background_button_top {
|
||||
order: 3;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
#Backgrounds.drawer-content.openDrawer.bg-drawer-layout {
|
||||
width: 100dvw;
|
||||
max-width: 100dvw;
|
||||
}
|
||||
|
||||
#extensions_settings,
|
||||
#extensions_settings2 {
|
||||
width: 100% !important;
|
||||
@@ -412,10 +493,6 @@
|
||||
flex-basis: max(calc(100% / 2 - 10px), 180px);
|
||||
}
|
||||
|
||||
.BGSampleTitle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tag.excluded:after {
|
||||
top: unset;
|
||||
bottom: unset;
|
||||
|
||||
+25
-8
@@ -26,7 +26,6 @@ dialog {
|
||||
|
||||
/* Fix weird animation issue with font-scaling during popup open */
|
||||
backface-visibility: hidden;
|
||||
transform: translateZ(0);
|
||||
-webkit-font-smoothing: subpixel-antialiased;
|
||||
|
||||
/* Variables setup */
|
||||
@@ -93,6 +92,11 @@ dialog {
|
||||
animation: fade-in var(--popup-animation-speed) ease-in-out;
|
||||
}
|
||||
|
||||
/* Fix toast container snapping into the backdrop while the animation is running */
|
||||
.popup[opening] #toast-container {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* Open state of the dialog */
|
||||
.popup[open] {
|
||||
color: var(--SmartThemeBodyColor);
|
||||
@@ -118,17 +122,30 @@ body.no-blur .popup[open]::backdrop {
|
||||
animation: fade-out var(--popup-animation-speed) ease-in-out;
|
||||
}
|
||||
|
||||
.popup #toast-container {
|
||||
/* Fix toastr in dialogs by actually placing it at the top of the screen via transform */
|
||||
height: 100dvh;
|
||||
top: calc(50% + var(--topBarBlockSize));
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
/* Edge inset to match Toastr default spacing */
|
||||
:root {
|
||||
--toast-edge: 12px;
|
||||
}
|
||||
|
||||
/* Fix text align, popups are centered by default. toasts should not. */
|
||||
.popup #toast-container {
|
||||
/* Popups are centered by default; toasts should not be */
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Per-position position adjustments caused by the top bar, inside the popup */
|
||||
.popup #toast-container.toast-top-left {
|
||||
top: calc(var(--toast-edge) + var(--topBarBlockSize));
|
||||
}
|
||||
|
||||
.popup #toast-container.toast-top-center {
|
||||
/* toastr in core does not have a top offset on center, so we don't do that either in popups */
|
||||
top: var(--topBarBlockSize);
|
||||
}
|
||||
|
||||
.popup #toast-container.toast-top-right {
|
||||
top: calc(var(--toast-edge) + var(--topBarBlockSize));
|
||||
}
|
||||
|
||||
.popup-crop-wrap {
|
||||
margin: 10px auto;
|
||||
max-height: 75vh;
|
||||
|
||||
Vendored
+11
-11
@@ -5,20 +5,20 @@ import { QuickReplyApi } from './scripts/extensions/quick-reply/api/QuickReplyAp
|
||||
|
||||
declare global {
|
||||
// Custom types
|
||||
declare type InstructSettings = typeof power_user.instruct;
|
||||
declare type ContextSettings = typeof power_user.context;
|
||||
declare type ReasoningSettings = typeof power_user.reasoning;
|
||||
type InstructSettings = typeof power_user.instruct;
|
||||
type ContextSettings = typeof power_user.context;
|
||||
type ReasoningSettings = typeof power_user.reasoning;
|
||||
|
||||
// Global namespace modules
|
||||
interface Window {
|
||||
ai: any;
|
||||
}
|
||||
|
||||
declare var pdfjsLib;
|
||||
declare var ePub;
|
||||
declare var quickReplyApi: QuickReplyApi;
|
||||
var pdfjsLib;
|
||||
var ePub;
|
||||
var quickReplyApi: QuickReplyApi;
|
||||
|
||||
declare var SillyTavern: {
|
||||
var SillyTavern: {
|
||||
getContext(): typeof getContext;
|
||||
llm: any;
|
||||
libs: typeof libs;
|
||||
@@ -63,7 +63,7 @@ declare global {
|
||||
* @param lang Target language
|
||||
* @param provider Translation provider
|
||||
*/
|
||||
async function translate(text: string, lang: string, provider: string = null): Promise<string>;
|
||||
function translate(text: string, lang: string, provider?: string | null): Promise<string>;
|
||||
|
||||
interface ConvertVideoArgs {
|
||||
buffer: Uint8Array;
|
||||
@@ -76,9 +76,9 @@ declare global {
|
||||
*/
|
||||
function convertVideoToAnimatedWebp(args: ConvertVideoArgs): Promise<Uint8Array>;
|
||||
|
||||
interface ColorPickerEvent extends JQuery.ChangeEvent<HTMLElement> {
|
||||
type ColorPickerEvent = Omit<JQuery.ChangeEvent<HTMLElement>, "detail"> & {
|
||||
detail: {
|
||||
rgba: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg id="uuid-adbdae8e-5a41-46d1-8c18-aa73cdbfee32" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" height="100px" width="100px" transform="rotate(0) scale(1, 1)"><path d="m0,2.7v12.6c0,1.491,1.209,2.7,2.7,2.7h12.6c1.491,0,2.7-1.209,2.7-2.7V2.7c0-1.491-1.209-2.7-2.7-2.7H2.7C1.209,0,0,1.209,0,2.7ZM10.8,0v3.6c0,3.976,3.224,7.2,7.2,7.2h-3.6c-3.976,0-7.199,3.222-7.2,7.198v-3.598c0-3.976-3.224-7.2-7.2-7.2h3.6c3.976,0,7.2-3.224,7.2-7.2Z" stroke-width="0"/></svg>
|
||||
|
After Width: | Height: | Size: 468 B |
@@ -0,0 +1 @@
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="118.66667" height="177.33333" viewBox="0 0 89 133"><path d="M14.5 1.8c-6.3 3-11.3 8.8-13.2 15.1C-.1 21.8-.2 27.6.6 70.6l.9 48.2 3.1 4.4c1.9 2.6 5.3 5.4 8.4 7l5.2 2.8h26.7c14.8 0 28.2-.5 30.2-1 5.4-1.5 11.6-8.6 12.4-14.3 1-6.5-.2-10.4-4.7-15.3-5.1-5.5-8.3-6.4-23.3-6.4C46.2 96 43 94.9 43 90.5c0-4.3 3.3-5.5 15.4-5.5 13 0 18-1.8 22.7-8.3 5.4-7.5 5-14.4-1.3-21.3-5.1-5.5-11-7.4-22.8-7.4-9.2 0-13-1.5-13-5 0-3.9 3.6-5 16.9-5 14.5 0 19.4-1.6 23.7-7.9 5.4-7.9 5.2-15.9-.6-22.5-5.4-6.1-6.7-6.4-37.5-7.1-26.3-.6-28.2-.5-32 1.3z"/></svg>
|
||||
|
After Width: | Height: | Size: 589 B |
+106
-37
@@ -652,7 +652,7 @@
|
||||
<input type="number" id="openai_max_tokens" name="openai_max_tokens" class="text_pole" min="1" max="65536">
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,custom,xai,aimlapi,moonshot">
|
||||
<div class="range-block" data-source="openai,custom,xai,aimlapi,moonshot,azure_openai">
|
||||
<div class="range-block-title" data-i18n="Multiple swipes per generation">
|
||||
Multiple swipes per generation
|
||||
</div>
|
||||
@@ -691,7 +691,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi">
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,electronhub,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi,azure_openai">
|
||||
<div class="range-block-title" data-i18n="Temperature">
|
||||
Temperature
|
||||
</div>
|
||||
@@ -704,7 +704,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi">
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,electronhub,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi,azure_openai">
|
||||
<div class="range-block-title" data-i18n="Frequency Penalty">
|
||||
Frequency Penalty
|
||||
</div>
|
||||
@@ -717,7 +717,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi">
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,electronhub,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi,azure_openai">
|
||||
<div class="range-block-title" data-i18n="Presence Penalty">
|
||||
Presence Penalty
|
||||
</div>
|
||||
@@ -730,7 +730,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="claude,aimlapi,openrouter,makersuite,vertexai,cohere,perplexity">
|
||||
<div class="range-block" data-source="claude,aimlapi,openrouter,makersuite,vertexai,cohere,perplexity,electronhub">
|
||||
<div class="range-block-title" data-i18n="Top K">
|
||||
Top K
|
||||
</div>
|
||||
@@ -743,7 +743,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi">
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,electronhub,nanogpt,deepseek,xai,pollinations,moonshot,fireworks,cometapi,azure_openai">
|
||||
<div class="range-block-title" data-i18n="Top P">
|
||||
Top P
|
||||
</div>
|
||||
@@ -980,7 +980,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,openrouter,mistralai,custom,cohere,groq,nanogpt,xai,pollinations,aimlapi,makersuite,vertexai">
|
||||
<div class="range-block" data-source="openai,openrouter,mistralai,custom,cohere,groq,electronhub,nanogpt,xai,pollinations,aimlapi,makersuite,vertexai,azure_openai">
|
||||
<div class="range-block-title justifyLeft" data-i18n="Seed">
|
||||
Seed
|
||||
</div>
|
||||
@@ -1970,7 +1970,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="makersuite,vertexai,aimlapi,openrouter,claude,xai,nanogpt">
|
||||
<div class="range-block" data-source="makersuite,vertexai,aimlapi,openrouter,claude,xai,electronhub,nanogpt">
|
||||
<label for="openai_enable_web_search" class="checkbox_label flexWrap widthFreeExpand">
|
||||
<input id="openai_enable_web_search" type="checkbox" />
|
||||
<span data-i18n="Enable web search">Enable web search</span>
|
||||
@@ -1984,7 +1984,7 @@
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,aimlapi,openrouter,groq,deepseek,makersuite,vertexai,ai21,xai,pollinations,moonshot,fireworks,cometapi">
|
||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,aimlapi,openrouter,groq,deepseek,makersuite,vertexai,ai21,xai,pollinations,moonshot,fireworks,cometapi,electronhub,azure_openai">
|
||||
<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>
|
||||
@@ -1999,7 +1999,7 @@
|
||||
<strong data-i18n="enable_functions_desc_4">Not supported when Prompt Post-Processing with "no tools" is used!</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,mistralai,makersuite,vertexai,claude,custom,xai,pollinations,moonshot,cohere,cometapi">
|
||||
<div class="range-block" data-source="openai,aimlapi,openrouter,mistralai,makersuite,vertexai,claude,custom,xai,pollinations,moonshot,cohere,cometapi,nanogpt,electronhub,azure_openai">
|
||||
<label for="openai_image_inlining" class="checkbox_label flexWrap widthFreeExpand">
|
||||
<input id="openai_image_inlining" type="checkbox" />
|
||||
<span data-i18n="Send inline images">Send inline images</span>
|
||||
@@ -2015,7 +2015,7 @@
|
||||
<code><i class="fa-solid fa-wand-magic-sparkles"></i></code>
|
||||
<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,xai,pollinations,cohere">
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,xai,pollinations,cohere,cometapi,nanogpt,moonshot,aimlapi,openrouter,mistralai,electronhub,azure_openai">
|
||||
<div class="flex-container oneline-dropdown">
|
||||
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
|
||||
Inline Image Quality
|
||||
@@ -2077,7 +2077,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai,fireworks,cometapi">
|
||||
<div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai,fireworks,cometapi,electronhub,azure_openai">
|
||||
<label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
|
||||
<input id="openai_show_thoughts" type="checkbox" />
|
||||
<span data-i18n="Request model reasoning">Request model reasoning</span>
|
||||
@@ -2091,7 +2091,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite,vertexai,aimlapi,openrouter,pollinations,perplexity,cometapi">
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom,claude,xai,makersuite,vertexai,aimlapi,openrouter,pollinations,perplexity,cometapi,electronhub,azure_openai">
|
||||
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. 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">
|
||||
<span data-i18n="Reasoning Effort">Reasoning Effort</span>
|
||||
@@ -2105,7 +2105,7 @@
|
||||
<option data-i18n="openai_reasoning_effort_high" value="high">High</option>
|
||||
<option data-i18n="openai_reasoning_effort_maximum" value="max">Maximum</option>
|
||||
</select>
|
||||
<div class="toggle-description justifyLeft marginBot5" data-source="openai,custom,xai,aimlapi,openrouter,perplexity" data-i18n="OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level.">
|
||||
<div class="toggle-description justifyLeft marginBot5" data-source="openai,custom,xai,aimlapi,openrouter,perplexity,electronhub,azure_openai" data-i18n="OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level.">
|
||||
OpenAI-style options: low, medium, high. Minimum and maximum are aliased to low and high. Auto does not send an effort level.
|
||||
</div>
|
||||
<div class="toggle-description justifyLeft marginBot5" data-source="claude" data-i18n="Allocates a portion of the response length for thinking (min: 1024 tokens, low: 10%, medium: 25%, high: 50%, max: 95%), but minimum 1024 tokens. Auto does not request thinking.">
|
||||
@@ -2144,7 +2144,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block m-t-1" data-source="openai,aimlapi,openrouter,custom">
|
||||
<div class="range-block m-t-1" data-source="openai,aimlapi,openrouter,custom,azure_openai">
|
||||
<div id="logit_bias_openai" class="range-block-title openai_restorable" data-i18n="Logit Bias">
|
||||
Logit Bias
|
||||
</div>
|
||||
@@ -2802,10 +2802,13 @@
|
||||
<optgroup>
|
||||
<option value="ai21">AI21</option>
|
||||
<option value="aimlapi">AI/ML API</option>
|
||||
<option value="azure_openai">Azure OpenAI</option>
|
||||
<option value="claude">Claude</option>
|
||||
<option value="cohere">Cohere</option>
|
||||
<option value="cometapi">CometAPI</option>
|
||||
<!-- Temporarily disabled. -->
|
||||
<!-- <option value="cometapi">CometAPI</option> -->
|
||||
<option value="deepseek">DeepSeek</option>
|
||||
<option value="electronhub">Electron Hub</option>
|
||||
<option value="fireworks">Fireworks AI</option>
|
||||
<option value="groq">Groq</option>
|
||||
<option value="makersuite">Google AI Studio</option>
|
||||
@@ -3177,6 +3180,7 @@
|
||||
<option value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option>
|
||||
<option value="gemini-2.5-flash-lite">gemini-2.5-flash-lite</option>
|
||||
<option value="gemini-2.5-flash-lite-preview-06-17">gemini-2.5-flash-lite-preview-06-17</option>
|
||||
<option value="gemini-2.5-flash-image-preview">gemini-2.5-flash-image-preview</option>
|
||||
</optgroup>
|
||||
<optgroup label="Gemini 2.0">
|
||||
<option value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05 → 2.5-pro-exp-03-25</option>
|
||||
@@ -3355,6 +3359,7 @@
|
||||
<option value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option>
|
||||
<option value="gemini-2.5-flash-lite">gemini-2.5-flash-lite</option>
|
||||
<option value="gemini-2.5-flash-lite-preview-06-17">gemini-2.5-flash-lite-preview-06-17</option>
|
||||
<option value="gemini-2.5-flash-image-preview">gemini-2.5-flash-image-preview</option>
|
||||
</optgroup>
|
||||
<optgroup label="Gemini 2.0">
|
||||
<option value="gemini-2.0-flash-exp" data-mode="full">gemini-2.0-flash-exp</option>
|
||||
@@ -3466,6 +3471,20 @@
|
||||
<option value="mistral-saba-24b">mistral-saba-24b</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="electronhub_form" data-source="electronhub">
|
||||
<h4 data-i18n="Electron Hub API Key">Electron Hub API Key</h4>
|
||||
<div class="flex-container">
|
||||
<input id="api_key_electronhub" name="api_key_electronhub" class="text_pole flex1" value="" type="text" autocomplete="off">
|
||||
<div title="Manage API keys" data-i18n="[title]Manage API keys" class="menu_button fa-solid fa-key fa-fw manage-api-keys" data-key="api_key_electronhub"></div>
|
||||
</div>
|
||||
<div data-for="api_key_electronhub" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you click 'Connect'.">
|
||||
For privacy reasons, your API key will be hidden after you click 'Connect'.
|
||||
</div>
|
||||
<h4 data-i18n="Electron Hub Model">Electron Hub Model</h4>
|
||||
<select id="model_electronhub_select">
|
||||
<option value="" data-i18n="-- Connect to the API --">-- Connect to the API --</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="nanogpt_form" data-source="nanogpt">
|
||||
<h4 data-i18n="NanoGPT API Key">NanoGPT API Key</h4>
|
||||
<div class="flex-container">
|
||||
@@ -3717,6 +3736,49 @@
|
||||
<option value="kimi-thinking-preview">kimi-thinking-preview</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="azure_openai_settings" data-source="azure_openai">
|
||||
<!-- Azure Base URL -->
|
||||
<h4><span data-i18n="Azure Base URL">Azure Base URL</span></h4>
|
||||
<div class="flex-container">
|
||||
<input id="azure_base_url" data-setting="azure_base_url" class="text_pole wide100p" type="text" placeholder="https://your-resource.openai.azure.com/">
|
||||
</div>
|
||||
|
||||
<!-- Azure Deployment Name -->
|
||||
<h4><span data-i18n="Deployment Name">Deployment Name</span></h4>
|
||||
<div class="flex-container">
|
||||
<input id="azure_deployment_name" data-setting="azure_deployment_name" class="text_pole wide100p" type="text" placeholder="your-deployment-name" title="The name of your model deployment in Azure." data-i18n="[title]The name of your model deployment in Azure.">
|
||||
</div>
|
||||
|
||||
<!-- Azure API Version Dropdown -->
|
||||
<h4><span data-i18n="API Version">API Version</span></h4>
|
||||
<div class="flex-container">
|
||||
<select id="azure_api_version" data-setting="azure_api_version" class="text_pole wide100p">
|
||||
<option value="2025-04-01-preview">2025-04-01-preview</option>
|
||||
<option value="2024-10-21">2024-10-21</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Azure API Key -->
|
||||
<h4><span data-i18n="Azure API Key">Azure API Key</span></h4>
|
||||
<div class="flex-container">
|
||||
<input id="api_key_azure_openai" data-setting="api_key_azure_openai" class="text_pole flex1" type="password" autocomplete="off">
|
||||
<div title="Manage API keys" data-i18n="[title]Manage API keys" class="menu_button fa-solid fa-key fa-fw manage-api-keys" data-key="api_key_azure_openai"></div>
|
||||
</div>
|
||||
<div class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you click 'Connect'." data-for="api_key_azure_openai">
|
||||
For privacy reasons, your API key will be hidden after you click 'Connect'.
|
||||
</div>
|
||||
|
||||
<!-- Model Name (Select) -->
|
||||
<h4><span data-i18n="Model Name">Model Name</span></h4>
|
||||
<div class="flex-container">
|
||||
<select id="azure_openai_model" data-setting="azure_openai_model" class="text_pole wide100p">
|
||||
<option value="" disabled selected data-i18n="Click 'Connect' to fetch model name">Click 'Connect' to fetch model name</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<small data-i18n="The underlying model of your deployment. This is detected automatically when you connect.">The underlying model of your deployment. This is detected automatically when you connect.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div id="prompt_post_processing_form">
|
||||
<h4>
|
||||
<span data-i18n="Prompt Post-Processing">
|
||||
@@ -5281,13 +5343,11 @@
|
||||
<div id="site_logo" class="drawer-toggle drawer-header" title="Change Background Image" data-i18n="[title]Change Background Image">
|
||||
<div class="drawer-icon fa-solid fa-panorama fa-fw closedIcon"></div>
|
||||
</div>
|
||||
<div id="Backgrounds" class="drawer-content closedDrawer">
|
||||
<div class="flex-container">
|
||||
<div id="Backgrounds" class="drawer-content closedDrawer bg-drawer-layout">
|
||||
<div id="bg-header-fixed">
|
||||
<div class="flex-container alignItemsBaseline wide100p">
|
||||
<h3 class="margin0 flex2" data-i18n="Background Image">
|
||||
Background Image
|
||||
</h3>
|
||||
<input id="bg-filter" data-i18n="[placeholder]Filter" placeholder="Filter" class="text_pole flex1" type="search" />
|
||||
<h3 id="bg-header-title" class="margin0" data-i18n="Backgrounds">Backgrounds</h3>
|
||||
<input id="bg-filter" class="text_pole flex1" type="search" data-i18n="[placeholder]Search" placeholder="Search" />
|
||||
<select id="background_fitting" class="text_pole" data-i18n="[title]Background Fitting" title="Background Fitting">
|
||||
<option value="classic" data-i18n="Classic">Classic</option>
|
||||
<option value="cover" data-i18n="Cover">Cover</option>
|
||||
@@ -5299,17 +5359,17 @@
|
||||
<i class="fa-solid fa-wand-magic"></i>
|
||||
<span data-i18n="Auto-select">Auto-select</span>
|
||||
</div>
|
||||
<label for="add_bg_button" id="add_background_button_top" class="menu_button menu_button_icon interactable" title="Add a new background">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
<span data-i18n="Add Background">Add Background</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bg-scrollable-content">
|
||||
<h3 data-i18n="System Backgrounds" class="wide100p textAlignCenter">
|
||||
System Backgrounds
|
||||
</h3>
|
||||
<div id="bg_menu_content" class="bg_list">
|
||||
<form id="form_bg_download" class="bg_example no-border no-shadow" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<label class="input-file">
|
||||
<input type="file" id="add_bg_button" name="avatar" accept="image/*, video/*">
|
||||
<div class="bg_example no-border no-shadow add_bg_but" style="background-image: url('/img/addbg3.png');"></div>
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
<h3 data-i18n="Chat Backgrounds" class="wide100p textAlignCenter">
|
||||
Chat Backgrounds
|
||||
@@ -5320,6 +5380,9 @@
|
||||
<div id="bg_custom_content" class="bg_list">
|
||||
</div>
|
||||
</div>
|
||||
<form id="form_bg_upload" style="display: none;">
|
||||
<input type="file" id="add_bg_button" name="avatar" accept="image/jpeg,image/png,image/gif,image/bmp,image/svg+xml,video/*">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="extensions-settings-button" class="drawer">
|
||||
@@ -5409,7 +5472,7 @@
|
||||
<div class="drawer-toggle">
|
||||
<div class="drawer-icon fa-solid fa-face-smile fa-fw closedIcon" title="Persona Management" data-i18n="[title]Persona Management"></div>
|
||||
</div>
|
||||
<div class="drawer-content closedDrawer">
|
||||
<div id="PersonaManagement" class="drawer-content closedDrawer">
|
||||
<div class="flex-container wide100p alignitemscenter spaceBetween flexNoGap">
|
||||
<div class="flex-container alignItemsBaseline wide100p">
|
||||
<div class="flex1 flex-container alignItemsBaseline">
|
||||
@@ -6253,14 +6316,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="background_template" class="template_element">
|
||||
<div class="bg_example flex-container" bgfile="" class="bg_example_img" title="">
|
||||
<div title="Copy to system backgrounds" data-i18n="[title]Copy to system backgrounds" class="bg_button bg_example_copy fa-solid fa-file-arrow-up"></div>
|
||||
<div title="Rename background" data-i18n="[title]Rename background" class="bg_button bg_example_edit fa-solid fa-pencil"></div>
|
||||
<div title="Lock" data-i18n="[title]Lock" class="bg_button bg_example_lock fa-solid fa-lock"></div>
|
||||
<div title="Unlock" data-i18n="[title]Unlock" class="bg_button bg_example_unlock fa-solid fa-lock-open"></div>
|
||||
<div title="Delete background" data-i18n="[title]Delete background" class="bg_button bg_example_cross fa-solid fa-circle-xmark"></div>
|
||||
<div class="BGSampleTitle">
|
||||
<div class="bg_example flex-container" bgfile="" title="">
|
||||
<div class="bg_example_img"></div>
|
||||
<div class="mobile-only-menu-toggle">
|
||||
<i class="fa-solid fa-ellipsis-vertical"></i>
|
||||
</div>
|
||||
<div class="jg-menu">
|
||||
<div data-action="copy" class="jg-button jg-copy fa-solid fa-file-arrow-up" data-i18n="[title]Copy to system backgrounds" title="Copy to system backgrounds"></div>
|
||||
<!-- temporarily moved lock icon here (will be moved to header) -->
|
||||
<div data-action="lock" class="jg-button jg-lock fa-solid fa-lock fa-fw pointer" data-i18n="[title]Lock" title="Lock"></div>
|
||||
<div data-action="unlock" class="jg-button jg-unlock fa-solid fa-lock-open fa-fw pointer" data-i18n="[title]Unlock" title="Unlock"></div>
|
||||
<div data-action="edit" class="jg-button jg-edit fa-solid fa-pen-to-square fa-fw pointer" data-i18n="[title]Rename Background" title="Rename Background"></div>
|
||||
<div data-action="delete" class="jg-button jg-delete fa-solid fa-trash-can fa-fw pointer" data-i18n="[title]Delete Background" title="Delete Background"></div>
|
||||
</div>
|
||||
<div class="BGSampleTitle"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- templates for JS to reuse when needed -->
|
||||
@@ -6436,7 +6505,7 @@
|
||||
</span>
|
||||
<div class="flex-container">
|
||||
<div class="flex-container flexFlowColumn">
|
||||
<label class="checkbox flex-container alignitemscenter flexNoGap" title="This entry will not be recursively activated by other entries.">
|
||||
<label class="checkbox flex-container alignitemscenter flexNoGap" data-i18n="[title]This entry will not be recursively activated by other entries." title="This entry will not be recursively activated by other entries.">
|
||||
<input type="checkbox" name="excludeRecursion" />
|
||||
<span data-i18n="Non-recursable">
|
||||
Non-recursable
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "وضع علامة",
|
||||
"API key (optional)": "مفتاح API (اختياري)",
|
||||
"Server url": "رابط الخادم",
|
||||
"Electron Hub API Key": "مفتاح API لـ Electron Hub",
|
||||
"Electron Hub Model": "نموذج Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "مثال: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "نموذج مخصص (اختياري)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (وضع غلاف OpenAI API)",
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "Flagge",
|
||||
"API key (optional)": "API-Schlüssel (optional)",
|
||||
"Server url": "Server-URL",
|
||||
"Electron Hub API Key": "Electron Hub API-Schlüssel",
|
||||
"Electron Hub Model": "Electron Hub-Modell",
|
||||
"Example: http://127.0.0.1:5000": "Beispiel: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Benutzerdefiniertes Modell (optional)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (OpenAI API-Wrappermodus)",
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "bandera",
|
||||
"API key (optional)": "Clave API (opcional)",
|
||||
"Server url": "URL del servidor",
|
||||
"Electron Hub API Key": "Clave API de Electron Hub",
|
||||
"Electron Hub Model": "Modelo de Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "Ejemplo: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Modelo personalizado (opcional)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (modo contenedor de API OpenAI)",
|
||||
|
||||
@@ -1411,6 +1411,8 @@
|
||||
"Do not proceed if you do not agree to this!": "Ne continuez pas si vous n'êtes pas d'accord avec cela !",
|
||||
"Claude API Key": "Clé API Claude",
|
||||
"Allow fallback models": "Autoriser les modèles de secours",
|
||||
"Electron Hub API Key": "Clé API Electron Hub",
|
||||
"Electron Hub Model": "Modèle Electron Hub",
|
||||
"NanoGPT API Key": "Clé API NanoGPT",
|
||||
"NanoGPT Model": "Modèle NanoGPT",
|
||||
"DeepSeek API Key": "Clé API DeepSeek",
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "bandiera",
|
||||
"API key (optional)": "Chiave API (opzionale)",
|
||||
"Server url": "URL del server",
|
||||
"Electron Hub API Key": "Chiave API di Electron Hub",
|
||||
"Electron Hub Model": "Modello di Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "Esempio: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Modello personalizzato (opzionale)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (modalità wrapper API OpenAI)",
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "フラグ",
|
||||
"API key (optional)": "APIキー(オプション)",
|
||||
"Server url": "サーバーURL",
|
||||
"Electron Hub API Key": "Electron Hub API キー",
|
||||
"Electron Hub Model": "Electron Hub モデル",
|
||||
"Example: http://127.0.0.1:5000": "例: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "カスタムモデル(オプション)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (OpenAI API ラッパーモード)",
|
||||
|
||||
@@ -319,6 +319,8 @@
|
||||
"flag": "깃발",
|
||||
"API key (optional)": "API 키 (선택 사항)",
|
||||
"Server url": "서버 URL",
|
||||
"Electron Hub API Key": "Electron Hub API 키",
|
||||
"Electron Hub Model": "Electron Hub 모델",
|
||||
"Example: http://127.0.0.1:5000": "예시: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "사용자 정의 모델 (선택 사항)",
|
||||
"vllm-project/vllm": "vllm-project/vllm(OpenAI API 래퍼 모드)",
|
||||
|
||||
+66
-17
@@ -1,17 +1,66 @@
|
||||
[
|
||||
{ "lang": "ar-sa", "display": "عربي (Arabic)" },
|
||||
{ "lang": "zh-cn", "display": "简体中文 (Chinese) (Simplified)" },
|
||||
{ "lang": "zh-tw", "display": "繁體中文 (Chinese) (Taiwan)" },
|
||||
{ "lang": "nl-nl", "display": "Nederlands (Dutch)" },
|
||||
{ "lang": "de-de", "display": "Deutsch (German)" },
|
||||
{ "lang": "fr-fr", "display": "Français (French)" },
|
||||
{ "lang": "is-is", "display": "íslenska (Icelandic)" },
|
||||
{ "lang": "it-it", "display": "Italiano (Italian)" },
|
||||
{ "lang": "ja-jp", "display": "日本語 (Japanese)" },
|
||||
{ "lang": "ko-kr", "display": "한국어 (Korean)" },
|
||||
{ "lang": "pt-pt", "display": "Português (Portuguese brazil)" },
|
||||
{ "lang": "ru-ru", "display": "Русский (Russian)" },
|
||||
{ "lang": "es-es", "display": "Español (Spanish)" },
|
||||
{ "lang": "uk-ua", "display": "Yкраїнська (Ukrainian)" },
|
||||
{ "lang": "vi-vn", "display": "Tiếng Việt (Vietnamese)" }
|
||||
]
|
||||
[
|
||||
{
|
||||
"lang": "ar-sa",
|
||||
"display": "عربي (Arabic)"
|
||||
},
|
||||
{
|
||||
"lang": "zh-cn",
|
||||
"display": "简体中文 (Chinese) (Simplified)"
|
||||
},
|
||||
{
|
||||
"lang": "zh-tw",
|
||||
"display": "繁體中文 (Chinese) (Taiwan)"
|
||||
},
|
||||
{
|
||||
"lang": "nl-nl",
|
||||
"display": "Nederlands (Dutch)"
|
||||
},
|
||||
{
|
||||
"lang": "de-de",
|
||||
"display": "Deutsch (German)"
|
||||
},
|
||||
{
|
||||
"lang": "fr-fr",
|
||||
"display": "Français (French)"
|
||||
},
|
||||
{
|
||||
"lang": "is-is",
|
||||
"display": "íslenska (Icelandic)"
|
||||
},
|
||||
{
|
||||
"lang": "it-it",
|
||||
"display": "Italiano (Italian)"
|
||||
},
|
||||
{
|
||||
"lang": "ja-jp",
|
||||
"display": "日本語 (Japanese)"
|
||||
},
|
||||
{
|
||||
"lang": "ko-kr",
|
||||
"display": "한국어 (Korean)"
|
||||
},
|
||||
{
|
||||
"lang": "pt-pt",
|
||||
"display": "Português (Portuguese brazil)"
|
||||
},
|
||||
{
|
||||
"lang": "ru-ru",
|
||||
"display": "Русский (Russian)"
|
||||
},
|
||||
{
|
||||
"lang": "es-es",
|
||||
"display": "Español (Spanish)"
|
||||
},
|
||||
{
|
||||
"lang": "uk-ua",
|
||||
"display": "Українська (Ukrainian)"
|
||||
},
|
||||
{
|
||||
"lang": "vi-vn",
|
||||
"display": "Tiếng Việt (Vietnamese)"
|
||||
},
|
||||
{
|
||||
"lang": "th-th",
|
||||
"display": "ไทย (Thai)"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "bandeira",
|
||||
"API key (optional)": "Chave da API (opcional)",
|
||||
"Server url": "URL do servidor",
|
||||
"Electron Hub API Key": "Chave API Electron Hub",
|
||||
"Electron Hub Model": "Modelo Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "Exemplo: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Modelo personalizado (opcional)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (modo wrapper da API OpenAI)",
|
||||
|
||||
+153
-84
@@ -40,7 +40,7 @@
|
||||
"Smoothing Factor": "Коэффициент сглаживания",
|
||||
"No Repeat Ngram Size": "Размер no_repeat_ngram",
|
||||
"Min Length": "Мин. длина",
|
||||
"Alternative server URL (leave empty to use the default value).": "URL альтернативного сервера (оставьте пустым для стандартного значения)",
|
||||
"Alternative server URL (leave empty to use the default value).": "URL реверс-прокси (оставьте пустым для стандартного значения)",
|
||||
"Remove your real OAI API Key from the API panel BEFORE typing anything into this box": "Удалите свой личный OAI API Key из панели API, и ТОЛЬКО ПОСЛЕ ЭТОГО вводите что-то сюда",
|
||||
"We cannot provide support for problems encountered while using an unofficial OpenAI proxy": "Мы не сможем предоставить помощь с проблемами, с которыми вы столкнетесь при использовании неофициальных прокси для OpenAI",
|
||||
"Context Size (tokens)": "Размер контекста (в токенах)",
|
||||
@@ -145,7 +145,7 @@
|
||||
"View API Usage Metrics": "Посмотреть статистику использования API",
|
||||
"Show External models (provided by API)": "Показать \"сторонние\" модели (предоставленные API)",
|
||||
"Allow fallback routes": "Разрешить резервные маршруты",
|
||||
"Allow fallback routes Description": "Автоматически выбирает альтернативную модель, если выбранная модель не может удовлетворить ваш запрос.",
|
||||
"Allow fallback routes Description": "Автоматически выбирает альтернативную модель, если выбранная модель не может обслужить ваш запрос.",
|
||||
"OpenRouter API Key": "Ключ от OpenRouter API",
|
||||
"OpenRouter Model": "Модель OpenRouter",
|
||||
"View Remaining Credits": "Посмотреть оставшиеся кредиты",
|
||||
@@ -154,7 +154,7 @@
|
||||
"View hidden API keys": "Посмотреть скрытые API-ключи",
|
||||
"Advanced Formatting": "Расширенное форматирование",
|
||||
"Context Template": "Шаблон контекста",
|
||||
"Replace Macro in Stop Strings": "Заменять макросы в пользовательских стоп-строках",
|
||||
"Replace Macro in Stop Strings": "Заменять макросы в стоп-строках",
|
||||
"Story String": "Общий шаблон",
|
||||
"Example Separator": "Разделитель примеров сообщений",
|
||||
"Chat Start": "Начало чата",
|
||||
@@ -184,7 +184,7 @@
|
||||
"Scan Depth": "Глубина сканирования",
|
||||
"Case-Sensitive": "С учетом регистра",
|
||||
"Match Whole Words": "Только полное совпадение",
|
||||
"Use global setting": "Использовать глобальную настройку",
|
||||
"Use global setting": "Глоб. настройка",
|
||||
"Yes": "Да",
|
||||
"No": "Нет",
|
||||
"Context %": "Процент контекста",
|
||||
@@ -201,7 +201,7 @@
|
||||
"Bubbles": "Пузыри",
|
||||
"No Blur Effect": "Отключить размытие",
|
||||
"No Text Shadows": "Отключить тень текста",
|
||||
"Waifu Mode": "Рeжим Вайфу",
|
||||
"Waifu Mode": "Режим вайфу",
|
||||
"Message Timer": "Таймер сообщений",
|
||||
"Model Icon": "Значки моделей",
|
||||
"Advanced Character Search": "Расширенный поиск по персонажам",
|
||||
@@ -279,7 +279,7 @@
|
||||
"Impersonate": "Перевоплощение",
|
||||
"Regenerate": "Повторная генерация",
|
||||
"Message Sound": "Звук сообщения",
|
||||
"Author's Note": "Заметки автора",
|
||||
"Author's Note": "Авторские заметки",
|
||||
"Replace empty message": "Заменять пустые сообщения",
|
||||
"Send this text instead of nothing when the text box is empty.": "Этот текст будет отправлен в случае отсутствия текста на отправку.",
|
||||
"Unrestricted maximum value for the context slider": "Убрать потолок для ползунка контекста. Включайте только если точно понимаете, что делаете",
|
||||
@@ -322,8 +322,8 @@
|
||||
"Order ↘": "Порядок ↘",
|
||||
"UID ↗": "UID ↗",
|
||||
"UID ↘": "UID ↘",
|
||||
"Trigger% ↗": "Триггер% ↗",
|
||||
"Trigger% ↘": "Триггер% ↘",
|
||||
"Trigger% ↗": "% срабатываний ↗",
|
||||
"Trigger% ↘": "% срабатываний ↘",
|
||||
"Depth:": "Глубина:",
|
||||
"Character Lore First": "Сначала лор персонажа",
|
||||
"Global Lore First": "Сначала глобальный лор",
|
||||
@@ -334,12 +334,17 @@
|
||||
"Exclude from recursion": "Исключить из рекурсии",
|
||||
"Entry Title/Memo": "Название или заметка о записи",
|
||||
"Position:": "Положение:",
|
||||
"T_Position": "↑Char: Перед определениями Персонажа\n↓Char: После определений Персонажа\n↑AN: Перед Пометок автора\n↓AN: После Пометок автора\n@D: На глубине",
|
||||
"T_Position": "↑Перс: Перед описанием персонажа\n↓Перс: После описания персонажа\n↑ПС: Перед примерами сообщений\n↓ПС: После примеров сообщений\n↑АЗ: Перед авторскими заметками\n↓АЗ: После авторских заметок\nНа глуб. ⚙️: на глубине (система)\nНа глуб. 👤: на глубине (пользователь)\nНа глуб. 🤖: на глубине (ассистент)",
|
||||
"Before Char Defs": "↑Перс.",
|
||||
"After Char Defs": "↓Перс.",
|
||||
"Before AN": "↑АЗ",
|
||||
"After AN": "↓АЗ",
|
||||
"Order": "Очерёдность:",
|
||||
"Before EM": "↑ПС",
|
||||
"After EM": "↓ПС",
|
||||
"at Depth System": "На глуб. ⚙️",
|
||||
"at Depth User": "На глуб. 👤",
|
||||
"at Depth AI": "На глуб. 🤖",
|
||||
"Order": "Приоритет:",
|
||||
"Update a theme file": "Обновить файл темы",
|
||||
"Save as a new theme": "Сохранить как новую тему",
|
||||
"Minimum number of blacklisted words detected to trigger an auto-swipe": "Минимальное количество обнаруженных запрещённых слов, при котором срабатывает авто-свайп.",
|
||||
@@ -385,7 +390,7 @@
|
||||
"Remove text shadow effect": "Удаление эффекта тени от текста.",
|
||||
"Reduce chat height, and put a static sprite behind the chat window": "Уменьшить высоту чата и поместить статичный спрайт за окном чата.",
|
||||
"Always show the full list of the Message Actions context items for chat messages, instead of hiding them behind '...'": "Всегда показывать полный список действий с сообщением, а не прятать их за '...'.",
|
||||
"Alternative UI for numeric sampling parameters with fewer steps": "Альтернативный пользовательский интерфейс для числовых параметров выборки с меньшим количеством шагов.",
|
||||
"Alternative UI for numeric sampling parameters with fewer steps": "Уменьшить кол-во шагов для параметров, регулируемых слайдерами.",
|
||||
"Entirely unrestrict all numeric sampling parameters": "Снять ограничения со всех числовых сэмплеров.",
|
||||
"Time the AI's message generation, and show the duration in the chat log": "Время генерации сообщений ИИ и его показ в журнале чата.",
|
||||
"Show a timestamp for each message in the chat log": "Показывать временную метку для каждого сообщения в журнале чата.",
|
||||
@@ -409,7 +414,7 @@
|
||||
"If checked and the character card contains a jailbreak override (Post History Instruction), use that instead": "При включении этой опции, пользовательский джейлбрейк будет заменяться кастомным джейлбрейком из карточки (при его наличии).",
|
||||
"Show actual file names on the disk, in the characters list display only": "Отображение названий файлов персонажей на диске, только в списке персонажей.",
|
||||
"Prompt to import embedded card tags on character import. Otherwise embedded tags are ignored": "Запрашивать разрешения на импорт встроенных тегов карт при импорте персонажей. В противном случае встроенные теги игнорируются.",
|
||||
"Hide character definitions from the editor panel behind a spoiler button": "Спрятать определения персонажей из панели редактора за кнопку спойлера.",
|
||||
"Hide character definitions from the editor panel behind a spoiler button": "Спрятать описания персонажей из панели редактора за кнопку спойлера.",
|
||||
"Show a button in the input area to ask the AI to continue (extend) its last message": "Показывать на форме ответа кнопку, по нажатии на которую ИИ продолжит своё предыдущее сообщение.",
|
||||
"Show arrow buttons on the last in-chat message to generate alternative AI responses. Both PC and mobile": "Показывать кнопки со стрелками на последнем сообщении в чате, чтобы генерировать альтернативные ответы ИИ. Как для ПК, так и для мобильных устройств.",
|
||||
"Allow using swiping gestures on the last in-chat message to trigger swipe generation. Mobile only, no effect on PC": "Позволяет использовать жесты смахивания на последнем сообщении в чате, чтобы вызвать альтернативную генерацию. Только для мобильных устройств, на ПК не работает.",
|
||||
@@ -427,8 +432,8 @@
|
||||
"Your Persona": "Ваша персона",
|
||||
"Show notifications on switching personas": "Показывать уведомления при смене персоны",
|
||||
"In Story String / Prompt Manager": "В общем шаблоне / Менеджере промптов",
|
||||
"Top of Author's Note": "Сверху от заметок автора",
|
||||
"Bottom of Author's Note": "Снизу от заметок автора",
|
||||
"Top of Author's Note": "Сверху от авторских заметок",
|
||||
"Bottom of Author's Note": "Снизу от авторских заметок",
|
||||
"How do I use this?": "Как пользоваться?",
|
||||
"More...": "Ещё...",
|
||||
"Link to World Info": "Ссылка на информацию о мире",
|
||||
@@ -436,7 +441,7 @@
|
||||
"Scenario Override": "Перезапись сценария",
|
||||
"Rename": "Переименовать",
|
||||
"Character Description": "Описание персонажа",
|
||||
"Creator's Notes": "Заметки создателя",
|
||||
"Creator's Notes": "Примечание от создателя",
|
||||
"A-Z": "A-Z",
|
||||
"Z-A": "Z-A",
|
||||
"Newest": "Сначала новые",
|
||||
@@ -471,7 +476,7 @@
|
||||
"Enter your name": "Введите свое имя",
|
||||
"Name this character": "Назовите этого персонажа",
|
||||
"Search / Create Tags": "Искать / Создать тэги",
|
||||
"Describe your character's physical and mental traits here.": "Опишите ментальные и физические черты персонажа",
|
||||
"Describe your character's physical and mental traits here.": "Опишите характер персонажа и его внешность",
|
||||
"This will be the first message from the character that starts every chat.": "Это будет первое сообщение от персонажа при начале нового чата",
|
||||
"Chat Name (Optional)": "Название чата (необязательно)",
|
||||
"Search...": "Поиск...",
|
||||
@@ -483,10 +488,10 @@
|
||||
"(Write a comma-separated list of tags)": "(Список тегов через запятую)",
|
||||
"(A brief description of the personality)": "(Краткое описание личности)",
|
||||
"(Circumstances and context of the interaction)": "(Обстоятельства и контекст этого диалога)",
|
||||
"(Examples of chat dialog. Begin each example with START on a new line.)": "(Примеры диалога. Начинайте каждый пример с START или новой строкой.)",
|
||||
"(Examples of chat dialog. Begin each example with START on a new line.)": "(Примеры диалога. Начинайте каждый пример со START и на новой строке.)",
|
||||
"Type here...": "Пишите здесь...",
|
||||
"Comma separated (required)": "Через запятую (обязательное поле)",
|
||||
"What this keyword should mean to the AI, sent verbatim": "Что это ключевое слово должно означать для ИИ, отправляется дословно",
|
||||
"What this keyword should mean to the AI, sent verbatim": "Объясните ИИ, что он должен знать об этом ключевом слове",
|
||||
"Filter to Character(s)": "Фильтр по персонажу(ам)",
|
||||
"Character Exclusion": "Исключить персонажей",
|
||||
"Inclusion Group": "Группа записей",
|
||||
@@ -569,12 +574,12 @@
|
||||
"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.": "Когда ИИ генерирует ответ, он будет совмещён с записями из глобально выбранного мира.",
|
||||
"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!": "ВНИМАНИЕ: эти выборы необязательные и не будут сохранены при экспорте персонажа!",
|
||||
"Associate one or more auxillary Lorebooks with this character.": "Привязать к этому персонажу один или больше вспомогательных лорбуков.",
|
||||
"NOTE: These choices are optional and won't be preserved on character export!": "ВНИМАНИЕ: вспомогательные лорбуки не будут выгружены при экспорте персонажа!",
|
||||
"Rename chat file": "Переименовать чат",
|
||||
"Export JSONL chat file": "Экспортировать чат в формате JSONL",
|
||||
"Download chat as plain text document": "Скачать чат в формате .txt",
|
||||
@@ -784,20 +789,20 @@
|
||||
"Enable magnification for zoomed avatar display.": "Добавляет возможность приближать увеличенную версию аватарки.",
|
||||
"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": "Перед основным промптом / строкой истории",
|
||||
"After Main Prompt / Story String": "После основного промпта / строки истории",
|
||||
"Include in World Info Scanning": "Учитывать при сканировании лорбуком",
|
||||
"Before Main Prompt / Story String": "Перед основным промптом / общим шаблоном",
|
||||
"After Main Prompt / Story String": "После основного промпта / общего шаблона",
|
||||
"In-chat @ Depth": "Встав. на глуб.",
|
||||
"as": "роль:",
|
||||
"Insertion Frequency": "Частота вставки",
|
||||
"(0 = Disable, 1 = Always)": "(0 = никогда, 1 = всегда)",
|
||||
"User inputs until next insertion:": "Ваших сообщений до след. вставки:",
|
||||
"Character Author's Note (Private)": "Заметки автора персонажа (личные)",
|
||||
"Will be automatically added as the author's note for this character. Will be used in groups, but can't be modified when a group chat is open.": "Автоматически применятся к этому персонажу в качестве заметок автора. Будут использоваться в группах, но при активном групповом чате к редактированию недоступны.",
|
||||
"Use character author's note": "Использовать заметки автора персонажа",
|
||||
"Replace Author's Note": "Вместо заметок автора",
|
||||
"Default Author's Note": "Стандартные заметки автора",
|
||||
"Will be automatically added as the Author's Note for all new chats.": "Будут автоматически добавляться во все новые чаты в качестве Заметок автора",
|
||||
"Character Author's Note (Private)": "Авторские заметки для персонажа (личные)",
|
||||
"Will be automatically added as the author's note for this character. Will be used in groups, but can't be modified when a group chat is open.": "Автоматически применятся к этому персонажу в качестве авторских заметок. Будут использоваться в группах, но при активном групповом чате к редактированию недоступны.",
|
||||
"Use character author's note": "Использовать авторские заметки для персонажа",
|
||||
"Replace Author's Note": "Вместо авторских заметок",
|
||||
"Default Author's Note": "Стандартные авторские заметки",
|
||||
"Will be automatically added as the Author's Note for all new chats.": "Будут автоматически добавляться во все новые чаты в качестве авторских заметок",
|
||||
"1 = disabled": "1 = откл.",
|
||||
"write short replies, write replies using past tense": "пиши короткие ответы, пиши в настоящем времени",
|
||||
"Positive Prompt": "Положительный промпт",
|
||||
@@ -906,7 +911,7 @@
|
||||
"ext_sum_force_text": "Пересказать сейчас",
|
||||
"Disable automatic summary updates. While paused, the summary remains as-is. You can still force an update by pressing the Summarize now button (which is only available with the Main API).": "Отключить авто-обновление пересказа. Пересказ всё время будет фиксированным. Однако останется возможность принудительно обновить пересказ через кнопку \"Пересказать сейчас\" (доступно только через Основное API)",
|
||||
"ext_sum_pause": "Приостановить",
|
||||
"Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN.": "Исключать из пересказа Информацию о мире и Заметки автора. Работает только для Основного API. Extras API всегда их исключает.",
|
||||
"Omit World Info and Author's Note from text to be summarized. Only has an effect when using the Main API. The Extras API always omits WI/AN.": "Исключать из пересказа Информацию о мире и Авторские заметки. Работает только для Основного API. Extras API всегда их исключает.",
|
||||
"ext_sum_no_wi_an": "Без мира и заметок",
|
||||
"ext_sum_settings_tip": "Изменить промпт пересказа, место для инжекта и т.д.",
|
||||
"ext_sum_settings": "Настройки пересказа",
|
||||
@@ -1333,13 +1338,7 @@
|
||||
"WI_Entry_Status_Normal": "Обычная",
|
||||
"WI_Entry_Status_Vectorized": "Векторизованная",
|
||||
"WI_Entry_Status_Disabled": "Отключена",
|
||||
"Before EM": "↑EM",
|
||||
"After EM": "↓EM",
|
||||
"at Depth System": "@D ⚙️",
|
||||
"at Depth User": "@D 👤",
|
||||
"at Depth AI": "@D 🤖",
|
||||
"Depth": "Глубина",
|
||||
"Trigger %:": "Trigger %:",
|
||||
"Probability": "Вероятность",
|
||||
"Duplicate world info entry": "Дублировать запись",
|
||||
"Delete world info entry": "Удалить запись",
|
||||
@@ -1411,26 +1410,7 @@
|
||||
"ext_regex_title": "Regex",
|
||||
"ext_regex_import_target": "Импортировать в:",
|
||||
"ext_regex_move_to_scoped": "Сделать локальным",
|
||||
"Trigger Stable Diffusion": "Trigger Stable Diffusion",
|
||||
"sd_Yourself": "Yourself",
|
||||
"sd_Your_Face": "Your Face",
|
||||
"sd_Me": "Me",
|
||||
"sd_The_Whole_Story": "The Whole Story",
|
||||
"sd_The_Last_Message": "The Last Message",
|
||||
"sd_Raw_Last_Message": "Raw Last Message",
|
||||
"sd_Background": "Background",
|
||||
"Image Generation": "Image Generation",
|
||||
"sd_refine_mode": "Allow to edit prompts manually before sending them to generation API",
|
||||
"sd_refine_mode_txt": "Edit prompts before generation",
|
||||
"sd_interactive_mode": "Automatically generate images when sending messages like 'send me a picture of cat'.",
|
||||
"sd_interactive_mode_txt": "Interactive mode",
|
||||
"sd_multimodal_captioning": "Use multimodal captioning to generate prompts for user and character portraits based on their avatars.",
|
||||
"sd_multimodal_captioning_txt": "Use multimodal captioning for portraits",
|
||||
"sd_expand": "Automatically extend prompts using text generation model",
|
||||
"sd_expand_txt": "Auto-enhance prompts",
|
||||
"sd_snap": "Snap generation requests with a forced aspect ratio (portraits, backgrounds) to the nearest known resolution, while trying to preserve the absolute pixel counts (recommended for SDXL).",
|
||||
"sd_snap_txt": "Snap auto-adjusted resolutions",
|
||||
"Source": "Source",
|
||||
"sd_auto_url": "Example: {{auto_url}}",
|
||||
"Authentication (optional)": "Authentication (optional)",
|
||||
"Example: username:password": "Example: username:password",
|
||||
@@ -1441,18 +1421,10 @@
|
||||
"sd_drawthings_auth_txt": "run DrawThings app with HTTP API switch enabled in the UI! The server must be accessible from the SillyTavern host machine.",
|
||||
"sd_vlad_url": "Example: {{vlad_url}}",
|
||||
"The server must be accessible from the SillyTavern host machine.": "The server must be accessible from the SillyTavern host machine.",
|
||||
"Hint: Save an API key in AI Horde API settings to use it here.": "Hint: Save an API key in AI Horde API settings to use it here.",
|
||||
"Allow NSFW images from Horde": "Разрешить NSFW-картинки в Horde",
|
||||
"Sanitize prompts (recommended)": "Sanitize prompts (recommended)",
|
||||
"Automatically adjust generation parameters to ensure free image generations.": "Automatically adjust generation parameters to ensure free image generations.",
|
||||
"Avoid spending Anlas": "Avoid spending Anlas",
|
||||
"Opus tier": "(Opus tier)",
|
||||
"View my Anlas": "View my Anlas",
|
||||
"These settings only apply to DALL-E 3": "These settings only apply to DALL-E 3",
|
||||
"Image Style": "Image Style",
|
||||
"Image Quality": "Image Quality",
|
||||
"Standard": "Standard",
|
||||
"HD": "HD",
|
||||
"sd_comfy_url": "Example: {{comfy_url}}",
|
||||
"Open workflow editor": "Open workflow editor",
|
||||
"Create new workflow": "Create new workflow",
|
||||
@@ -1460,9 +1432,6 @@
|
||||
"Enhance": "Enhance",
|
||||
"Refine": "Refine",
|
||||
"Decrisper": "Decrisper",
|
||||
"Sampling steps": "Sampling steps ()",
|
||||
"Width": "Width ()",
|
||||
"Height": "Height ()",
|
||||
"Resolution": "Resolution",
|
||||
"Model": "Model",
|
||||
"Sampling method": "Sampling method",
|
||||
@@ -1472,8 +1441,6 @@
|
||||
"DYN variants of SMEA samplers often lead to more varied output, but may fail at very high resolutions.": "DYN variants of SMEA samplers often lead to more varied output, but may fail at very high resolutions.",
|
||||
"DYN": "DYN",
|
||||
"Scheduler": "Scheduler",
|
||||
"Restore Faces": "Restore Faces",
|
||||
"Hires. Fix": "Hires. Fix",
|
||||
"Upscaler": "Upscaler",
|
||||
"Upscale by": "Upscale by",
|
||||
"Denoising strength": "Denoising strength",
|
||||
@@ -1484,7 +1451,6 @@
|
||||
"Delete style": "Delete style",
|
||||
"Common prompt prefix": "Common prompt prefix",
|
||||
"sd_prompt_prefix_placeholder": "Use {prompt} to specify where the generated prompt will be inserted",
|
||||
"Negative common prompt prefix": "Negative common prompt prefix",
|
||||
"Character-specific prompt prefix": "Character-specific prompt prefix",
|
||||
"Won't be used in groups.": "Won't be used in groups.",
|
||||
"sd_character_prompt_placeholder": "Any characteristics that describe the currently selected character. Will be added after a common prompt prefix.\nExample: female, green eyes, brown hair, pink shirt",
|
||||
@@ -1836,13 +1802,13 @@
|
||||
"Also delete the chat files": "Также удалить файлы чатов",
|
||||
"Delete the character?": "Удалить персонажа?",
|
||||
"Not a valid number": "Некорректное число",
|
||||
"Author's Note depth updated": "Глубина заметок автора обновлена",
|
||||
"Author's Note frequency updated": "Частота заметок автора обновлена",
|
||||
"Author's Note depth updated": "Глубина авторских заметок обновлена",
|
||||
"Author's Note frequency updated": "Частота авторских заметок обновлена",
|
||||
"Not a valid position": "Некорректная позиция",
|
||||
"Author's Note position updated": "Позиция заметок автора обновлена",
|
||||
"Something went wrong. Could not save character's author's note.": "Что-то пошло не так. Не удалось сохранить заметки автора для этого персонажа.",
|
||||
"Author's Note position updated": "Позиция авторских заметок обновлена",
|
||||
"Something went wrong. Could not save character's author's note.": "Что-то пошло не так. Не удалось сохранить авторские заметки для этого персонажа.",
|
||||
"Select a character before trying to use Author's Note": "Сначала необходимо выбрать персонажа",
|
||||
"Author's Note text updated": "Текст заметок автора обновлён",
|
||||
"Author's Note text updated": "Текст авторских заметок обновлён",
|
||||
"Group Validation": "Валидация группы",
|
||||
"Warning: Listed member ${0} does not exist as a character. It will be removed from the group.": "Предупреждение: персонаж ${0} не существует в виде карточки. Он будет удалён из группы.",
|
||||
"Group Chat could not be saved": "Не удалось сохранить групповой чат",
|
||||
@@ -1938,7 +1904,7 @@
|
||||
"Do you want to remove these fields before exporting?": "Желаете ли удалить эти поля перед экспортом?",
|
||||
"Save": "Сохранить",
|
||||
"Chat Lorebook": "Лорбук для чата",
|
||||
"chat_world_template_txt": "Выбранный мир будет привязан к этому чату. Будет добавляться в промпт наряду с глобальным лорбуком и лором персонажа.",
|
||||
"chat_world_template_txt": "Выбранный мир будет привязан к этому чату. Будет работать наряду с глобальным лорбуком и лором персонажа.",
|
||||
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + ЛКМ, чтобы открыть диалог привязки мира",
|
||||
"No auxillary Lorebooks set. Click here to select.": "Вспомогательный лорбук не выбран. Нажмите, чтобы выбрать.",
|
||||
"ext_regex_user_input_desc": "Отправленные вами сообщения.",
|
||||
@@ -2010,7 +1976,7 @@
|
||||
"Imported tags:": "Импортируемые теги:",
|
||||
"Importing Tags": "Импорт тегов",
|
||||
"Couldn't import tags:": "Не удалось импортировать теги:",
|
||||
"Allow fallback models": "Разрешить fallback-модели",
|
||||
"Allow fallback models": "Разрешить резервные модели",
|
||||
"Allow fallback providers": "Разрешить fallback-провайдеров",
|
||||
"To use instruct formatting, switch to OpenRouter under Text Completion API.": "Переключитесь на OpenRouter в Text Completion API, чтобы использовать форматирование Instruct-режима.",
|
||||
"Select providers. No selection = all providers.": "Выберите провайдера. Нет выбранного = выбраны все.",
|
||||
@@ -2028,6 +1994,8 @@
|
||||
"Click on the setting name to omit it from the profile.": "Нажмите на название настройки, чтобы исключить её из профиля",
|
||||
"Included settings:": "Сохранённые параметры:",
|
||||
"Server URL": "Адрес сервера",
|
||||
"Electron Hub API Key": "Ключ от API Electron Hub",
|
||||
"Electron Hub Model": "Модель Electron Hub",
|
||||
"NanoGPT API Key": "Ключ от API NanoGPT",
|
||||
"NanoGPT Model": "Модель NanoGPT",
|
||||
"Use extension settings": "Использовать настройки из расширения",
|
||||
@@ -2044,14 +2012,14 @@
|
||||
"Title/Memo": "Название",
|
||||
"Strategy": "Статус",
|
||||
"Position": "Позиция",
|
||||
"Trigger %": "% срабатывания",
|
||||
"Trigger %": "% срабатываний",
|
||||
"Use global": "Глоб. настройка",
|
||||
"Whole Words": "Целые слова",
|
||||
"Non-recursable": "Не рекурсивная",
|
||||
"Delay until recursion": "Рекурсивная",
|
||||
"Toggle entry's active state.": "Вкл/выкл запись.",
|
||||
"Prioritize": "Важная",
|
||||
"Prioritize this entry: When checked, this entry is prioritized out of all selections.If multiple are prioritized, the one with the highest 'Order' is chosen.": "Важная запись получает приоритет среди всех выбранных. Если важных записей несколько, выбирается та, у которой выше \"Очерёдность\".",
|
||||
"Prioritize this entry: When checked, this entry is prioritized out of all selections.If multiple are prioritized, the one with the highest 'Order' is chosen.": "Важная запись получает приоритет среди всех выбранных. Если важных записей несколько, выбирается та, у которой выше \"Приоритет\".",
|
||||
"Group Weight": "Вес в группе",
|
||||
"A relative likelihood of entry activation within the group": "Относительная вероятность активации записи в рамках группы",
|
||||
"Sticky": "Липучка",
|
||||
@@ -2067,7 +2035,7 @@
|
||||
"Switch to plaintext mode": "Вкл/выкл режим чистого текста",
|
||||
"Exclude": "Режим исключения",
|
||||
"Switch the Character/Tags filter around to exclude the listed characters and tags from matching for this entry": "Инвертировать логику: для выбранных в фильтре персонажей/тегов данная запись активна НЕ БУДЕТ",
|
||||
"Apply current sorting as Order": "Настроить Очерёдность в соответствии с текущей сортировкой",
|
||||
"Apply current sorting as Order": "Настроить Приоритет в соответствии с текущей сортировкой",
|
||||
"Create a new World Info": "Создать новый мир",
|
||||
"Enter a name for the new file:": "Название нового файла:",
|
||||
"Inclusion Groups ensure only one entry from a group is activated at a time, if multiple are triggered.Documentation: World Info - Inclusion Group": "Если сразу несколько записей из одной группы окажутся активированными, по факту сработает только одна. Одна запись может входить в несколько групп, отделяются запятыми. Раздел в документации: World Info - Inclusion Group",
|
||||
@@ -2165,7 +2133,7 @@
|
||||
"openai_reasoning_effort_high": "Подробные",
|
||||
"Persona Lore Alt+Click to open the lorebook": "Лорбук данной персоны\nAlt + ЛКМ чтобы открыть лорбук",
|
||||
"Persona Lorebook for": "Лорбук для персоны",
|
||||
"persona_world_template_txt": "Выбранная Информация о мире будет привязана к этой персоне. Информация будет добавляться в каждом промпте вместе с глобальным лорбуком и лорбуками персонажа и чата.",
|
||||
"persona_world_template_txt": "Выбранный мир будет привязан к этой персоне. Будет работать вместе с глобальным лорбуком и лорбуками персонажа и чата.",
|
||||
"Global list": "Глобальный список",
|
||||
"Preset-specific list": "Список для данного пресета",
|
||||
"Banned tokens/strings are being sent in the request.": "Запрещённые токены и строки отсылаются в запросе.",
|
||||
@@ -2280,7 +2248,7 @@
|
||||
"Character Words": "Слов отправлено персонажем",
|
||||
"stats_header_User": "пользователю",
|
||||
"stats_header_Character": "персонажу",
|
||||
"${0} Stats": "Статистика по ${0}",
|
||||
"${0} Stats": "Статистика по ${0}",
|
||||
"Context": "Контекст",
|
||||
"Response": "Ответ",
|
||||
"Connected": "Подключено",
|
||||
@@ -2521,6 +2489,16 @@
|
||||
"Automatically generated chat backups.": "Автоматически создаваемые бэкапы чатов.",
|
||||
"Settings Backups": "Копии настроек",
|
||||
"Automatically generated settings backups.": "Автоматически создаваемые бэкапы настроек.",
|
||||
"Files": "Файлы",
|
||||
"Files that are not associated with chat messages or Data Bank. WILL DELETE MANUAL UPLOADS!": "Файлы, не связанные ни с одним сообщением или банком данных. ЗАГРУЖЕННЫЕ ВРУЧНУЮ ФАЙЛЫ ТАКЖЕ БУДУТ УДАЛЕНЫ!",
|
||||
"Images": "Изображения",
|
||||
"Images that are not associated with chat messages. WILL DELETE MANUAL UPLOADS!": "Картинки, не связанные ни с одним сообщением. ЗАГРУЖЕННЫЕ ВРУЧНУЮ ФАЙЛЫ ТАКЖЕ БУДУТ УДАЛЕНЫ!",
|
||||
"Avatar Thumbnails": "Превью для аватарок",
|
||||
"Thumbnails for avatars of missing or deleted characters.": "Превью для аватарок удалённых персонажей",
|
||||
"Background Thumbnails": "Превью для фонов",
|
||||
"Thumbnails for missing or deleted backgrounds.": "Превью для удалённых фоновых изображений",
|
||||
"Persona Thumbnails": "Превью для персон",
|
||||
"Thumbnails for missing or deleted personas.": "Превью для удалённых персон",
|
||||
"Delete all items in this category": "Удалить всё в этой категории",
|
||||
"View item content": "Посмотреть содержимое",
|
||||
"Download item": "Скачать содержимое",
|
||||
@@ -2583,5 +2561,96 @@
|
||||
"Moonshot AI API Key": "Ключ от API Moonshot AI",
|
||||
"Moonshot AI Model": "Модель Moonshot AI",
|
||||
"AI/ML API Key": "Ключ от API AI/ML",
|
||||
"AI/ML Model": "Модель AI/ML"
|
||||
"AI/ML Model": "Модель AI/ML",
|
||||
"Replace Character": "Заменить персонажа",
|
||||
"Choose a new character card to replace this character with.": "Выберите, каким персонажем хотите заменить текущего.",
|
||||
"All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.": "Чаты с персонажем, его ассеты и членство в группах сохранятся. Однако сделанные вами изменения в карточке будут утеряны.",
|
||||
"Proceed?": "Продолжить?",
|
||||
"No Creator's Notes provided.": "Создатель не оставил примечаний.",
|
||||
"No auxiliary Lorebooks set. Click here to select.": "Вспомогательных лорбуков нет. ЛКМ, чтобы выбрать.",
|
||||
"Persona Title (optional, display only)": "Сноска (не влияет на чат, только в интерфейсе)",
|
||||
"This entry will not be recursively activated by other entries.": "Не будет активироваться другими записями.",
|
||||
"This entry will not activate other entries recursively.": "Не будет активировать другие записи.",
|
||||
"This entry can only be activated on recursive checking.": "Активируется только другими записями.",
|
||||
"This entry will be included ignoring budget constraints, assuming all other checks pass.": "Будет включена в промпт даже при превышении бюджета токенов (при условии, что все остальные условия соблюдены)",
|
||||
"Ignore budget": "Игнорировать бюджет",
|
||||
"Filter to Generation Triggers": "Только для опред. типов генераций",
|
||||
"Apply current sorting as Order": "Выставить приоритеты по текущей сортировке",
|
||||
"Apply your current sorting to the \"Order\" field. The Order values will go down from the chosen number.": "Заполнить поле \"Приоритет\" в соответствии с текущей сортировкой для всех записей. Поля будут заполнены значениями, начиная с этого числа:",
|
||||
"More than 100 entries in this world. If you don't choose a number higher than that, the lower entries will default to 0.<br />(Usual default: 100)<br />Minimum: ${0}": "В этом лорбуке больше 100 записей! Если не выставить число больше 100, то последние записи будут иметь приоритет 0.<br/>(Стандартное значение: 100)<br/>(Минимальное число: ${0})",
|
||||
"Apply": "Применить",
|
||||
"Apply Current Sorting": "Выставить приоритеты по сортировке",
|
||||
"Delete the entry with UID: ${0}?": "Удалить запись с UID: ${0}?",
|
||||
"This action is irreversible!": "Отменить будет невозможно!",
|
||||
"Recursion Level": "Уровень рекурсии",
|
||||
"delay_until_recursion_level": "Насколько глубоко должна зайти рекурсия, чтобы иметь возможность активировать эту запись.\n\nИзначально рекурсия делает проход по 1 уровню. Если там не находится подходящих записей, то она идёт на 2 уровень, и там повторяет процесс.\nИ так, пока не дойдёт до самого глубокого уровня.\n\nАктуально только для рекурсивных записей (с отмеченной галочкой \"Рекурсивная\").",
|
||||
"A number lower than the entry count has been chosen. All entries below that will default to 0.": "Введённое число меньше, чем общее кол-во записей. Всем записям внизу списка присвоен приоритет 0.",
|
||||
"Invalid number: ${0}": "Некорректное число: ${0}",
|
||||
"Allow animations for WEBP backgrounds. This is only a change for the selection menu.": "Разрешить анимации в WEBP фонах. Актуально только для меню выбора.",
|
||||
"sd_refine_mode_txt": "Редактировать промпты перед генерацией",
|
||||
"sd_refine_mode": "Отправлять промпты на проверку вам, прежде чем пересылать в API",
|
||||
"sd_function_tool_txt": "Использовать вызов функций",
|
||||
"sd_function_tool": "Использовать функцию, чтобы понимать, когда пора генерировать изображение",
|
||||
"sd_interactive_mode_txt": "Интерактивный режим",
|
||||
"sd_interactive_mode": "Автоматически генерировать изображения, когда появляется сообщение вида \"send me a picture of a cat\"",
|
||||
"sd_multimodal_captioning_txt": "Мультимодальный промптинг",
|
||||
"sd_multimodal_captioning": "Использовать мультимодальный промптинг для создания портретов пользователя и персонажа, основываясь на их аватарках",
|
||||
"sd_free_extend_txt": "Дописывать промпты в свободном режиме",
|
||||
"sd_free_extend_small": "(для интерактивного режима или команд)",
|
||||
"sd_free_extend": "Автоматически дописывать промпты в свободном режиме (для всего, что не касается фонов и портретов), используя текущую выбранную LLM",
|
||||
"sd_snap_txt": "Корректировать автоматически выбранное разрешение",
|
||||
"sd_snap": "Подгонять картинки с фиксированным соотношением сторон (фоны, портреты) к ближайшему известному разрешению (рекомендуется для SDXL)",
|
||||
"Source": "API",
|
||||
"Hint: Save an API key in AI Horde API settings to use it here.": "Подсказка: сохраните ключ от API в настройках API на сайте AI Horde, чтобы использовать его автоматически.",
|
||||
"Sanitize prompts (recommended)": "Прогонять промпты через санитайзер (рекомендуется)",
|
||||
"Sampling method": "Метод сэмплинга",
|
||||
"Resolution": "Целевое разрешение",
|
||||
"Sampling steps": "Кол-во шагов",
|
||||
"Width": "Ширина",
|
||||
"Height": "Высота",
|
||||
"Not all samplers supported.": "Поддерживает не все виды сэмплинга.",
|
||||
"(-1 for random)": "(-1 для случайного)",
|
||||
"Common prompt prefix": "Фиксированный префикс для промптов",
|
||||
"Preset for prompt prefix and negative prompt": "Пресет для префиксов промпта и для негативных промптов",
|
||||
"Style": "Стиль",
|
||||
"Negative common prompt prefix": "Фиксированный префикс для негативных промптов",
|
||||
"Chat Message Visibility (by source)": "Видимость сообщений в чате (по источникам)",
|
||||
"Uncheck to hide the extension's messages in chat prompts.": "Снимите галочку, чтобы скрыть из промптов сообщения, приходящие из этого источника.",
|
||||
"Extensions Menu": "Меню расширений",
|
||||
"Slash Command": "Слэш-команды",
|
||||
"Interactive Mode": "Интерактивный режим",
|
||||
"Function Tool": "Функция",
|
||||
"Save style": "Сохранить стиль",
|
||||
"Delete style": "Удалить стиль",
|
||||
"Are you sure you want to delete the style \"${0}\"?": "Вы точно хотите удалить стиль \"${0}\"?",
|
||||
"API Key": "Ключ от API",
|
||||
"These settings only apply to DALL-E 3": "Данные настройки применяются только для DALL-E 3",
|
||||
"Image Style": "Стиль изображения",
|
||||
"Image Quality": "Качество изображения",
|
||||
"Standard": "Стандарт",
|
||||
"sd_res_512x512": "512x512 (1:1, иконки, аватарки)",
|
||||
"sd_res_600x600": "600x600(1:1, иконки, аватарки)",
|
||||
"sd_res_512x768": "512x768 (2:3, вертикальная аватарка для карточки)",
|
||||
"sd_res_768x512": "768x512 (3:2, 35мм плёнка для кинофильмов, альбомн. ориентация)",
|
||||
"sd_res_960x540": "960x540 (16:9, обои, альбомн. ориентация)",
|
||||
"sd_res_540x960": "540x960 (9:16, обои, книжн. ориентация)",
|
||||
"sd_res_1920x1088": "1920x1088 (16:9, обои, альбомн. ориентация)",
|
||||
"sd_res_1088x1920": "1088x1920 (9:16, обои, книжн. ориентация)",
|
||||
"sd_res_1280x720": "1280x720 (16:9, обои, альбомн. ориентация)",
|
||||
"sd_res_720x1280": "720x1280 (9:16, обои, книжн. ориентация)",
|
||||
"Click to set": "Нажмите чтобы задать",
|
||||
"Prompt Upsampling": "Применять Prompt Upsampling",
|
||||
"Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation.": "При активации автоматически модифицирует промпт, чтобы сделать процесс генерации более креативным.",
|
||||
"Important:": "Важно:",
|
||||
"The server must be accessible from the SillyTavern host machine.": " Адрес должен быть доступен с сервера SillyTavern.",
|
||||
"Open workflow editor": "Открыть редактор воркфлоу",
|
||||
"Create new workflow": "Создать новый воркфлоу",
|
||||
"Delete workflow": "Удалить воркфлоу",
|
||||
"Delete the workflow? This action is irreversible.": "Удалить этот воркфлоу? Отменить будет невозможно.",
|
||||
"Swap width and height": "Поменять местами ширину и высоту",
|
||||
"Authentication (optional)": "Данные для аутентификации (необязательно)",
|
||||
"sd_auto_auth_warning_1": " запускайте Stable Diffusion с флагом",
|
||||
"sd_auto_auth_warning_2": "! Адрес SD должен быть доступен с сервера SillyTavern.",
|
||||
"Upscale by": "Множитель апскейлинга",
|
||||
"Hires steps (2nd pass)": "Кол-во шагов Hires (на втором проходе)"
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -317,6 +317,8 @@
|
||||
"flag": "прапорцем",
|
||||
"API key (optional)": "Ключ API (необов'язково)",
|
||||
"Server url": "URL-адреса сервера",
|
||||
"Electron Hub API Key": "Ключ API для Electron Hub",
|
||||
"Electron Hub Model": "Модель Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "Приклад: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Власна модель (необов'язково)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (режим оболонки OpenAI API)",
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
"flag": "cờ",
|
||||
"API key (optional)": "Key API (tùy chọn)",
|
||||
"Server url": "URL máy chủ",
|
||||
"Electron Hub API Key": "Key API Electron Hub",
|
||||
"Electron Hub Model": "Model Electron Hub",
|
||||
"Example: http://127.0.0.1:5000": "Ví dụ: http://127.0.0.1:5000",
|
||||
"Custom model (optional)": "Model tùy chỉnh (tùy chọn)",
|
||||
"vllm-project/vllm": "vllm-project/vllm (Chế độ trình bao bọc API OpenAI)",
|
||||
|
||||
+379
-183
File diff suppressed because it is too large
Load Diff
@@ -1791,6 +1791,8 @@
|
||||
"Derive context size from backend": "從後端推導上下文大小",
|
||||
"Using a proxy that you're not running yourself is a risk to your data privacy.": "使用非自行管理的代理服務可能導致您的資料隱私外洩。",
|
||||
"Claude API Key": "Claude API 金鑰",
|
||||
"Electron Hub API Key": "Electron Hub API 金鑰",
|
||||
"Electron Hub Model": "Electron Hub 模型",
|
||||
"NanoGPT API Key": "NanoGPT API 金鑰",
|
||||
"NanoGPT Model": "NanoGPT 模型",
|
||||
"context_derived": "若可能,根據模型後設資料推導。",
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@
|
||||
</div>
|
||||
|
||||
<script src="lib/jquery-3.5.1.min.js"></script>
|
||||
<script src="scripts/login.js"></script>
|
||||
<script src="scripts/login.js" type="module"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
+12
-2
@@ -266,6 +266,7 @@ import { initDataMaid } from './scripts/data-maid.js';
|
||||
import { clearItemizedPrompts, deleteItemizedPrompts, findItemizedPromptSet, initItemizedPrompts, itemizedParams, itemizedPrompts, loadItemizedPrompts, promptItemize, replaceItemizedPromptText, saveItemizedPrompts } from './scripts/itemized-prompts.js';
|
||||
import { getSystemMessageByType, initSystemMessages, SAFETY_CHAT, sendSystemMessage, system_message_types, system_messages } from './scripts/system-messages.js';
|
||||
import { event_types, eventSource } from './scripts/events.js';
|
||||
import { initAccessibility } from './scripts/a11y.js';
|
||||
|
||||
// API OBJECT FOR EXTERNAL WIRING
|
||||
globalThis.SillyTavern = {
|
||||
@@ -687,6 +688,7 @@ async function firstLoadInit() {
|
||||
initCustomSelectedSamplers();
|
||||
initDataMaid();
|
||||
initItemizedPrompts();
|
||||
initAccessibility();
|
||||
addDebugFunctions();
|
||||
doDailyExtensionUpdatesCheck();
|
||||
await hideLoader();
|
||||
@@ -5237,7 +5239,13 @@ function extractImageFromData(data, { mainApi = null, chatCompletionSource = nul
|
||||
return `data:${inlineData.mimeType};base64,${inlineData.data}`;
|
||||
}
|
||||
} break;
|
||||
|
||||
case chat_completion_sources.OPENROUTER: {
|
||||
const imageUrl = data?.choices[0]?.message?.images?.find(x => x.type === 'image_url')?.image_url?.url;
|
||||
if (isDataURL(imageUrl)) {
|
||||
return imageUrl;
|
||||
}
|
||||
// TODO: Handle remote URLs
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
@@ -5361,6 +5369,8 @@ export function extractJsonFromData(data, { mainApi = null, chatCompletionSource
|
||||
case chat_completion_sources.CUSTOM:
|
||||
case chat_completion_sources.COHERE:
|
||||
case chat_completion_sources.XAI:
|
||||
case chat_completion_sources.ELECTRONHUB:
|
||||
case chat_completion_sources.AZURE_OPENAI:
|
||||
default:
|
||||
result = tryParse(text);
|
||||
break;
|
||||
@@ -10808,7 +10818,7 @@ jQuery(async function () {
|
||||
}
|
||||
} break;
|
||||
case 'replace_update': {
|
||||
const confirm = await Popup.show.confirm('Replace Character', '<p>Choose a new character card to replace this character with.</p>All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.<br />Proceed?');
|
||||
const confirm = await Popup.show.confirm(t`Replace Character`, '<p>' + t`Choose a new character card to replace this character with.` + '</p>' + t`All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.` + '<br />' + t`Proceed?`);
|
||||
if (confirm) {
|
||||
async function uploadReplacementCard(e) {
|
||||
const file = e.target.files[0];
|
||||
|
||||
@@ -402,6 +402,7 @@ function RA_autoconnect(PrevApi) {
|
||||
|| (secret_state[SECRET_KEYS.COHERE] && oai_settings.chat_completion_source == chat_completion_sources.COHERE)
|
||||
|| (secret_state[SECRET_KEYS.PERPLEXITY] && oai_settings.chat_completion_source == chat_completion_sources.PERPLEXITY)
|
||||
|| (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ)
|
||||
|| (secret_state[SECRET_KEYS.ELECTRONHUB] && oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB)
|
||||
|| (secret_state[SECRET_KEYS.NANOGPT] && oai_settings.chat_completion_source == chat_completion_sources.NANOGPT)
|
||||
|| (secret_state[SECRET_KEYS.DEEPSEEK] && oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK)
|
||||
|| (secret_state[SECRET_KEYS.XAI] && oai_settings.chat_completion_source == chat_completion_sources.XAI)
|
||||
@@ -411,6 +412,7 @@ function RA_autoconnect(PrevApi) {
|
||||
|| (secret_state[SECRET_KEYS.COMETAPI] && oai_settings.chat_completion_source == chat_completion_sources.COMETAPI)
|
||||
|| (oai_settings.chat_completion_source === chat_completion_sources.POLLINATIONS)
|
||||
|| (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM)
|
||||
|| (secret_state[SECRET_KEYS.AZURE_OPENAI] && oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI)
|
||||
) {
|
||||
$('#api_button_openai').trigger('click');
|
||||
}
|
||||
@@ -480,8 +482,7 @@ export function dragElement($elmnt) {
|
||||
|
||||
let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
||||
let height, width, top, left, right, bottom,
|
||||
maxX, maxY, winHeight, winWidth,
|
||||
topbar;
|
||||
maxX, maxY, winHeight, winWidth;
|
||||
|
||||
const elmntName = $elmnt.attr('id');
|
||||
const elmntNameEscaped = $.escapeSelector(elmntName);
|
||||
@@ -540,11 +541,6 @@ export function dragElement($elmnt) {
|
||||
winWidth = window.innerWidth;
|
||||
winHeight = window.innerHeight;
|
||||
|
||||
topbar = document.getElementById('top-bar');
|
||||
const topbarstyle = getComputedStyle(topbar);
|
||||
topBarFirstX = parseInt(topbarstyle.marginInline);
|
||||
topBarLastY = parseInt(topbarstyle.height);
|
||||
|
||||
// Prepare state object if missing
|
||||
if (!power_user.movingUIState[elmntName]) power_user.movingUIState[elmntName] = {};
|
||||
|
||||
@@ -1066,6 +1062,19 @@ export function initRossMods() {
|
||||
$('#option_regenerate').trigger('click');
|
||||
$('#options').hide();
|
||||
}
|
||||
|
||||
// If there is input text, we do not trigger a regenerate - we just send it
|
||||
if ($('#send_textarea').val() !== '') {
|
||||
if (shouldSendOnEnter()) {
|
||||
console.debug('Sending with Ctrl+Enter');
|
||||
event.preventDefault();
|
||||
sendTextareaMessage();
|
||||
} else {
|
||||
console.debug('Text area is not empty, but send on enter is disabled');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (skipConfirm) {
|
||||
doRegenerate();
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* Shared module between login and main app.
|
||||
* Be careful what you import!
|
||||
*/
|
||||
|
||||
const buttonSelectors = [
|
||||
'.menu_button',
|
||||
'.right_menu_button',
|
||||
'.mes_button',
|
||||
'.drawer-icon',
|
||||
'.inline-drawer-icon',
|
||||
'.swipe_left',
|
||||
'.swipe_right',
|
||||
'.character_select',
|
||||
'.tags .tag',
|
||||
'.jg-menu .jg-button',
|
||||
'.bg_example .mobile-only-menu-toggle',
|
||||
'.paginationjs-pages li a',
|
||||
].join(', ');
|
||||
|
||||
const listSelectors = [
|
||||
'.options-content',
|
||||
'.list-group',
|
||||
'#rm_print_characters_block',
|
||||
'#rm_group_members',
|
||||
'#rm_group_add_members',
|
||||
'.tag_view_list_tags',
|
||||
'.secretKeyManagerList',
|
||||
'.recentChatList',
|
||||
'.dataMaidCategoryContent',
|
||||
'#userList',
|
||||
'.bg_list',
|
||||
].join(', ');
|
||||
|
||||
const listItemSelectors = [
|
||||
'.options-content .list-group-item',
|
||||
'.list-group .list-group-item',
|
||||
'#rm_print_characters_block .entity_block',
|
||||
'#rm_group_members .group_member',
|
||||
'#rm_group_add_members .group_member',
|
||||
'.tag_view_list_tags .tag_view_item',
|
||||
'.secretKeyManagerList .secretKeyManagerItem',
|
||||
'.recentChatList .recentChat',
|
||||
'.dataMaidCategoryContent .dataMaidItem',
|
||||
'#userList .userSelect',
|
||||
'.bg_list .bg_example',
|
||||
].join(', ');
|
||||
|
||||
const toolbarSelectors = [
|
||||
'.jg-menu',
|
||||
].join(', ');
|
||||
|
||||
/** @type {Record<string, (element: Element) => void>} */
|
||||
const a11yRules = {
|
||||
[buttonSelectors]: (element) => {
|
||||
element.setAttribute('role', 'button');
|
||||
},
|
||||
[listSelectors]: (element) => {
|
||||
element.setAttribute('role', 'list');
|
||||
},
|
||||
[listItemSelectors]: (element) => {
|
||||
element.setAttribute('role', 'listitem');
|
||||
},
|
||||
[toolbarSelectors]: (element) => {
|
||||
element.setAttribute('role', 'toolbar');
|
||||
},
|
||||
'#toast-container .toast': (element) => {
|
||||
element.setAttribute('role', 'status');
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply accessibility rules to an element.
|
||||
* @param {Element} element Element to process.
|
||||
*/
|
||||
function applyA11yRules(element) {
|
||||
try {
|
||||
for (const [selector, rule] of Object.entries(a11yRules)) {
|
||||
// Apply if the element directly matches the selector
|
||||
if (element.matches(selector)) {
|
||||
rule(element);
|
||||
}
|
||||
// Apply the rule to descendants
|
||||
element.querySelectorAll(selector).forEach(rule);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error applying accessibility rules to element:', element, error);
|
||||
}
|
||||
}
|
||||
|
||||
function setAccessibilityObserver() {
|
||||
// Apply for existing elements
|
||||
applyA11yRules(document.body);
|
||||
|
||||
// Setup observer for dynamic content
|
||||
const observer = new MutationObserver((mutationsList) => {
|
||||
for (const mutation of mutationsList) {
|
||||
if (mutation.type === 'childList') {
|
||||
for (const addedNode of mutation.addedNodes) {
|
||||
if (addedNode instanceof Element && addedNode.nodeType === Node.ELEMENT_NODE) {
|
||||
applyA11yRules(addedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
|
||||
export function initAccessibility() {
|
||||
setAccessibilityObserver();
|
||||
}
|
||||
@@ -265,9 +265,10 @@ async function onCopyToSystemBackgroundClick(e) {
|
||||
* It caches the thumbnail in local storage and returns a blob URL for the thumbnail.
|
||||
* If the thumbnail cannot be fetched, it returns a transparent PNG pixel as a fallback.
|
||||
* @param {string} bg Background URL
|
||||
* @param {boolean} isCustom Is the background custom?
|
||||
* @returns {Promise<string>} Blob URL of the thumbnail
|
||||
*/
|
||||
async function getThumbnailFromStorage(bg) {
|
||||
async function getThumbnailFromStorage(bg, isCustom) {
|
||||
const cachedBlobUrl = THUMBNAIL_BLOBS.get(bg);
|
||||
if (cachedBlobUrl) {
|
||||
return cachedBlobUrl;
|
||||
@@ -281,7 +282,8 @@ async function getThumbnailFromStorage(bg) {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(getBackgroundPath(bg), { cache: 'force-cache' });
|
||||
const url = isCustom ? bg : getBackgroundPath(bg);
|
||||
const response = await fetch(url, { cache: 'force-cache' });
|
||||
if (!response.ok) {
|
||||
throw new Error('Fetch failed with status: ' + response.status);
|
||||
}
|
||||
@@ -519,7 +521,7 @@ async function resolveImageUrl(bg, isCustom) {
|
||||
const fileExtension = bg.split('.').pop().toLowerCase();
|
||||
const isAnimated = ['mp4', 'webp'].includes(fileExtension);
|
||||
const thumbnailUrl = isAnimated && !background_settings.animation
|
||||
? await getThumbnailFromStorage(bg)
|
||||
? await getThumbnailFromStorage(bg, isCustom)
|
||||
: isCustom
|
||||
? bg
|
||||
: getThumbnailUrl('bg', bg);
|
||||
@@ -573,14 +575,21 @@ async function delBackground(bg) {
|
||||
}
|
||||
|
||||
async function onBackgroundUploadSelected() {
|
||||
const form = $('#form_bg_download').get(0);
|
||||
const form = $('#form_bg_upload').get(0);
|
||||
|
||||
if (!(form instanceof HTMLFormElement)) {
|
||||
console.error('form_bg_download is not a form');
|
||||
console.error('form_bg_upload is not a form');
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
const file = formData.get('avatar');
|
||||
if (!(file instanceof File) || file.size === 0) {
|
||||
form.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
await convertFileIfVideo(formData);
|
||||
await uploadBackground(formData);
|
||||
form.reset();
|
||||
@@ -614,7 +623,7 @@ async function convertFileIfVideo(formData) {
|
||||
const sourceBuffer = await file.arrayBuffer();
|
||||
const convertedBuffer = await globalThis.convertVideoToAnimatedWebp({ buffer: new Uint8Array(sourceBuffer), name: file.name });
|
||||
const convertedFileName = file.name.replace(/\.[^/.]+$/, '.webp');
|
||||
const convertedFile = new File([convertedBuffer], convertedFileName, { type: 'image/webp' });
|
||||
const convertedFile = new File([new Uint8Array(convertedBuffer)], convertedFileName, { type: 'image/webp' });
|
||||
formData.set('avatar', convertedFile);
|
||||
toastMessage.remove();
|
||||
} catch (error) {
|
||||
@@ -693,12 +702,42 @@ function onBackgroundFilterInput() {
|
||||
export function initBackgrounds() {
|
||||
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
|
||||
eventSource.on(event_types.FORCE_SET_BACKGROUND, forceSetBackground);
|
||||
$(document).on('click', '.bg_example', onSelectBackgroundClick);
|
||||
$(document).on('click', '.bg_example_lock', onLockBackgroundClick);
|
||||
$(document).on('click', '.bg_example_unlock', onUnlockBackgroundClick);
|
||||
$(document).on('click', '.bg_example_edit', onRenameBackgroundClick);
|
||||
$(document).on('click', '.bg_example_cross', onDeleteBackgroundClick);
|
||||
$(document).on('click', '.bg_example_copy', onCopyToSystemBackgroundClick);
|
||||
|
||||
$(document)
|
||||
.off('click', '.bg_example').on('click', '.bg_example', onSelectBackgroundClick)
|
||||
.off('click', '.bg_example .mobile-only-menu-toggle').on('click', '.bg_example .mobile-only-menu-toggle', function (e) {
|
||||
e.stopPropagation();
|
||||
const $context = $(this).closest('.bg_example');
|
||||
const wasOpen = $context.hasClass('mobile-menu-open');
|
||||
// Close all other open menus before opening a new one.
|
||||
$('.bg_example.mobile-menu-open').removeClass('mobile-menu-open');
|
||||
if (!wasOpen) {
|
||||
$context.addClass('mobile-menu-open');
|
||||
}
|
||||
})
|
||||
.off('click', '.jg-button').on('click', '.jg-button', function (e) {
|
||||
e.stopPropagation();
|
||||
const action = $(this).data('action');
|
||||
|
||||
switch (action) {
|
||||
case 'lock':
|
||||
onLockBackgroundClick.call(this, e.originalEvent);
|
||||
break;
|
||||
case 'unlock':
|
||||
onUnlockBackgroundClick.call(this, e.originalEvent);
|
||||
break;
|
||||
case 'edit':
|
||||
onRenameBackgroundClick.call(this, e.originalEvent);
|
||||
break;
|
||||
case 'delete':
|
||||
onDeleteBackgroundClick.call(this, e.originalEvent);
|
||||
break;
|
||||
case 'copy':
|
||||
onCopyToSystemBackgroundClick.call(this, e.originalEvent);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$('#auto_background').on('click', autoBackgroundCommand);
|
||||
$('#add_bg_button').on('change', onBackgroundUploadSelected);
|
||||
$('#bg-filter').on('input', onBackgroundFilterInput);
|
||||
|
||||
+28
-1
@@ -1758,7 +1758,34 @@ export function addDOMPurifyHooks() {
|
||||
|
||||
// Replace line breaks with <br> in unknown elements
|
||||
if (node instanceof HTMLUnknownElement) {
|
||||
node.innerHTML = node.innerHTML.trim().replaceAll('\n', '<br>');
|
||||
node.innerHTML = node.innerHTML.trim();
|
||||
|
||||
/** @type {Text[]} */
|
||||
const candidates = [];
|
||||
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
||||
while (walker.nextNode()) {
|
||||
const textNode = /** @type {Text} */ (walker.currentNode);
|
||||
if (!textNode.data.includes('\n')) continue;
|
||||
|
||||
// Skip if this text node is within a <pre> (any ancestor)
|
||||
if (textNode.parentElement && textNode.parentElement.closest('pre')) continue;
|
||||
|
||||
candidates.push(textNode);
|
||||
}
|
||||
|
||||
for (const textNode of candidates) {
|
||||
const parts = textNode.data.split('\n');
|
||||
const frag = document.createDocumentFragment();
|
||||
parts.forEach((part, idx) => {
|
||||
if (part.length) {
|
||||
frag.appendChild(document.createTextNode(part));
|
||||
}
|
||||
if (idx < parts.length - 1) {
|
||||
frag.appendChild(document.createElement('br'));
|
||||
}
|
||||
});
|
||||
textNode.replaceWith(frag);
|
||||
}
|
||||
}
|
||||
|
||||
const isMediaAllowed = isExternalMediaAllowed();
|
||||
|
||||
@@ -33,22 +33,37 @@ const observer = new MutationObserver(mutations => {
|
||||
* @param {boolean} [options.fromExtension=false] - Indicates if the styles are from an extension
|
||||
*/
|
||||
function applyDynamicFocusStyles(styleSheet, { fromExtension = false } = {}) {
|
||||
/** @type {{baseSelector: string, rule: CSSStyleRule}[]} */
|
||||
/** @typedef {{ type: 'media'|'supports'|'container', conditionText: string }} WrapperCond */
|
||||
/** @type {{baseSelector: string, rule: CSSStyleRule, wrappers: WrapperCond[]}[]} */
|
||||
const hoverRules = [];
|
||||
/** @type {Set<string>} */
|
||||
const focusRules = new Set();
|
||||
|
||||
const PLACEHOLDER = ':__PLACEHOLDER__';
|
||||
|
||||
/**
|
||||
* Builds a stable signature string for a chain of wrapper conditions so we can distinguish
|
||||
* identical selectors under different contexts (e.g., different @media queries)
|
||||
* @param {WrapperCond[]} wrappers
|
||||
* @returns {string}
|
||||
*/
|
||||
function wrapperSignature(wrappers) {
|
||||
return wrappers.map(w => `${w.type}:${w.conditionText}`).join(';');
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the CSS rules and separates selectors for hover and focus
|
||||
* @param {CSSRuleList} rules - The CSS rules to process
|
||||
* @param {WrapperCond[]} wrappers - Current chain of wrapper conditions (@media/@supports/etc.)
|
||||
*/
|
||||
function processRules(rules) {
|
||||
function processRules(rules, wrappers = []) {
|
||||
Array.from(rules).forEach(rule => {
|
||||
if (rule instanceof CSSImportRule) {
|
||||
// Make sure that @import rules are processed recursively
|
||||
processImportedStylesheet(rule.styleSheet);
|
||||
// If the @import has media conditions, treat them as wrappers as well
|
||||
/** @type {WrapperCond[]} */
|
||||
const extra = (rule.media && rule.media.mediaText) ? [{ type: 'media', conditionText: rule.media.mediaText }] : [];
|
||||
processImportedStylesheet(rule.styleSheet, [...wrappers, ...extra]);
|
||||
} else if (rule instanceof CSSStyleRule) {
|
||||
// Separate multiple selectors on a rule
|
||||
const selectors = rule.selectorText.split(',').map(s => s.trim());
|
||||
@@ -60,17 +75,25 @@ function applyDynamicFocusStyles(styleSheet, { fromExtension = false } = {}) {
|
||||
// We currently do nothing here. Rules containing both hover and focus are very specific and should never be automatically touched
|
||||
}
|
||||
else if (isHover) {
|
||||
const baseSelector = selector.replace(':hover', PLACEHOLDER).trim();
|
||||
hoverRules.push({ baseSelector, rule });
|
||||
const baseSelector = selector.replace(/:hover/g, PLACEHOLDER).trim();
|
||||
hoverRules.push({ baseSelector, rule, wrappers: [...wrappers] });
|
||||
} else if (isFocus) {
|
||||
// We need to make sure that we remember all existing :focus, :focus-within and :focus-visible rules
|
||||
const baseSelector = selector.replace(':focus-within', PLACEHOLDER).replace(':focus-visible', PLACEHOLDER).replace(':focus', PLACEHOLDER).trim();
|
||||
focusRules.add(baseSelector);
|
||||
const baseSelector = selector.replace(/:focus(-within|-visible)?/g, PLACEHOLDER).trim();
|
||||
focusRules.add(`${baseSelector}|${wrapperSignature(wrappers)}`);
|
||||
}
|
||||
});
|
||||
} else if (rule instanceof CSSMediaRule || rule instanceof CSSSupportsRule) {
|
||||
// Recursively process nested rules
|
||||
processRules(rule.cssRules);
|
||||
} else if (rule instanceof CSSMediaRule) {
|
||||
// Recursively process nested @media rules
|
||||
processRules(rule.cssRules, [...wrappers, { type: 'media', conditionText: rule.conditionText }]);
|
||||
} else if (rule instanceof CSSSupportsRule) {
|
||||
// Recursively process nested @supports rules
|
||||
processRules(rule.cssRules, [...wrappers, { type: 'supports', conditionText: rule.conditionText }]);
|
||||
} else if (rule instanceof window.CSSContainerRule) {
|
||||
// Recursively process nested @container rules (if supported by the browser)
|
||||
// Note: conditionText contains the query like "(min-width: 300px)" or "style(color)"
|
||||
// Using 'container' as the type ensures uniqueness separate from @media/@supports
|
||||
processRules(rule.cssRules, [...wrappers, { type: 'container', conditionText: rule.conditionText }]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -78,21 +101,22 @@ function applyDynamicFocusStyles(styleSheet, { fromExtension = false } = {}) {
|
||||
/**
|
||||
* Processes the CSS rules of an imported stylesheet recursively
|
||||
* @param {CSSStyleSheet} sheet - The imported stylesheet to process
|
||||
* @param {WrapperCond[]} wrappers - Wrapper conditions inherited from (at)import media
|
||||
*/
|
||||
function processImportedStylesheet(sheet) {
|
||||
function processImportedStylesheet(sheet, wrappers = []) {
|
||||
if (sheet && sheet.cssRules) {
|
||||
processRules(sheet.cssRules);
|
||||
processRules(sheet.cssRules, wrappers);
|
||||
}
|
||||
}
|
||||
|
||||
processRules(styleSheet.cssRules);
|
||||
processRules(styleSheet.cssRules, []);
|
||||
|
||||
/** @type {CSSStyleSheet} */
|
||||
let targetStyleSheet = null;
|
||||
|
||||
// Now finally create the dynamic focus rules
|
||||
hoverRules.forEach(({ baseSelector, rule }) => {
|
||||
if (!focusRules.has(baseSelector)) {
|
||||
hoverRules.forEach(({ baseSelector, rule, wrappers }) => {
|
||||
if (!focusRules.has(`${baseSelector}|${wrapperSignature(wrappers)}`)) {
|
||||
// Only initialize the dynamic stylesheet if needed
|
||||
targetStyleSheet ??= getDynamicStyleSheet({ fromExtension });
|
||||
|
||||
@@ -103,7 +127,19 @@ function applyDynamicFocusStyles(styleSheet, { fromExtension = false } = {}) {
|
||||
// If something like :focus-within or a more specific selector like `.blah:has(:focus-visible)` for elements inside,
|
||||
// it should be manually defined in CSS.
|
||||
const focusSelector = rule.selectorText.replace(/:hover/g, ':focus-visible');
|
||||
const focusRule = `${focusSelector} { ${rule.style.cssText} }`;
|
||||
let focusRule = `${focusSelector} { ${rule.style.cssText} }`;
|
||||
|
||||
// Wrap the generated rule into the same @media/@supports/@container chain (if any)
|
||||
if (wrappers.length > 0) {
|
||||
// Build nested blocks from outermost to innermost
|
||||
// Example: @media (x) { @supports (y) { <rule> } }
|
||||
focusRule = wrappers.reduceRight((inner, w) => {
|
||||
if (w.type === 'media') return `@media ${w.conditionText} { ${inner} }`;
|
||||
if (w.type === 'supports') return `@supports ${w.conditionText} { ${inner} }`;
|
||||
if (w.type === 'container') return `@container ${w.conditionText} { ${inner} }`;
|
||||
return inner;
|
||||
}, focusRule);
|
||||
}
|
||||
|
||||
try {
|
||||
targetStyleSheet.insertRule(focusRule, targetStyleSheet.cssRules.length);
|
||||
|
||||
@@ -188,6 +188,8 @@ export const extension_settings = {
|
||||
dice: {},
|
||||
/** @type {import('./char-data.js').RegexScriptData[]} */
|
||||
regex: [],
|
||||
/** @type {import('./extensions/regex/index.js').RegexPreset[]} */
|
||||
regex_presets: [],
|
||||
character_allowed_regex: [],
|
||||
tts: {},
|
||||
sd: {
|
||||
|
||||
@@ -439,6 +439,8 @@ jQuery(async function () {
|
||||
'cohere': SECRET_KEYS.COHERE,
|
||||
'aimlapi': SECRET_KEYS.AIMLAPI,
|
||||
'moonshot': SECRET_KEYS.MOONSHOT,
|
||||
'nanogpt': SECRET_KEYS.NANOGPT,
|
||||
'electronhub': SECRET_KEYS.ELECTRONHUB,
|
||||
};
|
||||
|
||||
if (chatCompletionApis[api] && secret_state[chatCompletionApis[api]]) {
|
||||
@@ -543,8 +545,10 @@ jQuery(async function () {
|
||||
}
|
||||
|
||||
await processEndpoint('openrouter', '/api/openrouter/models/multimodal');
|
||||
await processEndpoint('aimlapi', '/api/backends/chat-completions/aimlapi/models/multimodal');
|
||||
await processEndpoint('pollinations', '/api/backends/chat-completions/pollinations/models/multimodal');
|
||||
await processEndpoint('aimlapi', '/api/backends/chat-completions/multimodal-models/aimlapi');
|
||||
await processEndpoint('pollinations', '/api/backends/chat-completions/multimodal-models/pollinations');
|
||||
await processEndpoint('nanogpt', '/api/backends/chat-completions/multimodal-models/nanogpt');
|
||||
await processEndpoint('electronhub', '/api/backends/chat-completions/multimodal-models/electronhub');
|
||||
}
|
||||
|
||||
await addSettings();
|
||||
@@ -588,10 +592,12 @@ jQuery(async function () {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#caption_ollama_pull').on('click', (e) => {
|
||||
const presetModel = extension_settings.caption.multimodal_model !== 'ollama_current' ? extension_settings.caption.multimodal_model : '';
|
||||
const selectedModel = extension_settings.caption.multimodal_model;
|
||||
const staticModels = { 'ollama_current': textgenerationwebui_settings.ollama_model, 'ollama_custom': extension_settings.caption.ollama_custom_model };
|
||||
const presetModel = staticModels[selectedModel] || selectedModel;
|
||||
e.preventDefault();
|
||||
$('#ollama_download_model').trigger('click');
|
||||
$('#dialogue_popup_input').val(presetModel);
|
||||
$('.popup .popup-input').val(presetModel);
|
||||
});
|
||||
$('#caption_multimodal_api').on('change', async () => {
|
||||
const api = String($('#caption_multimodal_api').val());
|
||||
@@ -616,6 +622,10 @@ jQuery(async function () {
|
||||
extension_settings.caption.show_in_chat = !!$('#caption_show_in_chat').prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#caption_ollama_custom_model').val(extension_settings.caption.ollama_custom_model || '').on('input', () => {
|
||||
extension_settings.caption.ollama_custom_model = String($('#caption_ollama_custom_model').val()).trim();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
const onMessageEvent = async (index) => {
|
||||
if (!extension_settings.caption.auto_mode) {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<option value="anthropic">Anthropic</option>
|
||||
<option value="cohere">Cohere</option>
|
||||
<option value="custom" data-i18n="Custom (OpenAI-compatible)">Custom (OpenAI-compatible)</option>
|
||||
<option value="electronhub">Electron Hub</option>
|
||||
<option value="google">Google AI Studio</option>
|
||||
<option value="vertexai">Google Vertex AI</option>
|
||||
<option value="groq">Groq</option>
|
||||
@@ -28,6 +29,7 @@
|
||||
<option value="llamacpp">llama.cpp</option>
|
||||
<option value="mistral">MistralAI</option>
|
||||
<option value="moonshot">Moonshot AI</option>
|
||||
<option value="nanogpt">NanoGPT</option>
|
||||
<option value="ollama">Ollama</option>
|
||||
<option value="openai">OpenAI</option>
|
||||
<option value="openrouter">OpenRouter</option>
|
||||
@@ -40,7 +42,7 @@
|
||||
<div class="flex1 flex-container flexFlowColumn flexNoGap">
|
||||
<label for="caption_multimodal_model" data-i18n="Model">Model</label>
|
||||
<select id="caption_multimodal_model" class="flex1 text_pole">
|
||||
<!-- AI/ML API, OpenRouter, Pollinations are added externally by JavaScript -->
|
||||
<!-- AI/ML API, OpenRouter, Pollinations, NanoGPT are added externally by JavaScript -->
|
||||
<option data-type="cohere" value="c4ai-aya-vision-8b">c4ai-aya-vision-8b</option>
|
||||
<option data-type="cohere" value="c4ai-aya-vision-32b">c4ai-aya-vision-32b</option>
|
||||
<option data-type="cohere" value="command-a-vision-07-2025">command-a-vision-07-2025</option>
|
||||
@@ -110,6 +112,7 @@
|
||||
<option data-type="google" value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option>
|
||||
<option data-type="google" value="gemini-2.5-flash-lite">gemini-2.5-flash-lite</option>
|
||||
<option data-type="google" value="gemini-2.5-flash-lite-preview-06-17">gemini-2.5-flash-lite-preview-06-17</option>
|
||||
<option data-type="google" value="gemini-2.5-flash-image-preview">gemini-2.5-flash-image-preview</option>
|
||||
<option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05 → 2.5-pro-exp-03-25</option>
|
||||
<option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp → 2.5-pro-exp-03-25</option>
|
||||
<option data-type="google" value="gemini-exp-1206">gemini-exp-1206 → 2.5-pro-exp-03-25</option>
|
||||
@@ -146,17 +149,26 @@
|
||||
<option data-type="vertexai" value="gemini-2.5-flash-preview-04-17">gemini-2.5-flash-preview-04-17</option>
|
||||
<option data-type="vertexai" value="gemini-2.5-flash-lite">gemini-2.5-flash-lite</option>
|
||||
<option data-type="vertexai" value="gemini-2.5-flash-lite-preview-06-17">gemini-2.5-flash-lite-preview-06-17</option>
|
||||
<option data-type="vertexai" value="gemini-2.5-flash-image-preview">gemini-2.5-flash-image-preview</option>
|
||||
<option data-type="vertexai" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option>
|
||||
<option data-type="vertexai" value="gemini-2.0-flash-lite-001">gemini-2.0-flash-lite-001</option>
|
||||
<option data-type="groq" value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option>
|
||||
<option data-type="groq" value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option>
|
||||
<option data-type="groq" value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option>
|
||||
<option data-type="groq" value="meta-llama/llama-4-scout-17b-16e-instruct">meta-llama/llama-4-scout-17b-16e-instruct</option>
|
||||
<option data-type="groq" value="meta-llama/llama-4-maverick-17b-128e-instruct">meta-llama/llama-4-maverick-17b-128e-instruct</option>
|
||||
<option data-type="ollama" value="ollama_current" data-i18n="currently_selected">[Currently selected]</option>
|
||||
<option data-type="ollama" value="ollama_custom" data-i18n="[Custom model]">[Custom model]</option>
|
||||
<option data-type="ollama" value="bakllava">bakllava</option>
|
||||
<option data-type="ollama" value="llava">llava</option>
|
||||
<option data-type="ollama" value="llava-llama3">llava-llama3</option>
|
||||
<option data-type="ollama" value="llava-phi3">llava-phi3</option>
|
||||
<option data-type="ollama" value="moondream">moondream</option>
|
||||
<option data-type="ollama" value="gemma3">gemma3</option>
|
||||
<option data-type="ollama" value="minicpm-v">minicpm-v</option>
|
||||
<option data-type="ollama" value="qwen2.5vl">qwen2.5vl</option>
|
||||
<option data-type="ollama" value="granite3.2-vision">granite3.2-vision</option>
|
||||
<option data-type="ollama" value="mistral-small3.1">mistral-small3.1</option>
|
||||
<option data-type="ollama" value="mistral-small3.2">mistral-small3.2</option>
|
||||
<option data-type="ollama" value="llama3.2-vision">llama3.2-vision</option>
|
||||
<option data-type="ollama" value="llama4">llama4</option>
|
||||
<option data-type="llamacpp" value="llamacpp_current" data-i18n="currently_loaded">[Currently loaded]</option>
|
||||
<option data-type="ooba" value="ooba_current" data-i18n="currently_loaded">[Currently loaded]</option>
|
||||
<option data-type="koboldcpp" value="koboldcpp_current" data-i18n="currently_loaded">[Currently loaded]</option>
|
||||
@@ -168,16 +180,25 @@
|
||||
</select>
|
||||
</div>
|
||||
<div data-type="ollama">
|
||||
The model must be downloaded first! Do it with the <code>ollama pull</code> command or <a href="#" id="caption_ollama_pull">click here</a>.
|
||||
<div>
|
||||
The model must be downloaded first! Do it with the <code>ollama pull</code> command or <a href="#" id="caption_ollama_pull">click here</a>.
|
||||
</div>
|
||||
<div class="marginTop5">
|
||||
<label for="caption_ollama_custom_model">
|
||||
<span data-i18n="Custom Model Tag">Custom Model Tag</span>
|
||||
<small data-i18n="(for [Custom model] option)">(for [Custom model] option)</small>
|
||||
</label>
|
||||
<input id="caption_ollama_custom_model" class="text_pole" type="text" placeholder="e.g. gemma3:latest" />
|
||||
</div>
|
||||
</div>
|
||||
<label data-type="openai,anthropic,google,vertexai,mistral,xai" class="checkbox_label flexBasis100p" for="caption_allow_reverse_proxy" title="Allow using reverse proxy if defined and valid.">
|
||||
<input id="caption_allow_reverse_proxy" type="checkbox" class="checkbox">
|
||||
<span data-i18n="Allow reverse proxy">Allow reverse proxy</span>
|
||||
</label>
|
||||
<div class="flexBasis100p m-b-1">
|
||||
<div class="flexBasis100p marginBot10">
|
||||
<small><b data-i18n="Hint:">Hint:</b> <span data-i18n="Set your API keys and endpoints in the 'API Connections' tab first.">Set your API keys and endpoints in the 'API Connections' tab first.</span></small>
|
||||
</div>
|
||||
<div data-type="koboldcpp,ollama,vllm,llamacpp,ooba" class="flex-container flexFlowColumn">
|
||||
<div data-type="koboldcpp,ollama,vllm,llamacpp,ooba" class="flex-container flexFlowColumn wide100p">
|
||||
<label for="caption_altEndpoint_enabled" class="checkbox_label">
|
||||
<input id="caption_altEndpoint_enabled" type="checkbox">
|
||||
<span data-i18n="Use secondary URL">Use secondary URL</span>
|
||||
|
||||
@@ -43,6 +43,7 @@ const CC_COMMANDS = [
|
||||
'reasoning-template',
|
||||
'prompt-post-processing',
|
||||
'secret-id',
|
||||
'regex-preset',
|
||||
];
|
||||
|
||||
const TC_COMMANDS = [
|
||||
@@ -60,6 +61,7 @@ const TC_COMMANDS = [
|
||||
'start-reply-with',
|
||||
'reasoning-template',
|
||||
'secret-id',
|
||||
'regex-preset',
|
||||
];
|
||||
|
||||
const FANCY_NAMES = {
|
||||
@@ -79,6 +81,7 @@ const FANCY_NAMES = {
|
||||
'reasoning-template': 'Reasoning Template',
|
||||
'prompt-post-processing': 'Prompt Post-Processing',
|
||||
'secret-id': 'Secret',
|
||||
'regex-preset': 'Regex Preset',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -357,6 +360,14 @@ function makeFancyProfile(profile) {
|
||||
}
|
||||
}
|
||||
|
||||
if (key === 'regex-preset') {
|
||||
const label = extension_settings.regex_presets?.find(p => p.id === profile[key])?.name;
|
||||
if (label) {
|
||||
acc[value] = label;
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
|
||||
acc[value] = profile[key];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
@@ -63,10 +63,10 @@ mutationObserver.observe(document.body, {
|
||||
});
|
||||
|
||||
const SORT = Object.freeze({
|
||||
NAME_ASC: { value: 'nameAsc', field: 'name', order: 'asc', label: t`Sort By: Name (A-Z)` },
|
||||
NAME_DESC: { value: 'nameDesc', field: 'name', order: 'desc', label: t`Sort By: Name (Z-A)` },
|
||||
DATE_ASC: { value: 'dateAsc', field: 'date', order: 'asc', label: t`Sort By: Date (Oldest First)` },
|
||||
DATE_DESC: { value: 'dateDesc', field: 'date', order: 'desc', label: t`Sort By: Date (Newest First)` },
|
||||
NAME_ASC: { value: 'nameAsc', field: 'name', order: 'asc', label: t`Name (A-Z)` },
|
||||
NAME_DESC: { value: 'nameDesc', field: 'name', order: 'desc', label: t`Name (Z-A)` },
|
||||
DATE_DESC: { value: 'dateDesc', field: 'date', order: 'desc', label: t`Newest` },
|
||||
DATE_ASC: { value: 'dateAsc', field: 'date', order: 'asc', label: t`Oldest` },
|
||||
});
|
||||
|
||||
const defaultSettings = Object.freeze({
|
||||
@@ -376,6 +376,11 @@ async function makeMovable(url) {
|
||||
const titleText = document.createElement('span');
|
||||
titleText.textContent = t`Image Gallery`;
|
||||
dragTitle.append(titleText);
|
||||
|
||||
// Create a container for the controls
|
||||
const controlsContainer = document.createElement('div');
|
||||
controlsContainer.classList.add('flex-container', 'alignItemsCenter');
|
||||
|
||||
const sortSelect = document.createElement('select');
|
||||
sortSelect.classList.add('gallery-sort-select');
|
||||
|
||||
@@ -394,7 +399,42 @@ async function makeMovable(url) {
|
||||
});
|
||||
|
||||
sortSelect.value = getSortOrder();
|
||||
dragTitle.append(sortSelect);
|
||||
controlsContainer.appendChild(sortSelect);
|
||||
|
||||
// Create the "Add Image" button
|
||||
const addImageButton = document.createElement('div');
|
||||
addImageButton.classList.add('menu_button', 'menu_button_icon', 'interactable');
|
||||
addImageButton.title = 'Add Image';
|
||||
addImageButton.innerHTML = '<i class="fa-solid fa-plus fa-fw"></i><div>Add Image</div>';
|
||||
|
||||
// Create a hidden file input
|
||||
const fileInput = document.createElement('input');
|
||||
fileInput.type = 'file';
|
||||
fileInput.accept = 'image/*';
|
||||
fileInput.multiple = true;
|
||||
fileInput.style.display = 'none';
|
||||
|
||||
// Trigger file input when the button is clicked
|
||||
addImageButton.addEventListener('click', () => {
|
||||
fileInput.click();
|
||||
});
|
||||
|
||||
// Handle file selection
|
||||
fileInput.addEventListener('change', async () => {
|
||||
const files = fileInput.files;
|
||||
if (files.length > 0) {
|
||||
for (const file of files) {
|
||||
await uploadFile(file, url);
|
||||
}
|
||||
// Refresh the gallery
|
||||
closeButton.trigger('click');
|
||||
await showCharGallery();
|
||||
}
|
||||
});
|
||||
|
||||
controlsContainer.appendChild(addImageButton);
|
||||
dragTitle.append(controlsContainer);
|
||||
newElement.append(fileInput); // Append hidden file input to the main element
|
||||
|
||||
// add no-scrollbar class to this element
|
||||
newElement.addClass('no-scrollbar');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.gallery-folder-input {
|
||||
@@ -26,13 +27,13 @@
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
opacity: 0.8;
|
||||
background: none;
|
||||
background-color: var(--black30a);
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
background-image: url(/img/down-arrow.svg);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 6px center;
|
||||
background-size: 8px 5px;
|
||||
padding-right: 20px;
|
||||
font-size: calc(var(--mainFontSize)* 0.9);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
/* Styles for the debugger UI */
|
||||
#regex_debugger_rules {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
#regex_debugger_rules,
|
||||
#regex_debugger_rules .sortable-list {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.regex-debugger-rules-list {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.regex-debugger-rule {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
background-color: var(--black30a);
|
||||
gap: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#regex_debugger_run_test_header {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#regex_debugger_expand_steps,
|
||||
#regex_debugger_expand_final,
|
||||
#regex_debugger_save_order {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.regex-debugger-rule:hover {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
|
||||
.regex-debugger-rule .handle {
|
||||
cursor: grab;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.regex-debugger-rule .rule-details {
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.regex-debugger-rule .rule-name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.regex-debugger-rule .rule-regex {
|
||||
font-size: 0.8em;
|
||||
opacity: 0.8;
|
||||
font-family: var(--monoFontFamily);
|
||||
}
|
||||
|
||||
.regex-debugger-rule .rule-scope {
|
||||
font-size: 0.8em;
|
||||
padding: 2px 6px;
|
||||
border-radius: 5px;
|
||||
background-color: var(--black30a);
|
||||
margin-left: auto;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.regex-debugger-rule .menu_button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#regex_debugger_raw_input {
|
||||
min-height: 1.8em;
|
||||
}
|
||||
|
||||
#regex_debugger_steps_output {
|
||||
min-height: 2em;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
background-color: var(--black30a);
|
||||
font-family: var(--monoFontFamily);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#regex_debugger_final_output {
|
||||
min-height: 2em;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
background-color: var(--black30a);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.step-header {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.step-output {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
padding: 5px;
|
||||
background-color: var(--black30a);
|
||||
border-radius: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Classes to replace inline styles */
|
||||
.regex-debugger-no-rules {
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.regex-debugger-list-header {
|
||||
font-weight: bold;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* Styles for statistics */
|
||||
.step-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.step-metrics {
|
||||
font-size: 0.8em;
|
||||
opacity: 0.8;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.regex-debugger-summary {
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
background-color: var(--black30a);
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.regex-debugger-tester .results-header {
|
||||
position: relative;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.regex-debugger-tester .radio_group {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Styles for statistics and highlighting additions */
|
||||
.step-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
/* Allow wrapping on small screens */
|
||||
}
|
||||
|
||||
.step-metrics {
|
||||
font-size: 0.8em;
|
||||
opacity: 0.8;
|
||||
font-weight: normal;
|
||||
white-space: nowrap;
|
||||
/* Prevent metrics from breaking line */
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.regex-debugger-summary {
|
||||
padding: 8px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
background-color: var(--black30a);
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
/* New highlight color for added text */
|
||||
mark.green_hl {
|
||||
background-color: #28a745;
|
||||
/* A standard green color */
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* New highlight color for deleted text */
|
||||
mark.red_hl {
|
||||
background-color: #dc3545;
|
||||
/* A standard red color */
|
||||
color: white;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
/* Styles for the expanded view with navigation */
|
||||
.expanded-regex-container {
|
||||
display: flex;
|
||||
height: 75vh;
|
||||
/* Give the container a good height */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.expanded-regex-nav {
|
||||
flex: 0 0 200px;
|
||||
/* Fixed width for the nav bar */
|
||||
border-right: 1px solid var(--SmartThemeBorderColor);
|
||||
padding: 5px;
|
||||
overflow-y: auto;
|
||||
background-color: var(--black30a);
|
||||
}
|
||||
|
||||
.expanded-regex-nav a {
|
||||
display: block;
|
||||
padding: 6px 8px;
|
||||
text-decoration: none;
|
||||
color: var(--SmartThemeMainColor);
|
||||
border-radius: 5px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.expanded-regex-nav a:hover {
|
||||
background-color: var(--background_hover_color);
|
||||
}
|
||||
|
||||
.expanded-regex-nav a.active {
|
||||
background-color: var(--highlight_color);
|
||||
color: var(--text_color_black);
|
||||
}
|
||||
|
||||
.expanded-regex-content {
|
||||
flex-grow: 1;
|
||||
overflow-y: auto;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
#regex_debugger_render_mode {
|
||||
padding-right: 20px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.regex-popup-content {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
text-align: left;
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<div class="regex-debugger-container">
|
||||
<!-- Rules List Column -->
|
||||
<div class="regex-debugger-rules-list">
|
||||
<h3>
|
||||
<i class="fa-solid fa-list-ol"></i>
|
||||
<span data-i18n="ext_regex_debugger_active_rules"
|
||||
>Active Rules</span
|
||||
>
|
||||
</h3>
|
||||
<div class="flex-container">
|
||||
<button
|
||||
id="regex_debugger_save_order"
|
||||
class="menu_button menu_button_icon interactable"
|
||||
title="Save current rule order"
|
||||
tabindex="0"
|
||||
>
|
||||
<i class="fa-solid fa-floppy-disk"></i>
|
||||
<span data-i18n="ext_regex_debugger_save_order"
|
||||
>Save Order</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
<ul id="regex_debugger_rules" class="sortable-list">
|
||||
<!-- Rules will be populated here by JavaScript -->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Testing Area Column -->
|
||||
<div class="regex-debugger-tester">
|
||||
<h3>
|
||||
<i class="fa-solid fa-vial"></i>
|
||||
<span data-i18n="ext_regex_debugger_testing_area"
|
||||
>Testing Area</span
|
||||
>
|
||||
</h3>
|
||||
<div class="regex-debugger-io">
|
||||
<div class="regex-debugger-input">
|
||||
<label
|
||||
for="regex_debugger_raw_input"
|
||||
data-i18n="ext_regex_debugger_raw_input"
|
||||
>Raw Input</label
|
||||
>
|
||||
<textarea
|
||||
id="regex_debugger_raw_input"
|
||||
class="text_pole autoSetHeight"
|
||||
rows="4"
|
||||
></textarea>
|
||||
</div>
|
||||
<div
|
||||
id="regex_debugger_run_test_header"
|
||||
class="flex-container"
|
||||
>
|
||||
<button
|
||||
id="regex_debugger_run_test"
|
||||
class="menu_button menu_button_icon interactable"
|
||||
title="Run the test pipeline"
|
||||
tabindex="0"
|
||||
>
|
||||
<i class="fa-solid fa-play"></i>
|
||||
<span data-i18n="ext_regex_debugger_run_test"
|
||||
>Run Test</span
|
||||
>
|
||||
</button>
|
||||
<div class="flex-container gap10px">
|
||||
<div class="radio_group">
|
||||
<label
|
||||
><input
|
||||
type="radio"
|
||||
name="display_mode"
|
||||
value="replace"
|
||||
checked
|
||||
/>
|
||||
<span data-i18n="ext_regex_debugger_display_replace"
|
||||
>Replace</span
|
||||
></label
|
||||
>
|
||||
<label
|
||||
><input
|
||||
type="radio"
|
||||
name="display_mode"
|
||||
value="highlight"
|
||||
/>
|
||||
<span
|
||||
data-i18n="ext_regex_debugger_display_highlight"
|
||||
>Highlight</span
|
||||
></label
|
||||
>
|
||||
</div>
|
||||
<select
|
||||
id="regex_debugger_render_mode"
|
||||
>
|
||||
<option
|
||||
value="text"
|
||||
data-i18n="ext_regex_debugger_render_text"
|
||||
>
|
||||
Render as Text
|
||||
</option>
|
||||
<option
|
||||
value="message"
|
||||
data-i18n="ext_regex_debugger_render_message"
|
||||
>
|
||||
Render as Message
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="regex-debugger-results">
|
||||
<div class="results-header">
|
||||
<h4>
|
||||
<i class="fa-solid fa-shoe-prints"></i>
|
||||
<span data-i18n="ext_regex_debugger_step_by_step"
|
||||
>Step-by-step Transformation</span
|
||||
>
|
||||
</h4>
|
||||
<div
|
||||
id="regex_debugger_expand_steps"
|
||||
class="menu_button menu_button_icon"
|
||||
title="Expand view"
|
||||
>
|
||||
<i class="fa-solid fa-expand"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div id="regex_debugger_steps_output" class="results-box"></div>
|
||||
|
||||
<div class="results-header">
|
||||
<h4>
|
||||
<i class="fa-solid fa-flag-checkered"></i>
|
||||
<span data-i18n="ext_regex_debugger_final_output"
|
||||
>Final Output</span
|
||||
>
|
||||
</h4>
|
||||
<div
|
||||
id="regex_debugger_expand_final"
|
||||
class="menu_button menu_button_icon"
|
||||
title="Expand view"
|
||||
>
|
||||
<i class="fa-solid fa-expand"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="regex_debugger_final_output"
|
||||
class="results-box final-output"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Template for a single rule item -->
|
||||
<template id="regex_debugger_rule_template">
|
||||
<li class="regex-debugger-rule" draggable="true">
|
||||
<i class="fa-solid fa-grip-vertical handle"></i>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" class="rule-enabled" checked />
|
||||
</label>
|
||||
<div class="rule-details">
|
||||
<span class="rule-name"></span>
|
||||
<code class="rule-regex"></code>
|
||||
<small class="rule-scope"></small>
|
||||
</div>
|
||||
<div class="menu_button menu_button_icon edit_rule" title="Edit Rule">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<!-- Template for a single transformation step -->
|
||||
<template id="regex_debugger_step_template">
|
||||
<div class="step-result">
|
||||
<div class="step-header">
|
||||
<strong></strong>
|
||||
</div>
|
||||
<pre class="step-output"></pre>
|
||||
</div>
|
||||
</template>
|
||||
@@ -26,6 +26,10 @@
|
||||
<i class="fa-solid fa-edit"></i>
|
||||
<small data-i18n="ext_regex_bulk_edit">Bulk Edit</small>
|
||||
</label>
|
||||
<div id="open_regex_debugger" class="menu_button menu_button_icon" data-i18n="[title]ext_regex_debugger_desc" title="Advanced Regex Debugger">
|
||||
<i class="fa-solid fa-bug-slash"></i>
|
||||
<small data-i18n="ext_regex_debugger">Debugger</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="regex_bulk_operations flex-container justifyCenter">
|
||||
<div id="bulk_select_all_toggle" class="menu_button menu_button_icon" title="Toggle Select All">
|
||||
@@ -49,6 +53,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div id="regex_presets_block">
|
||||
<div class="flex-container alignItemsBaseline">
|
||||
<strong class="flex1" data-i18n="ext_regex_presets">Regex Presets</strong>
|
||||
</div>
|
||||
<small data-i18n="ext_regex_presets_desc">
|
||||
Save and switch between groups of enabled regex scripts.
|
||||
</small>
|
||||
<div class="flex-container marginTop5">
|
||||
<select id="regex_presets" class="text_pole flex1"></select>
|
||||
<div id="regex_preset_create" class="menu_button fa-solid fa-file-circle-plus" data-i18n="[title]ext_regex_preset_create" title="Create a new regex preset"></div>
|
||||
<div id="regex_preset_update" class="menu_button fa-solid fa-save" data-i18n="[title]ext_regex_preset_update" title="Update existing regex preset"></div>
|
||||
<div id="regex_preset_apply" class="menu_button fa-solid fa-recycle" data-i18n="[title]ext_regex_preset_apply" title="Re-apply current preset"></div>
|
||||
<div id="regex_preset_delete" class="menu_button fa-solid fa-trash" data-i18n="[title]ext_regex_preset_delete" title="Delete current preset"></div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div id="global_scripts_block" class="padding5">
|
||||
<div>
|
||||
<strong data-i18n="ext_regex_global_scripts">Global Scripts</strong>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { characters, eventSource, event_types, getCurrentChatId, reloadCurrentChat, saveSettingsDebounced, this_chid } from '../../../script.js';
|
||||
import { characters, eventSource, event_types, getCurrentChatId, messageFormatting, reloadCurrentChat, saveSettingsDebounced, this_chid } from '../../../script.js';
|
||||
import { extension_settings, renderExtensionTemplateAsync, writeExtensionField } from '../../extensions.js';
|
||||
import { selected_group } from '../../group-chats.js';
|
||||
import { callGenericPopup, POPUP_TYPE } from '../../popup.js';
|
||||
import { callGenericPopup, Popup, POPUP_TYPE } from '../../popup.js';
|
||||
import { SlashCommand } from '../../slash-commands/SlashCommand.js';
|
||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
|
||||
import { commonEnumProviders, enumIcons } from '../../slash-commands/SlashCommandCommonEnumsProvider.js';
|
||||
import { SlashCommandEnumValue, enumTypes } from '../../slash-commands/SlashCommandEnumValue.js';
|
||||
import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
|
||||
import { download, equalsIgnoreCaseAndAccents, getFileText, getSortableDelay, isFalseBoolean, isTrueBoolean, regexFromString, setInfoBlock, uuidv4 } from '../../utils.js';
|
||||
import { download, equalsIgnoreCaseAndAccents, getFileText, getSortableDelay, isFalseBoolean, isTrueBoolean, regexFromString, setInfoBlock, uuidv4, escapeHtml } from '../../utils.js';
|
||||
import { regex_placement, runRegexScript, substitute_find_regex } from './engine.js';
|
||||
import { t } from '../../i18n.js';
|
||||
import { accountStorage } from '../../util/AccountStorage.js';
|
||||
@@ -18,6 +18,452 @@ const sanitizeFileName = name => name.replace(/[\s.<>:"/\\|?*\x00-\x1F\x7F]/g, '
|
||||
* @typedef {import('../../char-data.js').RegexScriptData} RegexScript
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RegexPresetItem
|
||||
* @property {string} id - UUID of the regex script
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RegexPreset
|
||||
* @property {string} id - UUID of the preset
|
||||
* @property {string} name - Name of the preset
|
||||
* @property {boolean} isSelected - Whether the preset is currently selected
|
||||
* @property {RegexPresetItem[]} global - The list of global preset items
|
||||
* @property {RegexPresetItem[]} scoped - The list of scoped preset items
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} RegexPresetState
|
||||
* @property {string[]} global - List of enabled global regex script IDs
|
||||
* @property {string[]} scoped - List of enabled scoped regex script IDs
|
||||
*/
|
||||
|
||||
class RegexPresetManager {
|
||||
/** @type {HTMLSelectElement} */
|
||||
presetSelect = null;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
presetCreateButton = null;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
presetUpdateButton = null;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
presetApplyButton = null;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
presetDeleteButton = null;
|
||||
|
||||
/** @type {string|null} */
|
||||
currentPresetId = null;
|
||||
|
||||
/** @type {RegexPresetState|null} */
|
||||
lastKnownState = null;
|
||||
|
||||
/**
|
||||
* Captures the current state of enabled regex scripts for change detection.
|
||||
* @returns {RegexPresetState} The current state object
|
||||
*/
|
||||
captureCurrentState() {
|
||||
const globalScripts = this.regexListToPresetItems(extension_settings.regex) || [];
|
||||
const scopedScripts = this.regexListToPresetItems(characters[this_chid]?.data?.extensions?.regex_scripts) || [];
|
||||
|
||||
return {
|
||||
global: globalScripts.map(item => item.id).sort(),
|
||||
scoped: scopedScripts.map(item => item.id).sort(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two state objects to detect changes.
|
||||
* @param {RegexPresetState} state1 First state object
|
||||
* @param {RegexPresetState} state2 Second state object
|
||||
* @returns {boolean} True if states are different
|
||||
*/
|
||||
hasStateChanged(state1, state2) {
|
||||
if (!state1 || !state2) return false;
|
||||
|
||||
const global1 = state1.global || [];
|
||||
const global2 = state2.global || [];
|
||||
const scoped1 = state1.scoped || [];
|
||||
const scoped2 = state2.scoped || [];
|
||||
|
||||
if (global1.length !== global2.length || scoped1.length !== scoped2.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !global1.every(id => global2.includes(id)) ||
|
||||
!scoped1.every(id => scoped2.includes(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the stored state after a preset is applied or saved.
|
||||
* @param {string} presetId - The current preset ID
|
||||
*/
|
||||
updateStoredState(presetId) {
|
||||
this.currentPresetId = presetId;
|
||||
this.lastKnownState = this.captureCurrentState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are unsaved changes and shows a confirmation dialog.
|
||||
* @returns {Promise<boolean>} True if user wants to proceed without saving
|
||||
*/
|
||||
async checkUnsavedChanges() {
|
||||
if (!this.currentPresetId || !this.lastKnownState) {
|
||||
return true; // No current preset or state to compare
|
||||
}
|
||||
|
||||
const currentState = this.captureCurrentState();
|
||||
if (!this.hasStateChanged(this.lastKnownState, currentState)) {
|
||||
return true; // No changes detected
|
||||
}
|
||||
|
||||
const currentPreset = extension_settings.regex_presets.find(p => p.id === this.currentPresetId);
|
||||
const presetName = currentPreset ? currentPreset.name : t`Unknown Preset`;
|
||||
|
||||
const choice = await Popup.show.confirm(
|
||||
t`You have unsaved changes to the "${presetName}" preset.`,
|
||||
t`Do you want to save them before switching?`,
|
||||
{
|
||||
okButton: t`Save Changes`,
|
||||
cancelButton: t`Discard Changes`,
|
||||
},
|
||||
);
|
||||
|
||||
if (choice) {
|
||||
// User chose to save changes
|
||||
await this.savePreset(this.currentPresetId, true);
|
||||
this.renderPresetList();
|
||||
return true;
|
||||
}
|
||||
|
||||
// User chose to discard changes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up event listeners for the preset management UI.
|
||||
* @returns {void}
|
||||
*/
|
||||
setupEventListeners() {
|
||||
this.presetSelect = /** @type {HTMLSelectElement} */ (document.getElementById('regex_presets'));
|
||||
if (!this.presetSelect) {
|
||||
console.error('RegexPresetManager: Could not find preset select element in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetSelect.addEventListener('change', async (event) => {
|
||||
const selectedPresetId = this.presetSelect.value;
|
||||
const fromSlashCommand = event instanceof CustomEvent && event?.detail?.fromSlashCommand === true;
|
||||
|
||||
// Check for unsaved changes before switching
|
||||
if (!fromSlashCommand) {
|
||||
const canProceed = await this.checkUnsavedChanges();
|
||||
if (!canProceed) {
|
||||
// Revert the selection
|
||||
event.preventDefault();
|
||||
const currentPreset = extension_settings.regex_presets.find(p => p.id === this.currentPresetId);
|
||||
if (currentPreset) {
|
||||
this.presetSelect.value = currentPreset.id;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await this.applyPreset(selectedPresetId);
|
||||
extension_settings.regex_presets.forEach(p => { p.isSelected = p.id === selectedPresetId; });
|
||||
saveSettingsDebounced();
|
||||
this.updateStoredState(selectedPresetId);
|
||||
});
|
||||
|
||||
this.presetCreateButton = document.getElementById('regex_preset_create');
|
||||
if (!this.presetCreateButton) {
|
||||
console.error('RegexPresetManager: Could not find preset create button in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetCreateButton.addEventListener('click', async () => {
|
||||
const newId = uuidv4();
|
||||
await this.savePreset(newId, false);
|
||||
this.renderPresetList();
|
||||
this.updateStoredState(newId);
|
||||
});
|
||||
|
||||
this.presetUpdateButton = document.getElementById('regex_preset_update');
|
||||
if (!this.presetUpdateButton) {
|
||||
console.error('RegexPresetManager: Could not find preset update button in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetUpdateButton.addEventListener('click', async () => {
|
||||
const selectedPresetId = this.presetSelect.value;
|
||||
await this.savePreset(selectedPresetId, true);
|
||||
this.renderPresetList();
|
||||
this.updateStoredState(selectedPresetId);
|
||||
});
|
||||
|
||||
this.presetApplyButton = document.getElementById('regex_preset_apply');
|
||||
if (!this.presetApplyButton) {
|
||||
console.error('RegexPresetManager: Could not find preset apply button in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetApplyButton.addEventListener('click', async () => {
|
||||
const selectedPresetId = this.presetSelect.value;
|
||||
await this.applyPreset(selectedPresetId);
|
||||
this.updateStoredState(selectedPresetId);
|
||||
});
|
||||
|
||||
this.presetDeleteButton = document.getElementById('regex_preset_delete');
|
||||
if (!this.presetDeleteButton) {
|
||||
console.error('RegexPresetManager: Could not find preset delete button in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetDeleteButton.addEventListener('click', async () => {
|
||||
const selectedPresetId = this.presetSelect.value;
|
||||
await this.deletePreset(selectedPresetId);
|
||||
this.renderPresetList();
|
||||
|
||||
const newSelectedPresetId = extension_settings.regex_presets.find(p => p.isSelected)?.id;
|
||||
if (newSelectedPresetId) {
|
||||
await this.applyPreset(newSelectedPresetId);
|
||||
this.presetSelect.value = newSelectedPresetId;
|
||||
this.updateStoredState(newSelectedPresetId);
|
||||
} else {
|
||||
this.currentPresetId = null;
|
||||
this.lastKnownState = null;
|
||||
}
|
||||
});
|
||||
|
||||
this.renderPresetList();
|
||||
|
||||
// Initialize the stored state with the currently selected preset
|
||||
const selectedPreset = extension_settings.regex_presets?.find(p => p.isSelected);
|
||||
if (selectedPreset) {
|
||||
this.updateStoredState(selectedPreset.id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers slash commands related to regex presets.
|
||||
* @returns {void}
|
||||
*/
|
||||
registerSlashCommands() {
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'regex-preset',
|
||||
helpString: t`Selects a regex preset by name or ID. Gets the current regex preset ID if no argument is provided.`,
|
||||
callback: (args, name) => {
|
||||
if (!this.presetSelect) {
|
||||
return '';
|
||||
}
|
||||
|
||||
name = String(name ?? '').trim();
|
||||
|
||||
if (name) {
|
||||
const quiet = isTrueBoolean(args?.quiet?.toString());
|
||||
const foundId = extension_settings.regex_presets.find(p => equalsIgnoreCaseAndAccents(p.id, name) || equalsIgnoreCaseAndAccents(p.name, name))?.id;
|
||||
|
||||
if (foundId) {
|
||||
this.presetSelect.value = foundId;
|
||||
this.presetSelect.dispatchEvent(new CustomEvent('change', { detail: { fromSlashCommand: true } }));
|
||||
return foundId;
|
||||
}
|
||||
|
||||
!quiet && toastr.warning(`Regex preset "${name}" not found`);
|
||||
return '';
|
||||
}
|
||||
|
||||
return this.presetSelect.value;
|
||||
},
|
||||
returns: 'current preset ID',
|
||||
namedArgumentList: [
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'quiet',
|
||||
description: 'Suppress the toast message on preset change',
|
||||
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||
defaultValue: 'false',
|
||||
enumList: commonEnumProviders.boolean('trueFalse')(),
|
||||
}),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'regex preset name or ID',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
enumProvider: () => extension_settings.regex_presets.map(x => new SlashCommandEnumValue(x.id, x.name, enumTypes.enum, enumIcons.preset)),
|
||||
}),
|
||||
],
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the list of regex presets in the UI.
|
||||
* @returns {void}
|
||||
*/
|
||||
renderPresetList() {
|
||||
if (!this.presetSelect) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.presetSelect.innerHTML = '';
|
||||
|
||||
if (!Array.isArray(extension_settings.regex_presets) || extension_settings.regex_presets.length === 0) {
|
||||
const fallbackOption = new Option(t`[No presets saved]`, '', true, true);
|
||||
this.presetSelect.appendChild(fallbackOption);
|
||||
this.presetSelect.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
extension_settings.regex_presets.forEach(preset => {
|
||||
const option = new Option(preset.name, preset.id, preset.isSelected, preset.isSelected);
|
||||
this.presetSelect.appendChild(option);
|
||||
});
|
||||
|
||||
this.presetSelect.disabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a preset list to a target list of scripts.
|
||||
* @param {Object} params The parameters object
|
||||
* @param {RegexPresetItem[]} params.presetList The list of preset items
|
||||
* @param {RegexScript[]} params.targetList The list of target scripts to modify
|
||||
* @param {(targetList: RegexScript[]) => Promise<any>} params.saveFunction Function to save the modified list
|
||||
*/
|
||||
async applyPresetList({ presetList, targetList, saveFunction }) {
|
||||
if (!Array.isArray(targetList) || !Array.isArray(presetList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only enable scripts that are in the preset
|
||||
targetList.forEach((script => {
|
||||
script.disabled = !presetList.some(p => p.id === script.id);
|
||||
}));
|
||||
|
||||
// First sort by the order in the preset, then the original order
|
||||
targetList.sort((a, b) => {
|
||||
const aIndex = presetList.findIndex(p => p.id === a.id);
|
||||
const bIndex = presetList.findIndex(p => p.id === b.id);
|
||||
return aIndex - bIndex || targetList.indexOf(a) - targetList.indexOf(b);
|
||||
});
|
||||
|
||||
await saveFunction(targetList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a regex preset to the current context.
|
||||
* @param {string} presetId - The ID of the preset to apply
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async applyPreset(presetId) {
|
||||
const preset = extension_settings.regex_presets.find(p => p.id === presetId);
|
||||
if (!preset) {
|
||||
toastr.error(t`Could not find the selected preset.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply to both global and scoped lists
|
||||
await this.applyPresetList({
|
||||
presetList: preset.global,
|
||||
targetList: extension_settings.regex,
|
||||
saveFunction: () => saveSettingsDebounced(),
|
||||
});
|
||||
await this.applyPresetList({
|
||||
presetList: preset.scoped,
|
||||
targetList: characters[this_chid]?.data?.extensions?.regex_scripts,
|
||||
saveFunction: (scripts) => writeExtensionField(this_chid, 'regex_scripts', scripts),
|
||||
});
|
||||
|
||||
// Render the changes to the UI
|
||||
await loadRegexScripts();
|
||||
// Apply the changes to the current chat
|
||||
await reloadCurrentChat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a list of regex scripts to preset items.
|
||||
* @param {RegexScript[]} list The list of regex scripts
|
||||
* @returns {RegexPresetItem[] | null} The list of preset items, or null if the input is invalid
|
||||
*/
|
||||
regexListToPresetItems(list) {
|
||||
if (!Array.isArray(list)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.filter(x => !x.disabled).map(s => ({ id: s.id }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a regex preset.
|
||||
* @param {string} presetId - The ID of the preset
|
||||
* @param {boolean} isUpdate - Whether this is an update operation
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async savePreset(presetId, isUpdate) {
|
||||
const existingPreset = isUpdate ? extension_settings.regex_presets.find(p => p.id === presetId) : null;
|
||||
|
||||
if (isUpdate && !existingPreset) {
|
||||
toastr.error(t`Could not find the preset to update.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const name = isUpdate ? existingPreset.name : await Popup.show.input(t`Enter a name for the new regex preset:`, '');
|
||||
const id = isUpdate ? existingPreset.id : presetId;
|
||||
|
||||
if (!name || !name.trim().length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const preset = {
|
||||
id: id,
|
||||
name: name,
|
||||
isSelected: false,
|
||||
global: this.regexListToPresetItems(extension_settings.regex),
|
||||
scoped: this.regexListToPresetItems(characters[this_chid]?.data?.extensions?.regex_scripts),
|
||||
};
|
||||
|
||||
if (isUpdate) {
|
||||
Object.assign(existingPreset, preset);
|
||||
} else {
|
||||
extension_settings.regex_presets.push(preset);
|
||||
}
|
||||
|
||||
extension_settings.regex_presets.forEach(p => { p.isSelected = p.id === id; });
|
||||
saveSettingsDebounced();
|
||||
|
||||
toastr.success(isUpdate ? t`Regex preset updated` : t`Regex preset saved`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a regex preset.
|
||||
* @param {string} presetId - The ID of the preset to delete
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async deletePreset(presetId) {
|
||||
const presetIndex = extension_settings.regex_presets.findIndex(p => p.id === presetId);
|
||||
if (presetIndex === -1) {
|
||||
toastr.error(t`Could not find the preset to delete.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const presetName = extension_settings.regex_presets[presetIndex].name;
|
||||
const confirm = await Popup.show.confirm(t`Are you sure you want to delete this regex preset?`, presetName);
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
extension_settings.regex_presets.splice(presetIndex, 1);
|
||||
|
||||
// Select the first preset if any exist
|
||||
extension_settings.regex_presets.forEach((p, i) => { p.isSelected = i === 0; });
|
||||
saveSettingsDebounced();
|
||||
|
||||
toastr.success(t`Regex preset deleted`);
|
||||
}
|
||||
}
|
||||
|
||||
const presetManager = new RegexPresetManager();
|
||||
|
||||
/**
|
||||
* Retrieves the list of regex scripts by combining the scripts from the extension settings and the character data
|
||||
*
|
||||
@@ -94,13 +540,18 @@ async function saveRegexScript(regexScript, existingScriptIndex, isScoped) {
|
||||
if (currentChatId !== undefined && currentChatId !== null) {
|
||||
await reloadCurrentChat();
|
||||
}
|
||||
|
||||
const debuggerPopup = $('#regex_debugger_popup');
|
||||
if (debuggerPopup.length) {
|
||||
populateDebuggerRuleList(debuggerPopup.parent());
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRegexScript({ id, isScoped }) {
|
||||
const array = (isScoped ? characters[this_chid]?.data?.extensions?.regex_scripts : extension_settings.regex) ?? [];
|
||||
|
||||
const existingScriptIndex = array.findIndex((script) => script.id === id);
|
||||
if (!existingScriptIndex || existingScriptIndex !== -1) {
|
||||
if (existingScriptIndex !== -1) {
|
||||
array.splice(existingScriptIndex, 1);
|
||||
|
||||
if (isScoped) {
|
||||
@@ -329,6 +780,442 @@ async function onRegexEditorOpenClick(existingId, isScoped) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an HTML string for a replacement, highlighting literal parts in green
|
||||
* and keeping back-referenced parts plain.
|
||||
* @param {RegExpMatchArray} match The match object from `matchAll`.
|
||||
* @param {string} pattern The replacement pattern string (e.g., "new text $1").
|
||||
* @returns {string} The constructed HTML string.
|
||||
*/
|
||||
function buildReplacementHtml(match, pattern) {
|
||||
const container = document.createDocumentFragment();
|
||||
let lastIndex = 0;
|
||||
const backrefRegex = /\$\$|\$&|\$`|\$'|\$(\d{1,2})/g;
|
||||
|
||||
let reMatch;
|
||||
while ((reMatch = backrefRegex.exec(pattern)) !== null) {
|
||||
// Part of the pattern before the back-reference is a literal.
|
||||
const literalPart = pattern.substring(lastIndex, reMatch.index);
|
||||
if (literalPart) {
|
||||
const mark = document.createElement('mark');
|
||||
mark.className = 'green_hl';
|
||||
mark.innerText = literalPart;
|
||||
container.appendChild(mark);
|
||||
}
|
||||
|
||||
const backref = reMatch[0];
|
||||
if (backref === '$$') {
|
||||
container.appendChild(document.createTextNode('$'));
|
||||
} else if (backref === '$&') {
|
||||
const mark = document.createElement('mark');
|
||||
mark.className = 'yellow_hl';
|
||||
mark.innerText = match[0];
|
||||
container.appendChild(mark);
|
||||
} else if (backref === '$`') {
|
||||
container.appendChild(document.createTextNode(match.input.substring(0, match.index)));
|
||||
} else if (backref === '$\'') {
|
||||
container.appendChild(document.createTextNode(match.input.substring(match.index + match[0].length)));
|
||||
} else { // It's a numbered capture group, $n.
|
||||
const groupIndex = parseInt(reMatch[1], 10);
|
||||
if (groupIndex > 0 && groupIndex < match.length && match[groupIndex] !== undefined) {
|
||||
const mark = document.createElement('mark');
|
||||
mark.className = 'yellow_hl';
|
||||
mark.innerText = match[groupIndex];
|
||||
container.appendChild(mark);
|
||||
} else {
|
||||
// Not a valid group index, treat it as a literal.
|
||||
const mark = document.createElement('mark');
|
||||
mark.className = 'green_hl';
|
||||
mark.innerText = backref;
|
||||
container.appendChild(mark);
|
||||
}
|
||||
}
|
||||
lastIndex = backrefRegex.lastIndex;
|
||||
}
|
||||
|
||||
// The final part of the pattern after the last back-reference.
|
||||
const finalLiteralPart = pattern.substring(lastIndex);
|
||||
if (finalLiteralPart) {
|
||||
const mark = document.createElement('mark');
|
||||
mark.className = 'green_hl';
|
||||
mark.innerText = finalLiteralPart;
|
||||
container.appendChild(mark);
|
||||
}
|
||||
|
||||
// To get the HTML content, we need a temporary parent element.
|
||||
const tempDiv = document.createElement('div');
|
||||
tempDiv.appendChild(container);
|
||||
return tempDiv.innerHTML;
|
||||
}
|
||||
|
||||
function executeRegexScriptForDebugging(script, text) {
|
||||
let err;
|
||||
let originalRegex;
|
||||
|
||||
try {
|
||||
originalRegex = regexFromString(script.findRegex);
|
||||
if (!originalRegex) throw new Error('Invalid regex string');
|
||||
} catch (e) {
|
||||
err = `Compile error: ${e.message}`;
|
||||
return { output: text, highlightedOutput: text, error: err, charsCaptured: 0, charsAdded: 0, charsRemoved: 0 };
|
||||
}
|
||||
|
||||
const globalRegex = new RegExp(originalRegex.source, originalRegex.flags.includes('g') ? originalRegex.flags : originalRegex.flags + 'g');
|
||||
const matches = [...text.matchAll(globalRegex)];
|
||||
|
||||
if (matches.length === 0) {
|
||||
return { output: text, highlightedOutput: escapeHtml(text), error: null, charsCaptured: 0, charsAdded: 0, charsRemoved: 0 };
|
||||
}
|
||||
|
||||
let outputText = '';
|
||||
let highlightedOutput = ''; // This will now be our "diff view"
|
||||
let lastIndex = 0;
|
||||
let totalCharsCaptured = 0;
|
||||
let totalCharsAdded = 0;
|
||||
let totalCharsRemoved = 0;
|
||||
|
||||
try {
|
||||
for (const match of matches) {
|
||||
const originalMatchText = match[0];
|
||||
totalCharsCaptured += originalMatchText.length;
|
||||
|
||||
// Append text between matches (this part is unchanged)
|
||||
const precedingText = text.substring(lastIndex, match.index);
|
||||
outputText += precedingText;
|
||||
highlightedOutput += escapeHtml(precedingText);
|
||||
|
||||
// --- Start of new diff and statistics logic ---
|
||||
let charsAddedInMatch = 0;
|
||||
let charsKeptFromMatch = 0;
|
||||
const backrefRegex = /\$\$|\$&|\$`|\$'|\$(\d{1,2})/g;
|
||||
let lastPatternIndex = 0;
|
||||
let reMatch;
|
||||
let replacementForPlainText = '';
|
||||
|
||||
// This loop calculates the stats accurately
|
||||
while ((reMatch = backrefRegex.exec(script.replaceString)) !== null) {
|
||||
const literalPart = script.replaceString.substring(lastPatternIndex, reMatch.index);
|
||||
charsAddedInMatch += literalPart.length;
|
||||
replacementForPlainText += literalPart;
|
||||
const backref = reMatch[0];
|
||||
if (backref === '$$') {
|
||||
replacementForPlainText += '$';
|
||||
} else if (backref === '$&') {
|
||||
charsKeptFromMatch += (match[0] || '').length; replacementForPlainText += (match[0] || '');
|
||||
} else if (backref === '$`') {
|
||||
const part = match.input.substring(0, match.index); charsKeptFromMatch += part.length; replacementForPlainText += part;
|
||||
} else if (backref === '$\'') {
|
||||
const part = match.input.substring(match.index + match[0].length); charsKeptFromMatch += part.length; replacementForPlainText += part;
|
||||
} else {
|
||||
const groupIndex = parseInt(reMatch[1], 10);
|
||||
if (groupIndex > 0 && groupIndex < match.length && match[groupIndex] !== undefined) {
|
||||
charsKeptFromMatch += match[groupIndex].length;
|
||||
replacementForPlainText += match[groupIndex];
|
||||
}
|
||||
}
|
||||
lastPatternIndex = backrefRegex.lastIndex;
|
||||
}
|
||||
const finalLiteralPart = script.replaceString.substring(lastPatternIndex);
|
||||
charsAddedInMatch += finalLiteralPart.length;
|
||||
replacementForPlainText += finalLiteralPart;
|
||||
|
||||
totalCharsAdded += charsAddedInMatch;
|
||||
totalCharsRemoved += (originalMatchText.length - charsKeptFromMatch);
|
||||
|
||||
outputText += replacementForPlainText;
|
||||
// --- End of statistics logic ---
|
||||
|
||||
// --- Build the new Diff View HTML ---
|
||||
// 1. Show the entire original match as "removed" (red strikethrough)
|
||||
highlightedOutput += `<mark class='red_hl'>${escapeHtml(originalMatchText)}</mark>`;
|
||||
// 2. Add an arrow to signify transformation
|
||||
highlightedOutput += ' → ';
|
||||
// 3. Build the replacement string with green (added) and yellow (kept) parts
|
||||
highlightedOutput += buildReplacementHtml(match, script.replaceString);
|
||||
|
||||
lastIndex = match.index + originalMatchText.length;
|
||||
}
|
||||
|
||||
// Append text after the last match
|
||||
const trailingText = text.substring(lastIndex);
|
||||
outputText += trailingText;
|
||||
highlightedOutput += escapeHtml(trailingText);
|
||||
|
||||
} catch (e) {
|
||||
err = (err ? err + '; ' : '') + `Replace error: ${e.message}`;
|
||||
outputText = text; // Fallback
|
||||
highlightedOutput = escapeHtml(text);
|
||||
}
|
||||
|
||||
return {
|
||||
output: outputText,
|
||||
highlightedOutput: highlightedOutput,
|
||||
error: err,
|
||||
charsCaptured: totalCharsCaptured,
|
||||
charsAdded: totalCharsAdded,
|
||||
charsRemoved: totalCharsRemoved,
|
||||
};
|
||||
}
|
||||
|
||||
function populateDebuggerRuleList(container) {
|
||||
const rulesContainer = container.find('#regex_debugger_rules');
|
||||
const ruleTemplate = container.find('#regex_debugger_rule_template');
|
||||
if (!rulesContainer.length || !ruleTemplate.length) {
|
||||
console.error('Regex Debugger: Could not find rule list or template in the DOM.');
|
||||
return;
|
||||
}
|
||||
|
||||
rulesContainer.empty();
|
||||
|
||||
const allScripts = getRegexScripts();
|
||||
if (!allScripts || allScripts.length === 0) {
|
||||
rulesContainer.append('<div class="regex-debugger-no-rules">No regex rules found.</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
const globalScriptIds = new Set((extension_settings.regex ?? []).map(s => s.id));
|
||||
const globalScripts = [];
|
||||
const scopedScripts = [];
|
||||
|
||||
allScripts.forEach(script => {
|
||||
const scriptCopy = structuredClone(script); // Use structuredClone for deep copy
|
||||
if (globalScriptIds.has(script.id)) {
|
||||
// @ts-ignore
|
||||
scriptCopy.isScoped = false;
|
||||
globalScripts.push(scriptCopy);
|
||||
} else {
|
||||
// @ts-ignore
|
||||
scriptCopy.isScoped = true;
|
||||
scopedScripts.push(scriptCopy);
|
||||
}
|
||||
});
|
||||
|
||||
container.data('allScripts', [...globalScripts, ...scopedScripts]);
|
||||
|
||||
const renderRule = (script) => {
|
||||
if (!script.id) script.id = uuidv4();
|
||||
const ruleElementContent = $(ruleTemplate.prop('content')).clone();
|
||||
const ruleElement = ruleElementContent.find('.regex-debugger-rule');
|
||||
|
||||
ruleElement.attr('data-id', script.id);
|
||||
// @ts-ignore
|
||||
ruleElement.find('.rule-name').text(script.scriptName);
|
||||
ruleElement.find('.rule-regex').text(script.findRegex);
|
||||
// @ts-ignore
|
||||
ruleElement.find('.rule-scope').text(script.isScoped ? 'Scoped' : 'Global');
|
||||
ruleElement.find('.rule-enabled').prop('checked', !script.disabled);
|
||||
// @ts-ignore
|
||||
ruleElement.find('.edit_rule').on('click', () => onRegexEditorOpenClick(script.id, script.isScoped));
|
||||
|
||||
ruleElement.on('click', function (event) {
|
||||
if ($(event.target).is('input, .menu_button, .menu_button i')) {
|
||||
return;
|
||||
}
|
||||
const scriptId = $(this).data('id');
|
||||
const stepElement = $(`#step-result-${scriptId}`);
|
||||
const container = $('#regex_debugger_steps_output');
|
||||
|
||||
if (stepElement.length && container.length) {
|
||||
// Replace scrollIntoView with scrollTop animation
|
||||
const targetTop = stepElement.position().top;
|
||||
const containerScrollTop = container.scrollTop();
|
||||
const containerHeight = container.height();
|
||||
|
||||
// Center the element if possible
|
||||
let scrollTo = containerScrollTop + targetTop - (containerHeight / 2) + (stepElement.height() / 2);
|
||||
|
||||
container.animate({ scrollTop: scrollTo }, 300); // 300ms smooth scroll
|
||||
|
||||
stepElement.css('transition', 'background-color 0.5s').css('background-color', 'var(--highlight_color)');
|
||||
setTimeout(() => stepElement.css('background-color', ''), 1000);
|
||||
}
|
||||
});
|
||||
|
||||
return ruleElementContent;
|
||||
};
|
||||
|
||||
if (globalScripts.length > 0) {
|
||||
rulesContainer.append('<div class="list-header regex-debugger-list-header">Global Rules</div>');
|
||||
const globalList = $('<ul id="regex_debugger_rules_global" class="sortable-list"></ul>');
|
||||
globalScripts.forEach(script => globalList.append(renderRule(script)));
|
||||
rulesContainer.append(globalList);
|
||||
}
|
||||
|
||||
if (scopedScripts.length > 0) {
|
||||
rulesContainer.append('<div class="list-header regex-debugger-list-header">Scoped Rules</div>');
|
||||
const scopedList = $('<ul id="regex_debugger_rules_scoped" class="sortable-list"></ul>');
|
||||
scopedScripts.forEach(script => scopedList.append(renderRule(script)));
|
||||
rulesContainer.append(scopedList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the regex debugger.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function onRegexDebuggerOpenClick() {
|
||||
const templateContent = await renderExtensionTemplateAsync('regex', 'debugger');
|
||||
const debuggerHtml = $('<div>').html(templateContent);
|
||||
|
||||
const stepTemplate = debuggerHtml.find('#regex_debugger_step_template');
|
||||
|
||||
populateDebuggerRuleList(debuggerHtml);
|
||||
|
||||
// @ts-ignore
|
||||
debuggerHtml.find('#regex_debugger_rules_global').sortable({ delay: getSortableDelay() }).disableSelection();
|
||||
// @ts-ignore
|
||||
debuggerHtml.find('#regex_debugger_rules_scoped').sortable({ delay: getSortableDelay() }).disableSelection();
|
||||
|
||||
debuggerHtml.find('#regex_debugger_run_test').on('click', function () {
|
||||
const allScripts = debuggerHtml.data('allScripts');
|
||||
const orderedRuleIds = [
|
||||
...$('#regex_debugger_rules_global').find('li.regex-debugger-rule').map((i, el) => $(el).data('id')).get(),
|
||||
...$('#regex_debugger_rules_scoped').find('li.regex-debugger-rule').map((i, el) => $(el).data('id')).get(),
|
||||
];
|
||||
|
||||
const rawInput = String($('#regex_debugger_raw_input').val());
|
||||
const stepsOutput = $('#regex_debugger_steps_output');
|
||||
const finalOutput = $('#regex_debugger_final_output');
|
||||
|
||||
if (!stepsOutput.length || !finalOutput.length) return;
|
||||
|
||||
const displayMode = $('input[name="display_mode"]:checked').val();
|
||||
stepsOutput.empty();
|
||||
finalOutput.empty();
|
||||
$('#regex_debugger_final_summary').remove();
|
||||
|
||||
if (!allScripts) return;
|
||||
let textForNextStep = rawInput;
|
||||
let totalCharsCaptured = 0;
|
||||
let totalCharsAdded = 0;
|
||||
let totalCharsRemoved = 0;
|
||||
|
||||
orderedRuleIds.forEach(scriptId => {
|
||||
const ruleElement = $(`#regex_debugger_rules [data-id="${scriptId}"]`);
|
||||
if (!ruleElement.find('.rule-enabled').is(':checked')) return;
|
||||
|
||||
const script = allScripts.find(s => s.id === scriptId);
|
||||
|
||||
if (script) {
|
||||
const result = executeRegexScriptForDebugging(script, textForNextStep);
|
||||
totalCharsCaptured += result.charsCaptured;
|
||||
totalCharsAdded += result.charsAdded;
|
||||
totalCharsRemoved += result.charsRemoved;
|
||||
|
||||
const stepElement = $(stepTemplate.prop('content')).clone();
|
||||
// Set the ID on the TOP-LEVEL element that is being appended.
|
||||
stepElement.find('>:first-child').attr('id', `step-result-${script.id}`);
|
||||
const stepHeader = stepElement.find('.step-header');
|
||||
stepHeader.find('strong').text(`After: ${script.scriptName}`);
|
||||
|
||||
const metricsHtml = `<span class="step-metrics">Captured: ${result.charsCaptured}, Added: +${result.charsAdded}, Removed: -${result.charsRemoved}</span>`;
|
||||
stepHeader.append(metricsHtml);
|
||||
|
||||
if (displayMode === 'highlight') {
|
||||
stepElement.find('.step-output').html(result.highlightedOutput);
|
||||
} else {
|
||||
stepElement.find('.step-output').text(result.output);
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
stepHeader.append($(`<div class='warning_text text_rose-500'>${result.error}</div>`));
|
||||
}
|
||||
|
||||
stepsOutput.append(stepElement);
|
||||
textForNextStep = result.output;
|
||||
}
|
||||
});
|
||||
|
||||
const summaryHtml = `
|
||||
<div id="regex_debugger_final_summary" class="regex-debugger-summary">
|
||||
<strong>Total Captured:</strong> ${totalCharsCaptured} | <strong>Total Added:</strong> +${totalCharsAdded} | <strong>Total Removed:</strong> -${totalCharsRemoved}
|
||||
</div>
|
||||
`;
|
||||
finalOutput.before(summaryHtml);
|
||||
|
||||
const renderMode = $('#regex_debugger_render_mode').val();
|
||||
if (renderMode === 'message') {
|
||||
const formattedHtml = messageFormatting(textForNextStep, 'Debugger', true, false, null);
|
||||
const messageBlock = $('<div class="mes"><div class="mes_text"></div></div>');
|
||||
messageBlock.find('.mes_text').html(formattedHtml);
|
||||
finalOutput.append(messageBlock);
|
||||
} else {
|
||||
finalOutput.text(textForNextStep);
|
||||
}
|
||||
});
|
||||
|
||||
debuggerHtml.find('#regex_debugger_save_order').on('click', async function () {
|
||||
const allKnownScripts = getRegexScripts();
|
||||
const newGlobalScripts = $('#regex_debugger_rules_global').children('li').map((_, el) => allKnownScripts.find(s => s.id === $(el).data('id'))).get().filter(Boolean);
|
||||
const newScopedScripts = $('#regex_debugger_rules_scoped').children('li').map((_, el) => allKnownScripts.find(s => s.id === $(el).data('id'))).get().filter(Boolean);
|
||||
|
||||
extension_settings.regex = newGlobalScripts;
|
||||
if (this_chid !== undefined) {
|
||||
await writeExtensionField(this_chid, 'regex_scripts', newScopedScripts);
|
||||
}
|
||||
|
||||
saveSettingsDebounced();
|
||||
await loadRegexScripts();
|
||||
toastr.success(t`Regex script order saved!`);
|
||||
|
||||
const currentPopupContent = $('div:has(> #regex_debugger_rules)');
|
||||
populateDebuggerRuleList(currentPopupContent);
|
||||
// @ts-ignore
|
||||
currentPopupContent.find('#regex_debugger_rules_global').sortable({ delay: getSortableDelay() }).disableSelection();
|
||||
// @ts-ignore
|
||||
currentPopupContent.find('#regex_debugger_rules_scoped').sortable({ delay: getSortableDelay() }).disableSelection();
|
||||
});
|
||||
|
||||
debuggerHtml.find('#regex_debugger_expand_steps').on('click', function () {
|
||||
const popupContainer = $('<div class="expanded-regex-container"></div>');
|
||||
const navPanel = $('<div class="expanded-regex-nav"><h4>Steps</h4></div>');
|
||||
const contentPanel = $('<div class="expanded-regex-content"></div>');
|
||||
|
||||
const content = $('#regex_debugger_steps_output').clone().html();
|
||||
contentPanel.html(content);
|
||||
|
||||
$('#regex_debugger_rules .regex-debugger-rule').each(function () {
|
||||
const ruleElement = $(this);
|
||||
const scriptId = ruleElement.data('id');
|
||||
const scriptName = ruleElement.find('.rule-name').text();
|
||||
|
||||
const link = $(`<a href="#">${escapeHtml(scriptName)}</a>`);
|
||||
link.data('target-id', `step-result-${scriptId}`);
|
||||
|
||||
link.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
navPanel.find('a').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
const targetId = $(this).data('target-id');
|
||||
// The selector is now correct for the structure.
|
||||
const targetElement = contentPanel.find(`#${targetId}`);
|
||||
|
||||
if (targetElement.length) {
|
||||
const scrollTo = contentPanel.scrollTop() + targetElement.position().top;
|
||||
contentPanel.animate({ scrollTop: scrollTo }, 300);
|
||||
|
||||
targetElement.css('transition', 'background-color 0.5s').css('background-color', 'var(--highlight_color)');
|
||||
setTimeout(() => targetElement.css('background-color', ''), 1000);
|
||||
}
|
||||
});
|
||||
|
||||
navPanel.append(link);
|
||||
});
|
||||
|
||||
popupContainer.append(navPanel).append(contentPanel);
|
||||
callGenericPopup(popupContainer, POPUP_TYPE.TEXT, 'Step-by-step Transformation', { wide: true, allowVerticalScrolling: false });
|
||||
});
|
||||
|
||||
debuggerHtml.find('#regex_debugger_expand_final').on('click', function () {
|
||||
const content = $('#regex_debugger_final_output').html();
|
||||
const popupContent = $('<div class="regex-popup-content"></div>').html(content);
|
||||
callGenericPopup(popupContent, POPUP_TYPE.TEXT, 'Final Output', { wide: true, large: true, allowVerticalScrolling: true });
|
||||
});
|
||||
|
||||
await callGenericPopup(debuggerHtml.children(), POPUP_TYPE.TEXT, '', { wide: true, allowVerticalScrolling: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the info block in the regex editor with hints regarding the find regex.
|
||||
* @param {JQuery<HTMLElement>} editorHtml The editor HTML
|
||||
@@ -592,8 +1479,12 @@ async function checkEmbeddedRegexScripts() {
|
||||
// Workaround for loading in sequence with other extensions
|
||||
// NOTE: Always puts extension at the top of the list, but this is fine since it's static
|
||||
jQuery(async () => {
|
||||
if (extension_settings.regex) {
|
||||
migrateSettings();
|
||||
if (!Array.isArray(extension_settings.regex)) {
|
||||
extension_settings.regex = [];
|
||||
}
|
||||
|
||||
if (!Array.isArray(extension_settings.regex_presets)) {
|
||||
extension_settings.regex_presets = [];
|
||||
}
|
||||
|
||||
// Manually disable the extension since static imports auto-import the JS file
|
||||
@@ -601,11 +1492,14 @@ jQuery(async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
migrateSettings();
|
||||
|
||||
const settingsHtml = $(await renderExtensionTemplateAsync('regex', 'dropdown'));
|
||||
$('#regex_container').append(settingsHtml);
|
||||
$('#open_regex_editor').on('click', function () {
|
||||
onRegexEditorOpenClick(false, false);
|
||||
});
|
||||
$('#open_regex_debugger').on('click', onRegexDebuggerOpenClick);
|
||||
$('#open_scoped_editor').on('click', function () {
|
||||
if (this_chid === undefined) {
|
||||
toastr.error(t`No character selected.`);
|
||||
@@ -726,6 +1620,7 @@ jQuery(async () => {
|
||||
},
|
||||
];
|
||||
for (const { selector, setter, getter } of sortableDatas) {
|
||||
// @ts-ignore
|
||||
$(selector).sortable({
|
||||
delay: getSortableDelay(),
|
||||
stop: async function () {
|
||||
@@ -778,6 +1673,7 @@ jQuery(async () => {
|
||||
});
|
||||
|
||||
await loadRegexScripts();
|
||||
// @ts-ignore
|
||||
$('#saved_regex_scripts').sortable('enable');
|
||||
|
||||
const localEnumProviders = {
|
||||
@@ -856,4 +1752,7 @@ jQuery(async () => {
|
||||
|
||||
eventSource.on(event_types.CHAT_CHANGED, checkEmbeddedRegexScripts);
|
||||
eventSource.on(event_types.CHARACTER_DELETED, purgeEmbeddedRegexScripts);
|
||||
|
||||
presetManager.setupEventListeners();
|
||||
presetManager.registerSlashCommands();
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@import "debugger.css";
|
||||
|
||||
.regex_settings .menu_button {
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
@@ -39,19 +41,19 @@
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.enable_scoped:checked ~ .regex-toggle-on {
|
||||
.enable_scoped:checked~.regex-toggle-on {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.enable_scoped:checked ~ .regex-toggle-off {
|
||||
.enable_scoped:checked~.regex-toggle-off {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.enable_scoped:not(:checked) ~ .regex-toggle-on {
|
||||
.enable_scoped:not(:checked)~.regex-toggle-on {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.enable_scoped:not(:checked) ~ .regex-toggle-off {
|
||||
.enable_scoped:not(:checked)~.regex-toggle-off {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -90,19 +92,19 @@ input.enable_scoped {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disable_regex:checked ~ .regex-toggle-off {
|
||||
.disable_regex:checked~.regex-toggle-off {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.disable_regex:checked ~ .regex-toggle-on {
|
||||
.disable_regex:checked~.regex-toggle-on {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.disable_regex:not(:checked) ~ .regex-toggle-off {
|
||||
.disable_regex:not(:checked)~.regex-toggle-off {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.disable_regex:not(:checked) ~ .regex-toggle-on {
|
||||
.disable_regex:not(:checked)~.regex-toggle-on {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,6 @@ export async function getMultimodalCaption(base64Img, prompt) {
|
||||
|
||||
throwIfInvalidModel(useReverseProxy);
|
||||
|
||||
const noPrefix = ['ollama'].includes(extension_settings.caption.multimodal_api);
|
||||
|
||||
if (noPrefix && base64Img.startsWith('data:image/')) {
|
||||
base64Img = base64Img.split(',')[1];
|
||||
}
|
||||
|
||||
// OpenRouter has a payload limit of ~2MB. Google is 4MB, but we love democracy.
|
||||
// Ooba requires all images to be JPEGs. Koboldcpp just asked nicely.
|
||||
const isOllama = extension_settings.caption.multimodal_api === 'ollama';
|
||||
@@ -47,6 +41,9 @@ export async function getMultimodalCaption(base64Img, prompt) {
|
||||
} else if (!safeMimeTypes.includes(mimeType)) {
|
||||
base64Img = await createThumbnail(base64Img, null, null);
|
||||
}
|
||||
if (isOllama && base64Img.startsWith('data:image/')) {
|
||||
base64Img = base64Img.split(',')[1];
|
||||
}
|
||||
|
||||
const proxyUrl = useReverseProxy ? oai_settings.reverse_proxy : '';
|
||||
const proxyPassword = useReverseProxy ? oai_settings.proxy_password : '';
|
||||
@@ -72,6 +69,10 @@ export async function getMultimodalCaption(base64Img, prompt) {
|
||||
requestBody.model = textgenerationwebui_settings.ollama_model;
|
||||
}
|
||||
|
||||
if (extension_settings.caption.multimodal_model === 'ollama_custom') {
|
||||
requestBody.model = extension_settings.caption.ollama_custom_model;
|
||||
}
|
||||
|
||||
requestBody.server_url = extension_settings.caption.alt_endpoint_enabled
|
||||
? extension_settings.caption.alt_endpoint_url
|
||||
: textgenerationwebui_settings.server_urls[textgen_types.OLLAMA];
|
||||
@@ -211,6 +212,10 @@ function throwIfInvalidModel(useReverseProxy) {
|
||||
throw new Error('Ollama model is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'ollama' && multimodalModel === 'ollama_custom' && !extension_settings.caption.ollama_custom_model) {
|
||||
throw new Error('Ollama custom model tag is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'llamacpp' && !textgenerationwebui_settings.server_urls[textgen_types.LLAMACPP] && !altEndpointEnabled) {
|
||||
throw new Error('LlamaCPP server URL is not set.');
|
||||
}
|
||||
@@ -242,6 +247,14 @@ function throwIfInvalidModel(useReverseProxy) {
|
||||
if (multimodalApi === 'moonshot' && !secret_state[SECRET_KEYS.MOONSHOT]) {
|
||||
throw new Error('Moonshot AI API key is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'nanogpt' && !secret_state[SECRET_KEYS.NANOGPT]) {
|
||||
throw new Error('NanoGPT API key is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'electronhub' && !secret_state[SECRET_KEYS.ELECTRONHUB]) {
|
||||
throw new Error('Electron Hub API key is not set.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ import { callGenericPopup, Popup, POPUP_TYPE } from '../../popup.js';
|
||||
import { commonEnumProviders } from '../../slash-commands/SlashCommandCommonEnumsProvider.js';
|
||||
import { ToolManager } from '../../tool-calling.js';
|
||||
import { MacrosParser } from '../../macros.js';
|
||||
import { t } from '../../i18n.js';
|
||||
import { t, translate } from '../../i18n.js';
|
||||
import { oai_settings } from '../../openai.js';
|
||||
|
||||
export { MODULE_NAME };
|
||||
@@ -82,6 +82,7 @@ const sources = {
|
||||
pollinations: 'pollinations',
|
||||
stability: 'stability',
|
||||
huggingface: 'huggingface',
|
||||
electronhub: 'electronhub',
|
||||
nanogpt: 'nanogpt',
|
||||
bfl: 'bfl',
|
||||
falai: 'falai',
|
||||
@@ -650,7 +651,7 @@ async function onDeleteStyleClick() {
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = await callGenericPopup(`Are you sure you want to delete the style "${selectedStyle}"?`, POPUP_TYPE.CONFIRM, '', { okButton: 'Delete', cancelButton: 'Cancel' });
|
||||
const confirmed = await callGenericPopup(t`Are you sure you want to delete the style "${selectedStyle}"?`, POPUP_TYPE.CONFIRM, '', { okButton: 'Delete', cancelButton: 'Cancel' });
|
||||
|
||||
if (!confirmed) {
|
||||
return;
|
||||
@@ -925,16 +926,16 @@ function onADetailerFaceChange() {
|
||||
}
|
||||
|
||||
const resolutionOptions = {
|
||||
sd_res_512x512: { width: 512, height: 512, name: '512x512 (1:1, icons, profile pictures)' },
|
||||
sd_res_600x600: { width: 600, height: 600, name: '600x600 (1:1, icons, profile pictures)' },
|
||||
sd_res_512x768: { width: 512, height: 768, name: '512x768 (2:3, vertical character card)' },
|
||||
sd_res_768x512: { width: 768, height: 512, name: '768x512 (3:2, horizontal 35-mm movie film)' },
|
||||
sd_res_960x540: { width: 960, height: 540, name: '960x540 (16:9, horizontal wallpaper)' },
|
||||
sd_res_540x960: { width: 540, height: 960, name: '540x960 (9:16, vertical wallpaper)' },
|
||||
sd_res_1920x1088: { width: 1920, height: 1088, name: '1920x1088 (16:9, 1080p, horizontal wallpaper)' },
|
||||
sd_res_1088x1920: { width: 1088, height: 1920, name: '1088x1920 (9:16, 1080p, vertical wallpaper)' },
|
||||
sd_res_1280x720: { width: 1280, height: 720, name: '1280x720 (16:9, 720p, horizontal wallpaper)' },
|
||||
sd_res_720x1280: { width: 720, height: 1280, name: '720x1280 (9:16, 720p, vertical wallpaper)' },
|
||||
sd_res_512x512: { width: 512, height: 512, name: translate('512x512 (1:1, icons, profile pictures)', 'sd_res_512x512') },
|
||||
sd_res_600x600: { width: 600, height: 600, name: translate('600x600 (1:1, icons, profile pictures)', 'sd_res_600x600') },
|
||||
sd_res_512x768: { width: 512, height: 768, name: translate('512x768 (2:3, vertical character card)', 'sd_res_512x768') },
|
||||
sd_res_768x512: { width: 768, height: 512, name: translate('768x512 (3:2, horizontal 35-mm movie film)', 'sd_res_768x512') },
|
||||
sd_res_960x540: { width: 960, height: 540, name: translate('960x540 (16:9, horizontal wallpaper)', 'sd_res_960x540') },
|
||||
sd_res_540x960: { width: 540, height: 960, name: translate('540x960 (9:16, vertical wallpaper)', 'sd_res_540x960') },
|
||||
sd_res_1920x1088: { width: 1920, height: 1088, name: translate('1920x1088 (16:9, 1080p, horizontal wallpaper)', 'sd_res_1920x1088') },
|
||||
sd_res_1088x1920: { width: 1088, height: 1920, name: translate('1088x1920 (9:16, 1080p, vertical wallpaper)', 'sd_res_1088x1920') },
|
||||
sd_res_1280x720: { width: 1280, height: 720, name: translate('1280x720 (16:9, 720p, horizontal wallpaper)', 'sd_res_1280x720') },
|
||||
sd_res_720x1280: { width: 720, height: 1280, name: translate('720x1280 (9:16, 720p, vertical wallpaper)', 'sd_res_720x1280') },
|
||||
sd_res_1024x1024: { width: 1024, height: 1024, name: '1024x1024 (1:1, SDXL)' },
|
||||
sd_res_1152x896: { width: 1152, height: 896, name: '1152x896 (9:7, SDXL)' },
|
||||
sd_res_896x1152: { width: 896, height: 1152, name: '896x1152 (7:9, SDXL)' },
|
||||
@@ -1289,6 +1290,7 @@ async function onModelChange() {
|
||||
sources.pollinations,
|
||||
sources.stability,
|
||||
sources.huggingface,
|
||||
sources.electronhub,
|
||||
sources.nanogpt,
|
||||
sources.bfl,
|
||||
sources.falai,
|
||||
@@ -1506,6 +1508,9 @@ async function loadSamplers() {
|
||||
case sources.huggingface:
|
||||
samplers = ['N/A'];
|
||||
break;
|
||||
case sources.electronhub:
|
||||
samplers = ['N/A'];
|
||||
break;
|
||||
case sources.nanogpt:
|
||||
samplers = ['N/A'];
|
||||
break;
|
||||
@@ -1702,6 +1707,9 @@ async function loadModels() {
|
||||
case sources.huggingface:
|
||||
models = [{ value: '', text: '<Enter Model ID above>' }];
|
||||
break;
|
||||
case sources.electronhub:
|
||||
models = await loadElectronHubModels();
|
||||
break;
|
||||
case sources.nanogpt:
|
||||
models = await loadNanoGPTModels();
|
||||
break;
|
||||
@@ -1806,6 +1814,24 @@ async function loadTogetherAIModels() {
|
||||
return [];
|
||||
}
|
||||
|
||||
async function loadElectronHubModels() {
|
||||
if (!secret_state[SECRET_KEYS.ELECTRONHUB]) {
|
||||
console.debug('Electron Hub API key is not set.');
|
||||
return [];
|
||||
}
|
||||
|
||||
const result = await fetch('/api/sd/electronhub/models', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
});
|
||||
|
||||
if (result.ok) {
|
||||
return await result.json();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
async function loadNanoGPTModels() {
|
||||
if (!secret_state[SECRET_KEYS.NANOGPT]) {
|
||||
console.debug('NanoGPT API key is not set.');
|
||||
@@ -2131,6 +2157,9 @@ async function loadSchedulers() {
|
||||
case sources.huggingface:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
case sources.electronhub:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
case sources.nanogpt:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
@@ -2228,6 +2257,9 @@ async function loadVaes() {
|
||||
case sources.huggingface:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
case sources.electronhub:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
case sources.nanogpt:
|
||||
vaes = ['N/A'];
|
||||
break;
|
||||
@@ -2811,6 +2843,9 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
|
||||
case sources.huggingface:
|
||||
result = await generateHuggingFaceImage(prefixedPrompt, signal);
|
||||
break;
|
||||
case sources.electronhub:
|
||||
result = await generateElectronHubImage(prefixedPrompt, signal);
|
||||
break;
|
||||
case sources.nanogpt:
|
||||
result = await generateNanoGPTImage(prefixedPrompt, negativePrompt, signal);
|
||||
break;
|
||||
@@ -3013,6 +3048,56 @@ function getClosestAspectRatio(width, height, source) {
|
||||
return closestAspectRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get closest size for Electron Hub
|
||||
* @param {number} width - The width of the image
|
||||
* @param {number} height - The height of the image
|
||||
* @returns {Promise<string>} - The closest size
|
||||
*/
|
||||
async function getClosestSize(width, height) {
|
||||
const response = await fetch('/api/sd/electronhub/sizes', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({
|
||||
model: extension_settings.sd.model,
|
||||
}),
|
||||
});
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
throw new Error(text);
|
||||
}
|
||||
const result = await response.json();
|
||||
const sizesData = result.sizes;
|
||||
|
||||
const closestSize = sizesData.reduce((closest, size) => {
|
||||
if (!size || typeof size !== 'string') {
|
||||
return closest;
|
||||
}
|
||||
const sizeParts = size.split('x');
|
||||
if (sizeParts.length !== 2) {
|
||||
return closest;
|
||||
}
|
||||
|
||||
const sizeWidth = Number(sizeParts[0]);
|
||||
const sizeHeight = Number(sizeParts[1]);
|
||||
const targetWidth = Number(width);
|
||||
const targetHeight = Number(height);
|
||||
|
||||
if (isNaN(sizeWidth) || isNaN(sizeHeight) || isNaN(targetWidth) || isNaN(targetHeight)) {
|
||||
return closest;
|
||||
}
|
||||
|
||||
const sizeArea = sizeWidth * sizeHeight;
|
||||
const targetArea = targetWidth * targetHeight;
|
||||
const diff = Math.abs(sizeArea - targetArea);
|
||||
|
||||
return diff < closest.diff ? { size, diff } : closest;
|
||||
}, { size: null, diff: Infinity });
|
||||
|
||||
const size = closestSize.size;
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image using Stability AI.
|
||||
* @param {string} prompt - The main instruction used to guide the image generation.
|
||||
@@ -3564,6 +3649,35 @@ async function generateHuggingFaceImage(prompt, signal) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image using the Electron Hub API.
|
||||
* @param {string} prompt - The main instruction 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 generateElectronHubImage(prompt, signal) {
|
||||
const size = await getClosestSize(extension_settings.sd.width, extension_settings.sd.height);
|
||||
|
||||
const result = await fetch('/api/sd/electronhub/generate', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
signal: signal,
|
||||
body: JSON.stringify({
|
||||
model: extension_settings.sd.model,
|
||||
prompt: prompt,
|
||||
size: size,
|
||||
}),
|
||||
});
|
||||
|
||||
if (result.ok) {
|
||||
const data = await result.json();
|
||||
return { format: 'jpg', data: data.image };
|
||||
} else {
|
||||
const text = await result.text();
|
||||
throw new Error(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image using the NanoGPT API.
|
||||
* @param {string} prompt - The main instruction used to guide the image generation.
|
||||
@@ -3847,7 +3961,7 @@ async function onComfyNewWorkflowClick() {
|
||||
}
|
||||
|
||||
async function onComfyDeleteWorkflowClick() {
|
||||
const confirm = await callGenericPopup('Delete the workflow? This action is irreversible.', POPUP_TYPE.CONFIRM, '', { okButton: 'Delete', cancelButton: 'Cancel' });
|
||||
const confirm = await callGenericPopup(t`Delete the workflow? This action is irreversible.`, POPUP_TYPE.CONFIRM, '', { okButton: t`Delete`, cancelButton: t`Cancel` });
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
@@ -4014,6 +4128,8 @@ function isValidState() {
|
||||
return secret_state[SECRET_KEYS.STABILITY];
|
||||
case sources.huggingface:
|
||||
return secret_state[SECRET_KEYS.HUGGINGFACE];
|
||||
case sources.electronhub:
|
||||
return secret_state[SECRET_KEYS.ELECTRONHUB];
|
||||
case sources.nanogpt:
|
||||
return secret_state[SECRET_KEYS.NANOGPT];
|
||||
case sources.bfl:
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<option value="bfl">BFL (Black Forest Labs)</option>
|
||||
<option value="comfy">ComfyUI</option>
|
||||
<option value="drawthings">DrawThings HTTP API</option>
|
||||
<option value="electronhub">Electron Hub</option>
|
||||
<option value="extras">Extras API (deprecated)</option>
|
||||
<option value="falai">FAL.AI</option>
|
||||
<option value="google">Google AI</option>
|
||||
@@ -93,6 +94,9 @@
|
||||
<label for="sd_huggingface_model_id" data-i18n="Model ID">Model ID</label>
|
||||
<input id="sd_huggingface_model_id" type="text" class="text_pole" data-i18n="[placeholder]e.g. black-forest-labs/FLUX.1-dev" placeholder="e.g. black-forest-labs/FLUX.1-dev" value="" />
|
||||
</div>
|
||||
<div data-sd-source="electronhub">
|
||||
<i>Hint: Save an API key in the Electron Hub (Chat Completion) API settings to use it here.</i>
|
||||
</div>
|
||||
<div data-sd-source="nanogpt">
|
||||
<i>Hint: Save an API key in the NanoGPT (Chat Completion) API settings to use it here.</i>
|
||||
</div>
|
||||
@@ -260,7 +264,7 @@
|
||||
<span data-i18n="Click to set">Click to set</span>
|
||||
</div>
|
||||
</div>
|
||||
<label class="checkbox_label marginBot5" for="sd_bfl_upsampling" title="Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation.">
|
||||
<label class="checkbox_label marginBot5" for="sd_bfl_upsampling" data-i18n="[title]Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation." title="Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation.">
|
||||
<input id="sd_bfl_upsampling" type="checkbox" />
|
||||
<span data-i18n="Prompt Upsampling">
|
||||
Prompt Upsampling
|
||||
|
||||
@@ -182,9 +182,11 @@ function isGeneratingSwipe(messageId) {
|
||||
return $(`#chat .mes[mesid="${messageId}"] .mes_text`).text() === '...';
|
||||
}
|
||||
|
||||
async function translateImpersonate(text) {
|
||||
async function translateImpersonate() {
|
||||
const sendTextArea = $('#send_textarea');
|
||||
const text = sendTextArea.val().toString();
|
||||
const translatedText = await translate(text, extension_settings.translate.target_language);
|
||||
$('#send_textarea').val(translatedText);
|
||||
sendTextArea.val(translatedText);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -637,11 +637,8 @@ async function processTtsQueue() {
|
||||
}
|
||||
|
||||
if (extension_settings.tts.narrate_quoted_only) {
|
||||
const special_quotes = /[“”«»「」『』""]/g; // Extend this regex to include other special quotes
|
||||
text = text.replace(special_quotes, '"');
|
||||
const matches = text.match(/".*?"/g); // Matches text inside double quotes, non-greedily
|
||||
const partJoiner = (ttsProvider?.separator || ' ... ');
|
||||
text = matches ? matches.join(partJoiner) : text;
|
||||
text = joinQuotedBlocks(text, { separator: partJoiner, includeQuotes: true });
|
||||
}
|
||||
|
||||
// Remove embedded images
|
||||
@@ -702,6 +699,82 @@ async function processTtsQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and join quoted blocks with proper matching pairs and nesting.
|
||||
* - Captures outermost quotes and everything inside (including different inner quote styles).
|
||||
* - Requires matching opener/closer style (e.g., “ ... ”, 「 ... 」, « ... », etc.).
|
||||
* - Ignores incomplete/unclosed quotes (doesn't include them in the result).
|
||||
* - Symmetric quotes like "..." and "..." are supported (not nesting the same symmetric style).
|
||||
*
|
||||
* @param {string} text - The text to process
|
||||
* @param {object} [opts={}] - Optional options object
|
||||
* @param {string} [opts.separator=' ... '] - String to join multiple quoted blocks
|
||||
* @param {boolean} [opts.includeQuotes=true] - Keep the quote chars around the captured text
|
||||
* @param {boolean} [opts.returnEmptyOnNoQuotes=false] - Return an empty string if no quotes are found
|
||||
* @param {Array<[string,string]>} [opts.pairs] - Custom quote pairs; defaults cover EN/DE/FR/JP
|
||||
* @returns {string} The joined quoted blocks, or the original text if no quotes found
|
||||
*/
|
||||
function joinQuotedBlocks(text, opts = {}) {
|
||||
const {
|
||||
separator = ' ... ',
|
||||
includeQuotes = true,
|
||||
returnEmptyOnNoQuotes = false,
|
||||
pairs = [
|
||||
// typographic doubles
|
||||
['„', '“'], // DE low-high
|
||||
['“', '”'], // EN
|
||||
['«', '»'], // FR open « close »
|
||||
['»', '«'], // Some locales open »
|
||||
// typographic singles
|
||||
['‘', '’'],
|
||||
['‚', '‘'],
|
||||
// Japanese corner quotes
|
||||
['「', '」'],
|
||||
['『', '』'],
|
||||
// symmetric doubles
|
||||
['"', '"'],
|
||||
['"', '"'],
|
||||
],
|
||||
} = opts;
|
||||
|
||||
if (!text || typeof text !== 'string') return text;
|
||||
|
||||
const openToClose = Object.fromEntries(pairs);
|
||||
|
||||
const segments = [];
|
||||
const stack = []; // [{ opener, expectedClose, start }]
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
const ch = text[i];
|
||||
const top = stack[stack.length - 1];
|
||||
|
||||
// Prefer closing the current open pair if the char matches its expected closer
|
||||
if (top && ch === top.expectedClose) {
|
||||
const finished = stack.pop();
|
||||
if (stack.length === 0) {
|
||||
// Only collect outermost quotes (contains all nested content)
|
||||
segments.push(text.slice(finished.start, i + 1));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, see if this is a new opener
|
||||
if (openToClose[ch]) {
|
||||
stack.push({ opener: ch, expectedClose: openToClose[ch], start: i });
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a stray closer that doesn't match current top, ignore
|
||||
}
|
||||
|
||||
if (!segments.length) return returnEmptyOnNoQuotes ? '' : text;
|
||||
|
||||
const cleaned = includeQuotes
|
||||
? segments
|
||||
: segments.map(s => s.slice(1, -1)); // all defined pairs are single-char quotes
|
||||
|
||||
return cleaned.join(separator);
|
||||
}
|
||||
|
||||
async function playFullConversation() {
|
||||
resetTtsPlayback();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ const interactableSelectors = [
|
||||
'.avatar-container', // Persona list blocks
|
||||
'.tag .tag_remove', // Remove button in removable tags
|
||||
'.bg_example', // Background elements in the background menu
|
||||
'.bg_example .bg_button', // The inline buttons on the backgrounds
|
||||
'.bg_example .jg-button, .bg_example .mobile-only-menu-toggle', // The inline buttons on the backgrounds
|
||||
'#options a', // Option entries in the popup options menu
|
||||
'.mes_buttons .mes_button', // Small inline buttons on the chat messages
|
||||
'.extraMesButtons>div:not(.mes_button)', // The extra/extension buttons inline on the chat messages
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { initAccessibility } from './a11y.js';
|
||||
|
||||
/**
|
||||
* CRSF token for requests.
|
||||
*/
|
||||
@@ -265,6 +267,8 @@ function configureDiscreetLogin() {
|
||||
}
|
||||
|
||||
(async function () {
|
||||
initAccessibility();
|
||||
|
||||
csrfToken = await getCsrfToken();
|
||||
const userList = await getUserList();
|
||||
|
||||
|
||||
+303
-59
@@ -179,6 +179,7 @@ export const chat_completion_sources = {
|
||||
COHERE: 'cohere',
|
||||
PERPLEXITY: 'perplexity',
|
||||
GROQ: 'groq',
|
||||
ELECTRONHUB: 'electronhub',
|
||||
NANOGPT: 'nanogpt',
|
||||
DEEPSEEK: 'deepseek',
|
||||
AIMLAPI: 'aimlapi',
|
||||
@@ -187,6 +188,7 @@ export const chat_completion_sources = {
|
||||
MOONSHOT: 'moonshot',
|
||||
FIREWORKS: 'fireworks',
|
||||
COMETAPI: 'cometapi',
|
||||
AZURE_OPENAI: 'azure_openai',
|
||||
};
|
||||
|
||||
const character_names_behavior = {
|
||||
@@ -240,6 +242,8 @@ const sensitiveFields = [
|
||||
'custom_include_headers',
|
||||
'vertexai_region',
|
||||
'vertexai_express_project_id',
|
||||
'azure_base_url',
|
||||
'azure_deployment_name',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -271,6 +275,7 @@ export const settingsToUpdate = {
|
||||
cohere_model: ['#model_cohere_select', 'cohere_model', false, true],
|
||||
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false, true],
|
||||
groq_model: ['#model_groq_select', 'groq_model', false, true],
|
||||
electronhub_model: ['#model_electronhub_select', 'electronhub_model', false, true],
|
||||
nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false, true],
|
||||
deepseek_model: ['#model_deepseek_select', 'deepseek_model', false, true],
|
||||
aimlapi_model: ['#model_aimlapi_select', 'aimlapi_model', false, true],
|
||||
@@ -329,6 +334,10 @@ export const settingsToUpdate = {
|
||||
n: ['#n_openai', 'n', false, false],
|
||||
bypass_status_check: ['#openai_bypass_status_check', 'bypass_status_check', true, true],
|
||||
request_images: ['#openai_request_images', 'request_images', true, false],
|
||||
azure_base_url: ['#azure_base_url', 'azure_base_url', false, true],
|
||||
azure_deployment_name: ['#azure_deployment_name', 'azure_deployment_name', false, true],
|
||||
azure_api_version: ['#azure_api_version', 'azure_api_version', false, true],
|
||||
azure_openai_model: ['#azure_openai_model', 'azure_openai_model', false, true],
|
||||
extensions: ['#NULL_SELECTOR', 'extensions', false, false],
|
||||
};
|
||||
|
||||
@@ -369,6 +378,7 @@ const default_settings = {
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'sonar-pro',
|
||||
groq_model: 'llama-3.3-70b-versatile',
|
||||
electronhub_model: 'gpt-4o-mini',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
deepseek_model: 'deepseek-chat',
|
||||
aimlapi_model: 'gpt-4o-mini-2024-07-18',
|
||||
@@ -377,6 +387,10 @@ const default_settings = {
|
||||
cometapi_model: 'gpt-4o',
|
||||
moonshot_model: 'kimi-latest',
|
||||
fireworks_model: 'accounts/fireworks/models/kimi-k2-instruct',
|
||||
azure_base_url: '',
|
||||
azure_deployment_name: '',
|
||||
azure_api_version: '2024-02-15-preview',
|
||||
azure_openai_model: '',
|
||||
custom_model: '',
|
||||
custom_url: '',
|
||||
custom_include_body: '',
|
||||
@@ -458,6 +472,7 @@ const oai_settings = {
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'sonar-pro',
|
||||
groq_model: 'llama-3.1-70b-versatile',
|
||||
electronhub_model: 'gpt-4o-mini',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
deepseek_model: 'deepseek-chat',
|
||||
aimlapi_model: 'gpt-4-turbo',
|
||||
@@ -466,6 +481,10 @@ const oai_settings = {
|
||||
cometapi_model: 'gpt-4o',
|
||||
moonshot_model: 'kimi-latest',
|
||||
fireworks_model: 'accounts/fireworks/models/kimi-k2-instruct',
|
||||
azure_base_url: '',
|
||||
azure_deployment_name: '',
|
||||
azure_api_version: '2024-02-15-preview',
|
||||
azure_openai_model: '',
|
||||
custom_model: '',
|
||||
custom_url: '',
|
||||
custom_include_body: '',
|
||||
@@ -905,7 +924,6 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul
|
||||
|
||||
// Insert chat messages as long as there is budget available
|
||||
const chatPool = [...messages].reverse();
|
||||
const firstNonInjected = chatPool.find(x => !x.injected);
|
||||
for (let index = 0; index < chatPool.length; index++) {
|
||||
const chatPrompt = chatPool[index];
|
||||
|
||||
@@ -946,22 +964,6 @@ async function populateChatHistory(messages, prompts, chatCompletion, type = nul
|
||||
}
|
||||
|
||||
if (chatCompletion.canAfford(chatMessage)) {
|
||||
if (type === 'continue' && oai_settings.continue_prefill && chatPrompt === firstNonInjected) {
|
||||
// in case we are using continue_prefill and the latest message is an assistant message, we want to prepend the users assistant prefill on the message
|
||||
if (chatPrompt.role === 'assistant') {
|
||||
const supportsAssistantPrefill = oai_settings.chat_completion_source === chat_completion_sources.CLAUDE;
|
||||
const assistantPrefill = supportsAssistantPrefill ? substituteParams(oai_settings.assistant_prefill) : '';
|
||||
const messageContent = [assistantPrefill, chatMessage.content].filter(x => x).join('\n\n');
|
||||
const continueMessage = await Message.createAsync(chatMessage.role, messageContent, chatMessage.identifier);
|
||||
const collection = new MessageCollection('continuePrefill', continueMessage);
|
||||
chatCompletion.add(collection, -1);
|
||||
continue;
|
||||
}
|
||||
const collection = new MessageCollection('continuePrefill', chatMessage);
|
||||
chatCompletion.add(collection, -1);
|
||||
continue;
|
||||
}
|
||||
|
||||
chatCompletion.insertAtStart(chatMessage, 'chatHistory');
|
||||
} else {
|
||||
break;
|
||||
@@ -1221,6 +1223,21 @@ async function populateChatCompletion(prompts, chatCompletion, { bias, quietProm
|
||||
chatCompletion.reserveBudget(toolTokens);
|
||||
}
|
||||
|
||||
// Displace the message to be continued from its original position before performing in-chat injections
|
||||
// In case if it is an assistant message, we want to prepend the users assistant prefill on the message
|
||||
if (type === 'continue' && oai_settings.continue_prefill && messages.length) {
|
||||
const chatMessage = messages.shift();
|
||||
const isAssistantRole = chatMessage.role === 'assistant';
|
||||
const supportsAssistantPrefill = oai_settings.chat_completion_source === chat_completion_sources.CLAUDE;
|
||||
const namesInCompletion = oai_settings.names_behavior === character_names_behavior.COMPLETION;
|
||||
const assistantPrefill = isAssistantRole && supportsAssistantPrefill ? substituteParams(oai_settings.assistant_prefill) : '';
|
||||
const messageContent = [assistantPrefill, chatMessage.content].filter(x => x).join('\n\n');
|
||||
const continueMessage = await Message.createAsync(chatMessage.role, messageContent, 'continuePrefill');
|
||||
chatMessage.name && namesInCompletion && await continueMessage.setName(promptManager.sanitizeName(chatMessage.name));
|
||||
controlPrompts.add(continueMessage);
|
||||
chatCompletion.reserveBudget(continueMessage);
|
||||
}
|
||||
|
||||
// Add in-chat injections
|
||||
messages = await populationInjectionPrompts(absolutePrompts, messages);
|
||||
|
||||
@@ -1544,6 +1561,11 @@ export function tryParseStreamingError(response, decoded, { quiet = false } = {}
|
||||
!quiet && toastr.error(data.message, 'Chat Completion API');
|
||||
throw new Error(data);
|
||||
}
|
||||
|
||||
if (data.detail) {
|
||||
!quiet && toastr.error(data.detail?.error?.message || response.statusText, 'Chat Completion API');
|
||||
throw new Error(data);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// No JSON. Do nothing.
|
||||
@@ -1616,6 +1638,8 @@ export function getChatCompletionModel(source = null) {
|
||||
return oai_settings.perplexity_model;
|
||||
case chat_completion_sources.GROQ:
|
||||
return oai_settings.groq_model;
|
||||
case chat_completion_sources.ELECTRONHUB:
|
||||
return oai_settings.electronhub_model;
|
||||
case chat_completion_sources.NANOGPT:
|
||||
return oai_settings.nanogpt_model;
|
||||
case chat_completion_sources.DEEPSEEK:
|
||||
@@ -1632,6 +1656,8 @@ export function getChatCompletionModel(source = null) {
|
||||
return oai_settings.moonshot_model;
|
||||
case chat_completion_sources.FIREWORKS:
|
||||
return oai_settings.fireworks_model;
|
||||
case chat_completion_sources.AZURE_OPENAI:
|
||||
return oai_settings.azure_openai_model;
|
||||
default:
|
||||
console.error(`Unknown chat completion source: ${activeSource}`);
|
||||
return '';
|
||||
@@ -1776,6 +1802,26 @@ function saveModelList(data) {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB) {
|
||||
$('#model_electronhub_select').empty();
|
||||
model_list.forEach((model) => {
|
||||
if (model?.endpoints?.includes('/v1/chat/completions')) {
|
||||
$('#model_electronhub_select').append(
|
||||
$('<option>', {
|
||||
value: model.id,
|
||||
text: model.name,
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
const selectedModel = model_list.find(model => model.id === oai_settings.electronhub_model);
|
||||
if (model_list.length > 0 && (!selectedModel || !oai_settings.electronhub_model)) {
|
||||
oai_settings.electronhub_model = model_list[0].id;
|
||||
}
|
||||
|
||||
$('#model_electronhub_select').val(oai_settings.electronhub_model).trigger('change');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
$('#model_nanogpt_select').empty();
|
||||
model_list.forEach((model) => {
|
||||
@@ -1928,6 +1974,16 @@ function saveModelList(data) {
|
||||
|
||||
$('#model_cometapi_select').val(oai_settings.cometapi_model).trigger('change');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI) {
|
||||
const modelId = model_list?.[0]?.id || '';
|
||||
oai_settings.azure_openai_model = modelId;
|
||||
|
||||
$('#azure_openai_model')
|
||||
.empty()
|
||||
.append(new Option(modelId || 'None', modelId || '', true, true))
|
||||
.trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
|
||||
@@ -2039,6 +2095,7 @@ function getReasoningEffort() {
|
||||
// These sources expect the effort as string.
|
||||
const reasoningEffortSources = [
|
||||
chat_completion_sources.OPENAI,
|
||||
chat_completion_sources.AZURE_OPENAI,
|
||||
chat_completion_sources.CUSTOM,
|
||||
chat_completion_sources.XAI,
|
||||
chat_completion_sources.AIMLAPI,
|
||||
@@ -2046,24 +2103,43 @@ function getReasoningEffort() {
|
||||
chat_completion_sources.POLLINATIONS,
|
||||
chat_completion_sources.PERPLEXITY,
|
||||
chat_completion_sources.COMETAPI,
|
||||
chat_completion_sources.ELECTRONHUB,
|
||||
];
|
||||
|
||||
if (!reasoningEffortSources.includes(oai_settings.chat_completion_source)) {
|
||||
return oai_settings.reasoning_effort;
|
||||
}
|
||||
|
||||
switch (oai_settings.reasoning_effort) {
|
||||
case reasoning_effort_types.auto:
|
||||
return undefined;
|
||||
case reasoning_effort_types.min:
|
||||
return chat_completion_sources.OPENAI === oai_settings.chat_completion_source && /^gpt-5/.test(oai_settings.openai_model)
|
||||
? reasoning_effort_types.min
|
||||
: reasoning_effort_types.low;
|
||||
case reasoning_effort_types.max:
|
||||
return reasoning_effort_types.high;
|
||||
default:
|
||||
return oai_settings.reasoning_effort;
|
||||
function resolveReasoningEffort() {
|
||||
switch (oai_settings.reasoning_effort) {
|
||||
case reasoning_effort_types.auto:
|
||||
return undefined;
|
||||
case reasoning_effort_types.min:
|
||||
return [chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(oai_settings.chat_completion_source) && /^gpt-5/.test(getChatCompletionModel())
|
||||
? reasoning_effort_types.min
|
||||
: reasoning_effort_types.low;
|
||||
case reasoning_effort_types.max:
|
||||
return reasoning_effort_types.high;
|
||||
default:
|
||||
return oai_settings.reasoning_effort;
|
||||
}
|
||||
}
|
||||
|
||||
const reasoningEffort = resolveReasoningEffort();
|
||||
|
||||
// Check if the resolved effort supported by the model
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.ELECTRONHUB) {
|
||||
if (Array.isArray(model_list) && reasoningEffort) {
|
||||
const currentModel = model_list.find(m => m.id === oai_settings.electronhub_model);
|
||||
const supportedEfforts = currentModel?.metadata?.supported_reasoning_efforts;
|
||||
if (Array.isArray(supportedEfforts) && supportedEfforts.includes(reasoningEffort)) {
|
||||
return reasoningEffort;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return reasoningEffort;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2102,18 +2178,20 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
const isGroq = oai_settings.chat_completion_source == chat_completion_sources.GROQ;
|
||||
const isDeepSeek = oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK;
|
||||
const isAimlapi = oai_settings.chat_completion_source == chat_completion_sources.AIMLAPI;
|
||||
const isElectronHub = oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB;
|
||||
const isXAI = oai_settings.chat_completion_source == chat_completion_sources.XAI;
|
||||
const isPollinations = oai_settings.chat_completion_source == chat_completion_sources.POLLINATIONS;
|
||||
const isMoonshot = oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT;
|
||||
const isAzureOpenAI = oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI; // Add this line
|
||||
const isTextCompletion = isOAI && textCompletionModels.includes(oai_settings.openai_model);
|
||||
const isQuiet = type === 'quiet';
|
||||
const isImpersonate = type === 'impersonate';
|
||||
const isContinue = type === 'continue';
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !(isOAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model));
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !((isOAI || isAzureOpenAI) && ['o1-2024-12-17', 'o1'].includes(getChatCompletionModel()));
|
||||
const useLogprobs = !!power_user.request_token_probabilities;
|
||||
const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom || isXAI || isAimlapi || isMoonshot);
|
||||
const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isAzureOpenAI || isCustom || isXAI || isAimlapi || isMoonshot);
|
||||
|
||||
const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.CUSTOM];
|
||||
const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.CUSTOM];
|
||||
if (oai_settings.bias_preset_selected
|
||||
&& logitBiasSources.includes(oai_settings.chat_completion_source)
|
||||
&& Array.isArray(oai_settings.bias_presets[oai_settings.bias_preset_selected])
|
||||
@@ -2151,6 +2229,16 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
'custom_prompt_post_processing': oai_settings.custom_prompt_post_processing,
|
||||
};
|
||||
|
||||
if (isAzureOpenAI) {
|
||||
generate_data.azure_base_url = oai_settings.azure_base_url;
|
||||
generate_data.azure_deployment_name = oai_settings.azure_deployment_name;
|
||||
generate_data.azure_api_version = oai_settings.azure_api_version;
|
||||
// Reasoning effort is not supported on some Azure models (e.g. GPT-3.x, GPT-4.x)
|
||||
if (/^gpt-[34]/.test(oai_settings.azure_openai_model)) {
|
||||
delete generate_data.reasoning_effort;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
||||
await ToolManager.registerFunctionToolsOpenAI(generate_data);
|
||||
}
|
||||
@@ -2168,18 +2256,18 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
}
|
||||
|
||||
// Add logprobs request (currently OpenAI only, max 5 on their side)
|
||||
if (useLogprobs && (isOAI || isCustom || isDeepSeek || isXAI || isAimlapi)) {
|
||||
if (useLogprobs && (isOAI || isAzureOpenAI || isCustom || isDeepSeek || isXAI || isAimlapi)) {
|
||||
generate_data['logprobs'] = 5;
|
||||
}
|
||||
|
||||
// Remove logit bias/logprobs/stop-strings if not supported by the model
|
||||
const isVision = (m) => ['gpt', 'vision'].every(x => m.includes(x));
|
||||
if (isOAI && isVision(oai_settings.openai_model) || isOpenRouter && isVision(oai_settings.openrouter_model)) {
|
||||
if ((isOAI && isVision(oai_settings.openai_model)) || (isAzureOpenAI && isVision(oai_settings.azure_openai_model)) || (isOpenRouter && isVision(oai_settings.openrouter_model))) {
|
||||
delete generate_data.logit_bias;
|
||||
delete generate_data.stop;
|
||||
delete generate_data.logprobs;
|
||||
}
|
||||
if (isOAI && oai_settings.openai_model.includes('gpt-4.5') || isOpenRouter && oai_settings.openrouter_model.includes('gpt-4.5')) {
|
||||
if ((isOAI && oai_settings.openai_model.includes('gpt-4.5')) || (isAzureOpenAI && oai_settings.azure_openai_model.includes('gpt-4.5')) || (isOpenRouter && oai_settings.openrouter_model.includes('gpt-4.5'))) {
|
||||
delete generate_data.logprobs;
|
||||
}
|
||||
|
||||
@@ -2262,16 +2350,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
// https://api-docs.deepseek.com/api/create-chat-completion
|
||||
if (isDeepSeek) {
|
||||
generate_data.top_p = generate_data.top_p || Number.EPSILON;
|
||||
|
||||
if (generate_data.model.endsWith('-reasoner')) {
|
||||
delete generate_data.top_p;
|
||||
delete generate_data.temperature;
|
||||
delete generate_data.frequency_penalty;
|
||||
delete generate_data.presence_penalty;
|
||||
delete generate_data.top_logprobs;
|
||||
delete generate_data.logprobs;
|
||||
delete generate_data.logit_bias;
|
||||
}
|
||||
}
|
||||
|
||||
if (isXAI) {
|
||||
@@ -2295,13 +2373,20 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
delete generate_data.max_tokens;
|
||||
}
|
||||
|
||||
// https://docs.electronhub.ai/api-reference/chat/completions
|
||||
if (isElectronHub) {
|
||||
generate_data['top_k'] = Number(oai_settings.top_k_openai);
|
||||
}
|
||||
|
||||
const seedSupportedSources = [
|
||||
chat_completion_sources.OPENAI,
|
||||
chat_completion_sources.AZURE_OPENAI,
|
||||
chat_completion_sources.OPENROUTER,
|
||||
chat_completion_sources.MISTRALAI,
|
||||
chat_completion_sources.CUSTOM,
|
||||
chat_completion_sources.COHERE,
|
||||
chat_completion_sources.GROQ,
|
||||
chat_completion_sources.ELECTRONHUB,
|
||||
chat_completion_sources.NANOGPT,
|
||||
chat_completion_sources.XAI,
|
||||
chat_completion_sources.POLLINATIONS,
|
||||
@@ -2313,7 +2398,7 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
generate_data['seed'] = oai_settings.seed;
|
||||
}
|
||||
|
||||
if (isOAI && /^(o1|o3|o4)/.test(oai_settings.openai_model)) {
|
||||
if ((isOAI && /^(o1|o3|o4)/.test(oai_settings.openai_model)) || (isAzureOpenAI && /^(o1|o3|o4)/.test(oai_settings.azure_openai_model))) {
|
||||
generate_data.max_completion_tokens = generate_data.max_tokens;
|
||||
delete generate_data.max_tokens;
|
||||
delete generate_data.logprobs;
|
||||
@@ -2336,7 +2421,7 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
}
|
||||
}
|
||||
|
||||
if (isOAI && /^gpt-5/.test(oai_settings.openai_model)) {
|
||||
if ((isOAI && /^gpt-5/.test(oai_settings.openai_model)) || (isAzureOpenAI && /^gpt-5/.test(oai_settings.azure_openai_model))) {
|
||||
generate_data.max_completion_tokens = generate_data.max_tokens;
|
||||
delete generate_data.max_tokens;
|
||||
delete generate_data.logprobs;
|
||||
@@ -2466,11 +2551,15 @@ export function getStreamingReply(data, state, { chatCompletionSource = null, ov
|
||||
}
|
||||
return data.choices?.[0]?.delta?.content || '';
|
||||
} else if (chat_completion_source === chat_completion_sources.OPENROUTER) {
|
||||
const imageUrl = data?.choices?.[0]?.delta?.images?.find(x => x.type === 'image_url')?.image_url?.url;
|
||||
if (imageUrl) {
|
||||
state.image = imageUrl;
|
||||
}
|
||||
if (show_thoughts) {
|
||||
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 ([chat_completion_sources.CUSTOM, chat_completion_sources.POLLINATIONS, chat_completion_sources.AIMLAPI, chat_completion_sources.MOONSHOT, chat_completion_sources.COMETAPI].includes(chat_completion_source)) {
|
||||
} else if ([chat_completion_sources.CUSTOM, chat_completion_sources.POLLINATIONS, chat_completion_sources.AIMLAPI, chat_completion_sources.MOONSHOT, chat_completion_sources.COMETAPI, chat_completion_sources.ELECTRONHUB].includes(chat_completion_source)) {
|
||||
if (show_thoughts) {
|
||||
state.reasoning +=
|
||||
data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
|
||||
@@ -2502,6 +2591,7 @@ function parseChatCompletionLogprobs(data) {
|
||||
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
case chat_completion_sources.OPENAI:
|
||||
case chat_completion_sources.AZURE_OPENAI:
|
||||
case chat_completion_sources.DEEPSEEK:
|
||||
case chat_completion_sources.XAI:
|
||||
case chat_completion_sources.CUSTOM:
|
||||
@@ -2510,7 +2600,7 @@ function parseChatCompletionLogprobs(data) {
|
||||
}
|
||||
// OpenAI Text Completion API is treated as a chat completion source
|
||||
// by SillyTavern, hence its presence in this function.
|
||||
return textCompletionModels.includes(oai_settings.openai_model)
|
||||
return textCompletionModels.includes(getChatCompletionModel())
|
||||
? parseOpenAITextLogprobs(data.choices[0]?.logprobs)
|
||||
: parseOpenAIChatLogprobs(data.choices[0]?.logprobs);
|
||||
default:
|
||||
@@ -3432,6 +3522,7 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.cohere_model = settings.cohere_model ?? default_settings.cohere_model;
|
||||
oai_settings.perplexity_model = settings.perplexity_model ?? default_settings.perplexity_model;
|
||||
oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model;
|
||||
oai_settings.electronhub_model = settings.electronhub_model ?? default_settings.electronhub_model;
|
||||
oai_settings.nanogpt_model = settings.nanogpt_model ?? default_settings.nanogpt_model;
|
||||
oai_settings.deepseek_model = settings.deepseek_model ?? default_settings.deepseek_model;
|
||||
oai_settings.aimlapi_model = settings.aimlapi_model ?? default_settings.aimlapi_model;
|
||||
@@ -3447,6 +3538,10 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.custom_include_headers = settings.custom_include_headers ?? default_settings.custom_include_headers;
|
||||
oai_settings.custom_prompt_post_processing = settings.custom_prompt_post_processing ?? default_settings.custom_prompt_post_processing;
|
||||
oai_settings.google_model = settings.google_model ?? default_settings.google_model;
|
||||
oai_settings.azure_base_url = settings.azure_base_url ?? default_settings.azure_base_url;
|
||||
oai_settings.azure_deployment_name = settings.azure_deployment_name ?? default_settings.azure_deployment_name;
|
||||
oai_settings.azure_api_version = settings.azure_api_version ?? default_settings.azure_api_version;
|
||||
oai_settings.azure_openai_model = settings.azure_openai_model ?? default_settings.azure_openai_model;
|
||||
oai_settings.vertexai_model = settings.vertexai_model ?? default_settings.vertexai_model;
|
||||
oai_settings.chat_completion_source = settings.chat_completion_source ?? default_settings.chat_completion_source;
|
||||
oai_settings.show_external_models = settings.show_external_models ?? default_settings.show_external_models;
|
||||
@@ -3527,6 +3622,8 @@ function loadOpenAISettings(data, settings) {
|
||||
$(`#model_perplexity_select option[value="${oai_settings.perplexity_model}"`).prop('selected', true);
|
||||
$('#model_groq_select').val(oai_settings.groq_model);
|
||||
$(`#model_groq_select option[value="${oai_settings.groq_model}"`).prop('selected', true);
|
||||
$('#model_electronhub_select').val(oai_settings.electronhub_model);
|
||||
$(`#model_electronhub_select option[value="${oai_settings.electronhub_model}"`).prop('selected', true);
|
||||
$('#model_nanogpt_select').val(oai_settings.nanogpt_model);
|
||||
$(`#model_nanogpt_select option[value="${oai_settings.nanogpt_model}"`).prop('selected', true);
|
||||
$('#model_deepseek_select').val(oai_settings.deepseek_model);
|
||||
@@ -3541,6 +3638,11 @@ function loadOpenAISettings(data, settings) {
|
||||
$(`#model_moonshot_select option[value="${oai_settings.moonshot_model}"`).prop('selected', true);
|
||||
$('#custom_model_id').val(oai_settings.custom_model);
|
||||
$('#custom_api_url_text').val(oai_settings.custom_url);
|
||||
$('#azure_base_url').val(oai_settings.azure_base_url);
|
||||
$('#azure_deployment_name').val(oai_settings.azure_deployment_name);
|
||||
$('#azure_api_version').val(oai_settings.azure_api_version);
|
||||
$('#azure_openai_model').val(oai_settings.azure_openai_model);
|
||||
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context);
|
||||
$('#openai_max_context_counter').val(`${oai_settings.openai_max_context}`);
|
||||
$('#model_openrouter_select').val(oai_settings.openrouter_model);
|
||||
@@ -3719,6 +3821,12 @@ async function getStatusOpen() {
|
||||
return resultCheckStatus();
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.AZURE_OPENAI && !isValidUrl(oai_settings.azure_base_url)) {
|
||||
console.debug('Invalid endpoint URL of Azure OpenAI API:', oai_settings.azure_base_url);
|
||||
setOnlineStatus(t`Invalid Azure endpoint URL. Requests may fail.`);
|
||||
return resultCheckStatus();
|
||||
}
|
||||
|
||||
let data = {
|
||||
reverse_proxy: oai_settings.reverse_proxy,
|
||||
proxy_password: oai_settings.proxy_password,
|
||||
@@ -3744,6 +3852,12 @@ async function getStatusOpen() {
|
||||
data.custom_include_headers = oai_settings.custom_include_headers;
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.AZURE_OPENAI) {
|
||||
data.azure_base_url = oai_settings.azure_base_url;
|
||||
data.azure_deployment_name = oai_settings.azure_deployment_name;
|
||||
data.azure_api_version = oai_settings.azure_api_version;
|
||||
}
|
||||
|
||||
const canBypass = (oai_settings.chat_completion_source === chat_completion_sources.OPENAI && oai_settings.bypass_status_check) || oai_settings.chat_completion_source === chat_completion_sources.CUSTOM;
|
||||
if (canBypass) {
|
||||
setOnlineStatus(t`Status check bypassed`);
|
||||
@@ -3813,6 +3927,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
xai_model: settings.xai_model,
|
||||
pollinations_model: settings.pollinations_model,
|
||||
aimlapi_model: settings.aimlapi_model,
|
||||
electronhub_model: settings.electronhub_model,
|
||||
moonshot_model: settings.moonshot_model,
|
||||
fireworks_model: settings.fireworks_model,
|
||||
cometapi_model: settings.cometapi_model,
|
||||
@@ -3824,6 +3939,10 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
custom_prompt_post_processing: settings.custom_prompt_post_processing,
|
||||
google_model: settings.google_model,
|
||||
vertexai_model: settings.vertexai_model,
|
||||
azure_base_url: settings.azure_base_url,
|
||||
azure_deployment_name: settings.azure_deployment_name,
|
||||
azure_api_version: settings.azure_api_version,
|
||||
azure_openai_model: settings.azure_openai_model,
|
||||
temperature: settings.temp_openai,
|
||||
frequency_penalty: settings.freq_pen_openai,
|
||||
presence_penalty: settings.pres_pen_openai,
|
||||
@@ -4578,6 +4697,47 @@ function getFireworksMaxContext(model, isUnlocked) {
|
||||
return max_32k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum context size for the ElectronHub model
|
||||
* @param {string} model Model identifier
|
||||
* @param {boolean} isUnlocked Whether context limits are unlocked
|
||||
* @returns {number} Maximum context size in tokens
|
||||
*/
|
||||
function getElectronHubMaxContext(model, isUnlocked) {
|
||||
if (isUnlocked) {
|
||||
return unlocked_max;
|
||||
}
|
||||
|
||||
if (Array.isArray(model_list)) {
|
||||
const modelInfo = model_list.find(m => m.id === model);
|
||||
if (modelInfo?.tokens) {
|
||||
return modelInfo.tokens;
|
||||
}
|
||||
}
|
||||
return max_8k;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum context size for the NanoGPT model
|
||||
* @param {string} model Model identifier
|
||||
* @param {boolean} isUnlocked Whether context limits are unlocked
|
||||
* @returns {number} Maximum context size in tokens
|
||||
*/
|
||||
function getNanoGptMaxContext(model, isUnlocked) {
|
||||
if (isUnlocked) {
|
||||
return unlocked_max;
|
||||
}
|
||||
|
||||
if (Array.isArray(model_list)) {
|
||||
const modelInfo = model_list.find(m => m.id === model);
|
||||
if (modelInfo?.context_length) {
|
||||
return modelInfo.context_length;
|
||||
}
|
||||
}
|
||||
|
||||
return max_128k;
|
||||
}
|
||||
|
||||
async function onModelChange() {
|
||||
biasCache = undefined;
|
||||
let value = String($(this).val() || '');
|
||||
@@ -4668,6 +4828,15 @@ async function onModelChange() {
|
||||
oai_settings.groq_model = value;
|
||||
}
|
||||
|
||||
if ($(this).is('#model_electronhub_select')) {
|
||||
if (!value) {
|
||||
console.debug('Null ElectronHub model selected. Ignoring.');
|
||||
return;
|
||||
}
|
||||
console.log('ElectronHub model changed to', value);
|
||||
oai_settings.electronhub_model = value;
|
||||
}
|
||||
|
||||
if ($(this).is('#model_nanogpt_select')) {
|
||||
if (!value) {
|
||||
console.debug('Null NanoGPT model selected. Ignoring.');
|
||||
@@ -4736,11 +4905,21 @@ async function onModelChange() {
|
||||
oai_settings.cometapi_model = value;
|
||||
}
|
||||
|
||||
if ($(this).is('#azure_openai_model')) {
|
||||
if (!value) {
|
||||
console.debug('Null Azure OpenAI model selected. Ignoring.');
|
||||
return;
|
||||
}
|
||||
oai_settings.azure_openai_model = value;
|
||||
}
|
||||
|
||||
if ([chat_completion_sources.MAKERSUITE, chat_completion_sources.VERTEXAI].includes(oai_settings.chat_completion_source)) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', max_2mil);
|
||||
} else if (value.includes('gemini-1.5-pro')) {
|
||||
$('#openai_max_context').attr('max', max_2mil);
|
||||
} else if (value.includes('gemini-2.5-flash-image-preview')) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash') || value.includes('gemini-2.0-pro') || value.includes('gemini-exp') || value.includes('gemini-2.5-flash') || value.includes('gemini-2.5-pro') || value.includes('learnlm-2.0-flash')) {
|
||||
$('#openai_max_context').attr('max', max_1mil);
|
||||
} else if (value.includes('gemma-3-27b-it')) {
|
||||
@@ -4808,7 +4987,7 @@ async function onModelChange() {
|
||||
$('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.OPENAI) {
|
||||
if ([chat_completion_sources.AZURE_OPENAI, chat_completion_sources.OPENAI].includes(oai_settings.chat_completion_source)) {
|
||||
$('#openai_max_context').attr('max', getMaxContextOpenAI(value));
|
||||
oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
@@ -4907,15 +5086,21 @@ async function onModelChange() {
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB) {
|
||||
const maxContext = getElectronHubMaxContext(oai_settings.electronhub_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);
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) {
|
||||
const maxContext = getNanoGptMaxContext(oai_settings.nanogpt_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);
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
@@ -5204,6 +5389,19 @@ async function onConnectButtonClick(e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB) {
|
||||
const api_key_electronhub = String($('#api_key_electronhub').val()).trim();
|
||||
|
||||
if (api_key_electronhub.length) {
|
||||
await writeSecret(SECRET_KEYS.ELECTRONHUB, api_key_electronhub);
|
||||
}
|
||||
|
||||
if (!secret_state[SECRET_KEYS.ELECTRONHUB]) {
|
||||
console.log('No secret key saved for Electron Hub');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
const api_key_nanogpt = String($('#api_key_nanogpt').val()).trim();
|
||||
|
||||
@@ -5295,6 +5493,20 @@ async function onConnectButtonClick(e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI) {
|
||||
const api_key_azure_openai = String($('#api_key_azure_openai').val()).trim();
|
||||
|
||||
if (api_key_azure_openai.length) {
|
||||
await writeSecret(SECRET_KEYS.AZURE_OPENAI, api_key_azure_openai);
|
||||
}
|
||||
|
||||
if (!api_key_azure_openai && !secret_state[SECRET_KEYS.AZURE_OPENAI]) {
|
||||
console.log('No secret key saved for Azure OpenAI');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
startStatusLoading();
|
||||
saveSettingsDebounced();
|
||||
await getStatusOpen();
|
||||
@@ -5338,6 +5550,9 @@ function toggleChatCompletionForms() {
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
|
||||
$('#model_groq_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.ELECTRONHUB) {
|
||||
$('#model_electronhub_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
$('#model_nanogpt_select').trigger('change');
|
||||
}
|
||||
@@ -5365,6 +5580,9 @@ function toggleChatCompletionForms() {
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.COMETAPI) {
|
||||
$('#model_cometapi_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI) {
|
||||
$('#azure_openai_model').trigger('change');
|
||||
}
|
||||
|
||||
$('[data-source]').each(function () {
|
||||
const validSources = $(this).data('source').split(',');
|
||||
@@ -5484,10 +5702,15 @@ export function isImageInliningSupported() {
|
||||
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
case chat_completion_sources.OPENAI:
|
||||
case chat_completion_sources.AZURE_OPENAI: {
|
||||
const modelToCheck = oai_settings.chat_completion_source === chat_completion_sources.AZURE_OPENAI
|
||||
? oai_settings.azure_openai_model
|
||||
: oai_settings.openai_model;
|
||||
return visionSupportedModels.some(model =>
|
||||
oai_settings.openai_model.includes(model)
|
||||
&& ['gpt-4-turbo-preview', 'o1-mini', 'o3-mini'].some(x => !oai_settings.openai_model.includes(x)),
|
||||
modelToCheck.includes(model)
|
||||
&& ['gpt-4-turbo-preview', 'o1-mini', 'o3-mini'].some(x => !modelToCheck.includes(x)),
|
||||
);
|
||||
}
|
||||
case chat_completion_sources.MAKERSUITE:
|
||||
return visionSupportedModels.some(model => oai_settings.google_model.includes(model));
|
||||
case chat_completion_sources.VERTEXAI:
|
||||
@@ -5495,7 +5718,7 @@ export function isImageInliningSupported() {
|
||||
case chat_completion_sources.CLAUDE:
|
||||
return visionSupportedModels.some(model => oai_settings.claude_model.includes(model));
|
||||
case chat_completion_sources.OPENROUTER:
|
||||
return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.openrouter_model)?.architecture?.modality === 'text+image->text');
|
||||
return (Array.isArray(model_list) && ['text+image->text+image', 'text+image->text'].includes(model_list.find(m => m.id === oai_settings.openrouter_model)?.architecture?.modality));
|
||||
case chat_completion_sources.CUSTOM:
|
||||
return true;
|
||||
case chat_completion_sources.MISTRALAI:
|
||||
@@ -5506,12 +5729,16 @@ export function isImageInliningSupported() {
|
||||
return visionSupportedModels.some(model => oai_settings.xai_model.includes(model));
|
||||
case chat_completion_sources.AIMLAPI:
|
||||
return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.aimlapi_model)?.features?.includes('openai/chat-completion.vision'));
|
||||
case chat_completion_sources.ELECTRONHUB:
|
||||
return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.electronhub_model)?.metadata?.vision);
|
||||
case chat_completion_sources.POLLINATIONS:
|
||||
return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.pollinations_model)?.vision);
|
||||
case chat_completion_sources.COMETAPI:
|
||||
return true;
|
||||
case chat_completion_sources.MOONSHOT:
|
||||
return visionSupportedModels.some(model => oai_settings.moonshot_model.includes(model));
|
||||
case chat_completion_sources.NANOGPT:
|
||||
return (Array.isArray(model_list) && model_list.find(m => m.id === oai_settings.nanogpt_model)?.capabilities?.vision);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -6164,6 +6391,21 @@ export function initOpenAI() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#azure_base_url').on('input', function () {
|
||||
oai_settings.azure_base_url = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#azure_deployment_name').on('input', function () {
|
||||
oai_settings.azure_deployment_name = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#azure_api_version').on('input change', function () {
|
||||
oai_settings.azure_api_version = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#character_names_none').on('input', function () {
|
||||
oai_settings.names_behavior = character_names_behavior.NONE;
|
||||
setNamesBehaviorControls();
|
||||
@@ -6312,6 +6554,7 @@ export function initOpenAI() {
|
||||
$('#model_cohere_select').on('change', onModelChange);
|
||||
$('#model_perplexity_select').on('change', onModelChange);
|
||||
$('#model_groq_select').on('change', onModelChange);
|
||||
$('#model_electronhub_select').on('change', onModelChange);
|
||||
$('#model_nanogpt_select').on('change', onModelChange);
|
||||
$('#model_deepseek_select').on('change', onModelChange);
|
||||
$('#model_aimlapi_select').on('change', onModelChange);
|
||||
@@ -6321,6 +6564,7 @@ export function initOpenAI() {
|
||||
$('#model_cometapi_select').on('change', onModelChange);
|
||||
$('#model_moonshot_select').on('change', onModelChange);
|
||||
$('#model_fireworks_select').on('change', onModelChange);
|
||||
$('#azure_openai_model').on('change', onModelChange);
|
||||
$('#settings_preset_openai').on('change', onSettingsPresetChange);
|
||||
$('#new_oai_preset').on('click', onNewPresetClick);
|
||||
$('#delete_oai_preset').on('click', onDeletePresetClick);
|
||||
|
||||
@@ -1348,6 +1348,29 @@ function registerReasoningAppEvents() {
|
||||
for (const event of [event_types.GENERATION_STOPPED, event_types.GENERATION_ENDED, event_types.CHAT_CHANGED]) {
|
||||
eventSource.on(event, () => PromptReasoning.clearLatest());
|
||||
}
|
||||
|
||||
eventSource.makeFirst(event_types.IMPERSONATE_READY, async () => {
|
||||
if (!power_user.reasoning.auto_parse) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sendTextArea = /** @type {HTMLTextAreaElement} */ (document.getElementById('send_textarea'));
|
||||
|
||||
if (!sendTextArea) {
|
||||
console.warn('[Reasoning] Send textarea not found');
|
||||
return;
|
||||
}
|
||||
|
||||
console.debug('[Reasoning] Auto-parsing reasoning block for impersonation');
|
||||
|
||||
if (!sendTextArea.value) {
|
||||
console.debug('[Reasoning] Reasoning is empty, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
sendTextArea.value = removeReasoningFromString(sendTextArea.value);
|
||||
sendTextArea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,10 +47,12 @@ export const SECRET_KEYS = {
|
||||
PERPLEXITY: 'api_key_perplexity',
|
||||
GROQ: 'api_key_groq',
|
||||
AZURE_TTS: 'api_key_azure_tts',
|
||||
AZURE_OPENAI: 'api_key_azure_openai',
|
||||
FEATHERLESS: 'api_key_featherless',
|
||||
HUGGINGFACE: 'api_key_huggingface',
|
||||
STABILITY: 'api_key_stability',
|
||||
CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts',
|
||||
ELECTRONHUB: 'api_key_electronhub',
|
||||
NANOGPT: 'api_key_nanogpt',
|
||||
TAVILY: 'api_key_tavily',
|
||||
BFL: 'api_key_bfl',
|
||||
@@ -95,6 +97,7 @@ const FRIENDLY_NAMES = {
|
||||
[SECRET_KEYS.GROQ]: 'Groq',
|
||||
[SECRET_KEYS.FEATHERLESS]: 'Featherless',
|
||||
[SECRET_KEYS.HUGGINGFACE]: 'HuggingFace',
|
||||
[SECRET_KEYS.ELECTRONHUB]: 'Electron Hub',
|
||||
[SECRET_KEYS.NANOGPT]: 'NanoGPT',
|
||||
[SECRET_KEYS.GENERIC]: 'Generic (OpenAI-compatible)',
|
||||
[SECRET_KEYS.DEEPSEEK]: 'DeepSeek',
|
||||
@@ -120,6 +123,7 @@ const FRIENDLY_NAMES = {
|
||||
[SECRET_KEYS.MINIMAX_GROUP_ID]: 'MiniMax Group ID',
|
||||
[SECRET_KEYS.MOONSHOT]: 'Moonshot AI',
|
||||
[SECRET_KEYS.COMETAPI]: 'CometAPI',
|
||||
[SECRET_KEYS.AZURE_OPENAI]: 'Azure OpenAI',
|
||||
};
|
||||
|
||||
const INPUT_MAP = {
|
||||
@@ -148,6 +152,7 @@ const INPUT_MAP = {
|
||||
[SECRET_KEYS.GROQ]: '#api_key_groq',
|
||||
[SECRET_KEYS.FEATHERLESS]: '#api_key_featherless',
|
||||
[SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface',
|
||||
[SECRET_KEYS.ELECTRONHUB]: '#api_key_electronhub',
|
||||
[SECRET_KEYS.NANOGPT]: '#api_key_nanogpt',
|
||||
[SECRET_KEYS.GENERIC]: '#api_key_generic',
|
||||
[SECRET_KEYS.DEEPSEEK]: '#api_key_deepseek',
|
||||
@@ -157,6 +162,7 @@ const INPUT_MAP = {
|
||||
[SECRET_KEYS.MOONSHOT]: '#api_key_moonshot',
|
||||
[SECRET_KEYS.FIREWORKS]: '#api_key_fireworks',
|
||||
[SECRET_KEYS.COMETAPI]: '#api_key_cometapi',
|
||||
[SECRET_KEYS.AZURE_OPENAI]: '#api_key_azure_openai',
|
||||
};
|
||||
|
||||
const getLabel = () => moment().format('L LT');
|
||||
|
||||
+504
-512
File diff suppressed because it is too large
Load Diff
@@ -7,13 +7,12 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js';
|
||||
import { SlashCommandScope } from './SlashCommandScope.js';
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* @typedef {NamedArgumentsCapture & {
|
||||
* _scope:SlashCommandScope,
|
||||
* _parserFlags:import('./SlashCommandParser.js').ParserFlags,
|
||||
* _abortController:SlashCommandAbortController,
|
||||
* _debugController:SlashCommandDebugController,
|
||||
* _hasUnnamedArgument:boolean,
|
||||
* [id:string]:string|SlashCommandClosure|(string|SlashCommandClosure)[]|undefined,
|
||||
* }} NamedArguments
|
||||
*/
|
||||
|
||||
@@ -52,7 +51,7 @@ export class SlashCommand {
|
||||
|
||||
|
||||
/**@type {string}*/ name;
|
||||
/**@type {(namedArguments:{_scope:SlashCommandScope, _abortController:SlashCommandAbortController, [id:string]:string|SlashCommandClosure}, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[])=>string|SlashCommandClosure|Promise<string|SlashCommandClosure>}*/ callback;
|
||||
/**@type {(namedArguments:NamedArguments, unnamedArguments:UnnamedArguments)=>string|SlashCommandClosure|Promise<string|SlashCommandClosure>}*/ callback;
|
||||
/**@type {string}*/ helpString;
|
||||
/**@type {boolean}*/ splitUnnamedArgument = false;
|
||||
/**@type {Number}*/ splitUnnamedArgumentCount;
|
||||
@@ -238,7 +237,7 @@ export class SlashCommand {
|
||||
const name = document.createElement('div'); {
|
||||
name.classList.add('name');
|
||||
name.classList.add('monospace');
|
||||
name.title = 'command name';
|
||||
name.title = t`Command name`;
|
||||
name.textContent = `/${key}`;
|
||||
head.append(name);
|
||||
}
|
||||
@@ -284,19 +283,19 @@ export class SlashCommand {
|
||||
const argItem = document.createElement('div'); {
|
||||
argItem.classList.add('argument');
|
||||
argItem.classList.add('namedArgument');
|
||||
argItem.title = `${arg.isRequired ? '' : 'optional '}named argument`;
|
||||
argItem.title = arg.isRequired ? t`Named argument` : t`Optional named argument`;
|
||||
if (!arg.isRequired || (arg.defaultValue ?? false)) argItem.classList.add('optional');
|
||||
if (arg.acceptsMultiple) argItem.classList.add('multiple');
|
||||
const name = document.createElement('span'); {
|
||||
name.classList.add('argument-name');
|
||||
name.title = `${argItem.title} - name`;
|
||||
name.title = t`${argItem.title} - Name`;
|
||||
name.textContent = arg.name;
|
||||
argItem.append(name);
|
||||
}
|
||||
if (arg.enumList.length > 0) {
|
||||
const enums = document.createElement('span'); {
|
||||
enums.classList.add('argument-enums');
|
||||
enums.title = `${argItem.title} - accepted values`;
|
||||
enums.title = t`${argItem.title} - Accepted values`;
|
||||
for (const e of arg.enumList) {
|
||||
const enumItem = document.createElement('span'); {
|
||||
enumItem.classList.add('argument-enum');
|
||||
@@ -309,7 +308,7 @@ export class SlashCommand {
|
||||
} else {
|
||||
const types = document.createElement('span'); {
|
||||
types.classList.add('argument-types');
|
||||
types.title = `${argItem.title} - accepted types`;
|
||||
types.title = t`${argItem.title} - Accepted types`;
|
||||
for (const t of arg.typeList) {
|
||||
const type = document.createElement('span'); {
|
||||
type.classList.add('argument-type');
|
||||
@@ -325,7 +324,7 @@ export class SlashCommand {
|
||||
if (arg.defaultValue !== null) {
|
||||
const argDefault = document.createElement('div'); {
|
||||
argDefault.classList.add('argument-default');
|
||||
argDefault.title = 'default value';
|
||||
argDefault.title = t`Default value`;
|
||||
argDefault.textContent = arg.defaultValue.toString();
|
||||
argSpec.append(argDefault);
|
||||
}
|
||||
@@ -348,13 +347,13 @@ export class SlashCommand {
|
||||
const argItem = document.createElement('div'); {
|
||||
argItem.classList.add('argument');
|
||||
argItem.classList.add('unnamedArgument');
|
||||
argItem.title = `${arg.isRequired ? '' : 'optional '}unnamed argument`;
|
||||
argItem.title = arg.isRequired ? t`Unnamed argument` : t`Optional unnamed argument`;
|
||||
if (!arg.isRequired || (arg.defaultValue ?? false)) argItem.classList.add('optional');
|
||||
if (arg.acceptsMultiple) argItem.classList.add('multiple');
|
||||
if (arg.enumList.length > 0) {
|
||||
const enums = document.createElement('span'); {
|
||||
enums.classList.add('argument-enums');
|
||||
enums.title = `${argItem.title} - accepted values`;
|
||||
enums.title = t`${argItem.title} - Accepted values`;
|
||||
for (const e of arg.enumList) {
|
||||
const enumItem = document.createElement('span'); {
|
||||
enumItem.classList.add('argument-enum');
|
||||
@@ -367,7 +366,7 @@ export class SlashCommand {
|
||||
} else {
|
||||
const types = document.createElement('span'); {
|
||||
types.classList.add('argument-types');
|
||||
types.title = `${argItem.title} - accepted types`;
|
||||
types.title = t`${argItem.title} - Accepted types`;
|
||||
for (const t of arg.typeList) {
|
||||
const type = document.createElement('span'); {
|
||||
type.classList.add('argument-type');
|
||||
@@ -383,7 +382,7 @@ export class SlashCommand {
|
||||
if (arg.defaultValue !== null) {
|
||||
const argDefault = document.createElement('div'); {
|
||||
argDefault.classList.add('argument-default');
|
||||
argDefault.title = 'default value';
|
||||
argDefault.title = t`Default value`;
|
||||
argDefault.textContent = arg.defaultValue.toString();
|
||||
argSpec.append(argDefault);
|
||||
}
|
||||
@@ -402,7 +401,7 @@ export class SlashCommand {
|
||||
}
|
||||
const returns = document.createElement('span'); {
|
||||
returns.classList.add('returns');
|
||||
returns.title = [null, undefined, 'void'].includes(returnType) ? 'command does not return anything' : 'return value';
|
||||
returns.title = [null, undefined, 'void'].includes(returnType) ? t`Command does not return anything` : t`Return value`;
|
||||
returns.textContent = returnType ?? 'void';
|
||||
body.append(returns);
|
||||
}
|
||||
@@ -415,7 +414,7 @@ export class SlashCommand {
|
||||
help.innerHTML = helpString;
|
||||
for (const code of help.querySelectorAll('pre > code')) {
|
||||
code.classList.add('language-stscript');
|
||||
hljs.highlightElement(code);
|
||||
hljs.highlightElement(/**@type {HTMLElement}*/(code));
|
||||
}
|
||||
frag.append(help);
|
||||
}
|
||||
|
||||
@@ -74,12 +74,14 @@ const OPENROUTER_PROVIDERS = [
|
||||
'NextBit',
|
||||
'Nineteen',
|
||||
'Novita',
|
||||
'Nvidia',
|
||||
'OpenAI',
|
||||
'OpenInference',
|
||||
'Parasail',
|
||||
'Perplexity',
|
||||
'Phala',
|
||||
'SambaNova',
|
||||
'SiliconFlow',
|
||||
'Stealth',
|
||||
'Switchpoint',
|
||||
'Targon',
|
||||
|
||||
@@ -586,6 +586,10 @@ export function getTokenizerModel() {
|
||||
const nemoTokenizer = 'nemo';
|
||||
const deepseekTokenizer = 'deepseek';
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.AZURE_OPENAI) {
|
||||
return oai_settings.azure_openai_model || turboTokenizer;
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) {
|
||||
return deepseekTokenizer;
|
||||
}
|
||||
|
||||
@@ -633,6 +633,13 @@ export class ToolManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.ELECTRONHUB && Array.isArray(model_list)) {
|
||||
const currentModel = model_list.find(model => model.id === oai_settings.electronhub_model);
|
||||
if (currentModel && currentModel.metadata?.function_call) {
|
||||
return currentModel.metadata.function_call;
|
||||
}
|
||||
}
|
||||
|
||||
const supportedSources = [
|
||||
chat_completion_sources.OPENAI,
|
||||
chat_completion_sources.CUSTOM,
|
||||
@@ -651,6 +658,8 @@ export class ToolManager {
|
||||
chat_completion_sources.MOONSHOT,
|
||||
chat_completion_sources.FIREWORKS,
|
||||
chat_completion_sources.COMETAPI,
|
||||
chat_completion_sources.ELECTRONHUB,
|
||||
chat_completion_sources.AZURE_OPENAI,
|
||||
];
|
||||
return supportedSources.includes(oai_settings.chat_completion_source);
|
||||
}
|
||||
|
||||
@@ -2348,21 +2348,21 @@ async function displayWorldEntries(name, data, navigation = navigation_option.no
|
||||
const entryCount = Object.keys(data.entries).length;
|
||||
const moreThan100 = entryCount > 100;
|
||||
|
||||
let content = '<span>Apply your current sorting to the "Order" field. The Order values will go down from the chosen number.</span>';
|
||||
let content = '<span>' + t`Apply your current sorting to the "Order" field. The Order values will go down from the chosen number.` + '</span>';
|
||||
if (moreThan100) {
|
||||
content += `<div class="m-t-1"><i class="fa-solid fa-triangle-exclamation" style="color: #FFD43B;"></i> More than 100 entries in this world. If you don't choose a number higher than that, the lower entries will default to 0.<br />(Usual default: 100)<br />Minimum: ${entryCount}</div>`;
|
||||
content += '<div class="m-t-1"><i class="fa-solid fa-triangle-exclamation" style="color: #FFD43B;"></i> ' + t`More than 100 entries in this world. If you don't choose a number higher than that, the lower entries will default to 0.<br />(Usual default: 100)<br />Minimum: ${entryCount}` + '</div>';
|
||||
}
|
||||
|
||||
const result = await Popup.show.input('Apply Current Sorting', content, '100', { okButton: 'Apply', cancelButton: 'Cancel' });
|
||||
const result = await Popup.show.input(t`Apply Current Sorting`, content, '100', { okButton: t`Apply`, cancelButton: 'Cancel' });
|
||||
if (!result) return;
|
||||
|
||||
const start = Number(result);
|
||||
if (isNaN(start) || start < 0) {
|
||||
toastr.error('Invalid number: ' + result, 'Apply Current Sorting');
|
||||
toastr.error(t`Invalid number: ${result}`, t`Apply Current Sorting`);
|
||||
return;
|
||||
}
|
||||
if (start < entryCount) {
|
||||
toastr.warning('A number lower than the entry count has been chosen. All entries below that will default to 0.', 'Apply Current Sorting');
|
||||
toastr.warning(t`A number lower than the entry count has been chosen. All entries below that will default to 0.`, t`Apply Current Sorting`);
|
||||
}
|
||||
|
||||
// We need to sort the entries here, as the data source isn't sorted
|
||||
@@ -3728,7 +3728,7 @@ export async function deleteWorldInfoEntry(data, uid, { silent = false } = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmation = silent || await Popup.show.confirm(`Delete the entry with UID: ${uid}?`, 'This action is irreversible!');
|
||||
const confirmation = silent || await Popup.show.confirm(t`Delete the entry with UID: ${uid}?`, t`This action is irreversible!`);
|
||||
if (!confirmation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-172
@@ -13,6 +13,7 @@
|
||||
@import url(css/welcome.css);
|
||||
@import url(css/data-maid.css);
|
||||
@import url(css/secrets.css);
|
||||
@import url(css/backgrounds.css);
|
||||
|
||||
:root {
|
||||
interpolate-size: allow-keywords;
|
||||
@@ -721,71 +722,11 @@ hr {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#bg1,
|
||||
#bg_custom {
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-size: cover;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transition: background-image var(--animation-duration-3x) ease-in-out;
|
||||
}
|
||||
|
||||
/* Background fitting options */
|
||||
#background_fitting {
|
||||
max-width: 6em;
|
||||
}
|
||||
|
||||
/* Fill/Cover - scales to fill width while maintaining aspect ratio */
|
||||
#bg1.cover,
|
||||
#bg_custom.cover {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
/* Fit/Contain - shows entire image maintaining aspect ratio */
|
||||
#bg1.contain,
|
||||
#bg_custom.contain {
|
||||
background-size: contain;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* Stretch - stretches to fill entire space */
|
||||
#bg1.stretch,
|
||||
#bg_custom.stretch {
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
|
||||
/* Center - centers without scaling */
|
||||
#bg1.center,
|
||||
#bg_custom.center {
|
||||
background-size: auto;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
body.reduced-motion #bg1,
|
||||
body.reduced-motion #bg_custom {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
#version_display {
|
||||
padding: 5px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
#bg1 {
|
||||
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
|
||||
z-index: -3;
|
||||
}
|
||||
|
||||
#bg_custom {
|
||||
background-image: none;
|
||||
z-index: -2;
|
||||
}
|
||||
|
||||
/*TOPPER margin*/
|
||||
|
||||
#top-bar {
|
||||
@@ -3298,123 +3239,12 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
||||
.bg_list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: calc(var(--sheldWidth) - 10px);
|
||||
width: calc(var(--sheldWidth) - 15px);
|
||||
max-width: 100vw;
|
||||
max-width: 100dvw;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.bg_example {
|
||||
width: 30%;
|
||||
max-width: 200px;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
box-shadow: 0 0 7px var(--black50a);
|
||||
margin: 5px;
|
||||
cursor: pointer;
|
||||
aspect-ratio: 16/9;
|
||||
justify-content: flex-end;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bg_example.locked {
|
||||
outline: 2px solid var(--golden);
|
||||
}
|
||||
|
||||
.bg_example:hover.locked .bg_example_lock,
|
||||
.bg_example:focus-within.locked .bg_example_lock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example:hover:not(.locked) .bg_example_unlock,
|
||||
.bg_example:focus-within:not(.locked) .bg_example_unlock {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example:hover[custom="true"] .bg_example_edit,
|
||||
.bg_example:focus-within[custom="true"] .bg_example_edit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example:hover[custom="false"] .bg_example_copy,
|
||||
.bg_example:focus-within[custom="false"] .bg_example_copy {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.BGSampleTitle {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: min-content;
|
||||
text-align: center;
|
||||
justify-content: center;
|
||||
align-self: flex-end;
|
||||
bottom: 0;
|
||||
position: relative;
|
||||
word-break: break-word;
|
||||
background-color: var(--SmartThemeBlurTintColor);
|
||||
font-size: calc(var(--fontScale) * 0.9em);
|
||||
max-height: 50%;
|
||||
overflow-y: clip;
|
||||
border-radius: 0 0 7px 7px;
|
||||
}
|
||||
|
||||
.bg_example[custom="true"] .BGSampleTitle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_button {
|
||||
padding: 4px;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
cursor: pointer;
|
||||
opacity: 0.8;
|
||||
border-radius: 3px;
|
||||
font-size: 20px;
|
||||
color: var(--black70a);
|
||||
text-shadow: none;
|
||||
margin: 0;
|
||||
filter: drop-shadow(0px 0px 3px white);
|
||||
transition: opacity var(--animation-duration-2x) ease-in-out;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bg_example:hover .bg_button,
|
||||
.bg_example:focus-within .bg_button {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.bg_button:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.bg_example_cross {
|
||||
right: 6px;
|
||||
}
|
||||
|
||||
.bg_example_edit {
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.bg_example_copy {
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.bg_example_lock,
|
||||
.bg_example_unlock {
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.add_bg_but {
|
||||
cursor: pointer;
|
||||
opacity: 0.1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.input-file {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -27,6 +27,7 @@ import { initConfig } from './config-init.js';
|
||||
* @property {boolean} ssl If enable SSL
|
||||
* @property {string} certPath Path to certificate
|
||||
* @property {string} keyPath Path to private key
|
||||
* @property {string} keyPassphrase SSL private key passphrase
|
||||
* @property {boolean} whitelistMode If enable whitelist mode
|
||||
* @property {boolean} basicAuthMode If enable basic authentication
|
||||
* @property {boolean} requestProxyEnabled If enable outgoing request proxy
|
||||
@@ -70,6 +71,7 @@ export class CommandLineParser {
|
||||
ssl: false,
|
||||
certPath: 'certs/cert.pem',
|
||||
keyPath: 'certs/privkey.pem',
|
||||
keyPassphrase: '',
|
||||
whitelistMode: true,
|
||||
basicAuthMode: false,
|
||||
requestProxyEnabled: false,
|
||||
@@ -193,6 +195,11 @@ export class CommandLineParser {
|
||||
default: null,
|
||||
describe: 'Path to SSL private key file',
|
||||
})
|
||||
.option('keyPassphrase', {
|
||||
type: 'string',
|
||||
default: null,
|
||||
describe: 'Passphrase for the SSL private key',
|
||||
})
|
||||
.option('whitelist', {
|
||||
type: 'boolean',
|
||||
default: null,
|
||||
@@ -291,6 +298,7 @@ export class CommandLineParser {
|
||||
ssl: cliArguments.ssl ?? getConfigValue('ssl.enabled', defaultConfig.ssl, 'boolean'),
|
||||
certPath: cliArguments.certPath ?? getConfigValue('ssl.certPath', defaultConfig.certPath),
|
||||
keyPath: cliArguments.keyPath ?? getConfigValue('ssl.keyPath', defaultConfig.keyPath),
|
||||
keyPassphrase: cliArguments.keyPassphrase ?? getConfigValue('ssl.keyPassphrase', defaultConfig.keyPassphrase),
|
||||
whitelistMode: cliArguments.whitelist ?? getConfigValue('whitelistMode', defaultConfig.whitelistMode, 'boolean'),
|
||||
basicAuthMode: cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', defaultConfig.basicAuthMode, 'boolean'),
|
||||
requestProxyEnabled: cliArguments.requestProxyEnabled ?? getConfigValue('requestProxy.enabled', defaultConfig.requestProxyEnabled, 'boolean'),
|
||||
|
||||
@@ -173,6 +173,7 @@ export const CHAT_COMPLETION_SOURCES = {
|
||||
COHERE: 'cohere',
|
||||
PERPLEXITY: 'perplexity',
|
||||
GROQ: 'groq',
|
||||
ELECTRONHUB: 'electronhub',
|
||||
NANOGPT: 'nanogpt',
|
||||
DEEPSEEK: 'deepseek',
|
||||
AIMLAPI: 'aimlapi',
|
||||
@@ -181,6 +182,7 @@ export const CHAT_COMPLETION_SOURCES = {
|
||||
MOONSHOT: 'moonshot',
|
||||
FIREWORKS: 'fireworks',
|
||||
COMETAPI: 'cometapi',
|
||||
AZURE_OPENAI: 'azure_openai',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -407,6 +409,45 @@ export const VLLM_KEYS = [
|
||||
'guided_whitespace_pattern',
|
||||
];
|
||||
|
||||
export const AZURE_OPENAI_KEYS = [
|
||||
'messages',
|
||||
'temperature',
|
||||
'frequency_penalty',
|
||||
'presence_penalty',
|
||||
'top_p',
|
||||
'max_tokens',
|
||||
'max_completion_tokens',
|
||||
'stream',
|
||||
'logit_bias',
|
||||
'stop',
|
||||
'n',
|
||||
'logprobs',
|
||||
'seed',
|
||||
'tools',
|
||||
'tool_choice',
|
||||
'reasoning_effort',
|
||||
];
|
||||
|
||||
export const OPENAI_REASONING_EFFORT_MODELS = [
|
||||
'o1',
|
||||
'o3-mini',
|
||||
'o3-mini-2025-01-31',
|
||||
'o4-mini',
|
||||
'o4-mini-2025-04-16',
|
||||
'o3',
|
||||
'o3-2025-04-16',
|
||||
'gpt-5',
|
||||
'gpt-5-2025-08-07',
|
||||
'gpt-5-mini',
|
||||
'gpt-5-mini-2025-08-07',
|
||||
'gpt-5-nano',
|
||||
'gpt-5-nano-2025-08-07',
|
||||
];
|
||||
|
||||
export const OPENAI_REASONING_EFFORT_MAP = {
|
||||
min: 'minimal',
|
||||
};
|
||||
|
||||
export const LOG_LEVELS = {
|
||||
DEBUG: 0,
|
||||
INFO: 1,
|
||||
|
||||
Generated
+3
-3
@@ -265,9 +265,9 @@
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "35.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-35.0.0.tgz",
|
||||
"integrity": "sha512-mwNQNktYLPnUWZVR8iNkfWCBjmM5e2/CmB1rhACwE9ASDbVU7CYPgp/jLUB3bj/LyQsfSuubD82OUite6SN8Uw==",
|
||||
"version": "35.7.5",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-35.7.5.tgz",
|
||||
"integrity": "sha512-dnL+JvLraKZl7iusXTVTGYs10TKfzUi30uEDTqsmTm0guN9V2tbOjTzyIZbh9n3ygUjgEYyo+igAwMRXIi3IPw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
||||
@@ -2,11 +2,15 @@ import process from 'node:process';
|
||||
import util from 'node:util';
|
||||
import express from 'express';
|
||||
import fetch from 'node-fetch';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import {
|
||||
AIMLAPI_HEADERS,
|
||||
AZURE_OPENAI_KEYS,
|
||||
CHAT_COMPLETION_SOURCES,
|
||||
GEMINI_SAFETY,
|
||||
OPENAI_REASONING_EFFORT_MAP,
|
||||
OPENAI_REASONING_EFFORT_MODELS,
|
||||
OPENROUTER_HEADERS,
|
||||
} from '../../constants.js';
|
||||
import {
|
||||
@@ -60,6 +64,7 @@ const API_GROQ = 'https://api.groq.com/openai/v1';
|
||||
const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
|
||||
const API_VERTEX_AI = 'https://us-central1-aiplatform.googleapis.com';
|
||||
const API_AI21 = 'https://api.ai21.com/studio/v1';
|
||||
const API_ELECTRONHUB = 'https://api.electronhub.ai/v1';
|
||||
const API_NANOGPT = 'https://nano-gpt.com/api/v1';
|
||||
const API_DEEPSEEK = 'https://api.deepseek.com/beta';
|
||||
const API_XAI = 'https://api.x.ai/v1';
|
||||
@@ -221,7 +226,7 @@ async function sendClaudeRequest(request, response) {
|
||||
betaHeaders.push('extended-cache-ttl-2025-04-11');
|
||||
}
|
||||
|
||||
if (isOpus41){
|
||||
if (isOpus41) {
|
||||
if (requestBody.top_p < 1) {
|
||||
delete requestBody.temperature;
|
||||
} else {
|
||||
@@ -371,6 +376,7 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
'gemini-2.0-flash-exp',
|
||||
'gemini-2.0-flash-exp-image-generation',
|
||||
'gemini-2.0-flash-preview-image-generation',
|
||||
'gemini-2.5-flash-image-preview',
|
||||
];
|
||||
|
||||
// These models do not support setting the threshold to OFF at all.
|
||||
@@ -381,7 +387,7 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
'gemini-1.5-flash-8b-exp-0924',
|
||||
];
|
||||
|
||||
const isThinkingConfigModel = m => /^gemini-2.5-(flash|pro)/.test(m);
|
||||
const isThinkingConfigModel = m => /^gemini-2.5-(flash|pro)/.test(m) && !/-image-preview$/.test(m);
|
||||
|
||||
const noSearchModels = [
|
||||
'gemini-2.0-flash-lite',
|
||||
@@ -496,8 +502,8 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
? 'https://aiplatform.googleapis.com'
|
||||
: `https://${region}-aiplatform.googleapis.com`;
|
||||
url = projectId
|
||||
? `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/publishers/google/models/${model}:generateContent?key=${keyParam}${stream ? '&alt=sse' : ''}`
|
||||
: `${baseUrl}/v1/publishers/google/models/${model}:generateContent?key=${keyParam}${stream ? '&alt=sse' : ''}`;
|
||||
? `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/publishers/google/models/${model}:${responseType}?key=${keyParam}${stream ? '&alt=sse' : ''}`
|
||||
: `${baseUrl}/v1/publishers/google/models/${model}:${responseType}?key=${keyParam}${stream ? '&alt=sse' : ''}`;
|
||||
} else if (authType === 'full') {
|
||||
// For Full mode (service account authentication), use project-specific URL
|
||||
// Get project ID from Service Account JSON
|
||||
@@ -916,10 +922,7 @@ async function sendDeepSeekRequest(request, response) {
|
||||
request.body.messages.push(message);
|
||||
}
|
||||
|
||||
const postProcessType = String(request.body.model).endsWith('-reasoner')
|
||||
? PROMPT_PROCESSING_TYPE.STRICT_TOOLS
|
||||
: PROMPT_PROCESSING_TYPE.SEMI_TOOLS;
|
||||
const processedMessages = addAssistantPrefix(postProcessPrompt(request.body.messages, postProcessType, getPromptNames(request)), bodyParams.tools, 'prefix');
|
||||
const processedMessages = addAssistantPrefix(postProcessPrompt(request.body.messages, PROMPT_PROCESSING_TYPE.SEMI_TOOLS, getPromptNames(request)), bodyParams.tools, 'prefix');
|
||||
|
||||
const requestBody = {
|
||||
'messages': processedMessages,
|
||||
@@ -1194,14 +1197,209 @@ async function sendAimlapiRequest(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Electron Hub.
|
||||
* @param {express.Request} request Express request
|
||||
* @param {express.Response} response Express response
|
||||
*/
|
||||
async function sendElectronHubRequest(request, response) {
|
||||
const apiUrl = API_ELECTRONHUB;
|
||||
const apiKey = readSecret(request.user.directories, SECRET_KEYS.ELECTRONHUB);
|
||||
|
||||
if (!apiKey) {
|
||||
console.warn('Electron Hub key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
request.socket.removeAllListeners('close');
|
||||
request.socket.on('close', function () {
|
||||
controller.abort();
|
||||
});
|
||||
|
||||
try {
|
||||
let bodyParams = {};
|
||||
|
||||
if (request.body.enable_web_search) {
|
||||
bodyParams['web_search'] = true;
|
||||
}
|
||||
|
||||
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||
bodyParams['tools'] = request.body.tools;
|
||||
bodyParams['tool_choice'] = request.body.tool_choice;
|
||||
}
|
||||
|
||||
if (request.body.reasoning_effort) {
|
||||
bodyParams['reasoning_effort'] = request.body.reasoning_effort;
|
||||
}
|
||||
|
||||
if (request.body.json_schema) {
|
||||
bodyParams['response_format'] = {
|
||||
type: 'json_schema',
|
||||
json_schema: {
|
||||
name: request.body.json_schema.name,
|
||||
description: request.body.json_schema.description,
|
||||
schema: request.body.json_schema.value,
|
||||
strict: request.body.json_schema.strict ?? true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
'messages': request.body.messages,
|
||||
'model': request.body.model,
|
||||
'temperature': request.body.temperature,
|
||||
'max_tokens': request.body.max_tokens,
|
||||
'stream': request.body.stream,
|
||||
'presence_penalty': request.body.presence_penalty,
|
||||
'frequency_penalty': request.body.frequency_penalty,
|
||||
'top_p': request.body.top_p,
|
||||
'top_k': request.body.top_k,
|
||||
'seed': request.body.seed,
|
||||
...bodyParams,
|
||||
};
|
||||
|
||||
const config = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + apiKey,
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
console.debug('Electron Hub request:', requestBody);
|
||||
|
||||
const generateResponse = await fetch(apiUrl + '/chat/completions', config);
|
||||
|
||||
if (request.body.stream) {
|
||||
forwardFetchResponse(generateResponse, response);
|
||||
} else {
|
||||
if (!generateResponse.ok) {
|
||||
const errorText = await generateResponse.text();
|
||||
console.warn('Electron Hub returned error: ', errorText);
|
||||
const errorJson = tryParse(errorText) ?? { error: true };
|
||||
return response.status(500).send(errorJson);
|
||||
}
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.debug('Electron Hub response:', generateResponseJson);
|
||||
return response.send(generateResponseJson);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error communicating with Electron Hub: ', error);
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: true });
|
||||
} else {
|
||||
response.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a chat completion request to Azure OpenAI.
|
||||
* @param {express.Request} request Express request object (contains request.body with all generate_data)
|
||||
* @param {express.Response} response Express response object
|
||||
*/
|
||||
async function sendAzureOpenAIRequest(request, response) {
|
||||
// 1. GATHER & VALIDATE SETTINGS
|
||||
const { azure_base_url, azure_deployment_name, azure_api_version } = request.body;
|
||||
const apiKey = readSecret(request.user.directories, SECRET_KEYS.AZURE_OPENAI);
|
||||
if (!azure_base_url || !azure_deployment_name || !azure_api_version || !apiKey) {
|
||||
return response.status(400).send({
|
||||
error: {
|
||||
message: 'Azure OpenAI configuration is incomplete. Please provide Base URL, Deployment Name, API Version, and API Key in the connection settings.',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 2. PREPARE THE REQUEST
|
||||
const url = new URL(`/openai/deployments/${azure_deployment_name}/chat/completions`, azure_base_url);
|
||||
url.searchParams.set('api-version', azure_api_version);
|
||||
const endpointUrl = url.toString();
|
||||
|
||||
// Create the base payload with all standard parameters
|
||||
const apiRequestBody = /** @type {any} */ ({});
|
||||
for (const key of AZURE_OPENAI_KEYS) {
|
||||
if (Object.hasOwn(request.body, key)) {
|
||||
apiRequestBody[key] = request.body[key];
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Structured Output (JSON Mode) by translating the custom `json_schema` object.
|
||||
if (request.body.json_schema) {
|
||||
apiRequestBody['response_format'] = {
|
||||
type: 'json_schema',
|
||||
json_schema: {
|
||||
name: request.body.json_schema.name,
|
||||
strict: request.body.json_schema.strict ?? true,
|
||||
schema: request.body.json_schema.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Adjust logprobs for Azure OpenAI, which follows the OpenAI Chat Completions API spec.
|
||||
if (typeof apiRequestBody.logprobs === 'number' && apiRequestBody.logprobs > 0) {
|
||||
apiRequestBody.top_logprobs = apiRequestBody.logprobs;
|
||||
apiRequestBody.logprobs = true;
|
||||
}
|
||||
|
||||
// Do not send reasoning effort to models which do not support it
|
||||
apiRequestBody['reasoning_effort'] = OPENAI_REASONING_EFFORT_MODELS.includes(request.body.model)
|
||||
? OPENAI_REASONING_EFFORT_MAP[request.body.reasoning_effort] ?? request.body.reasoning_effort
|
||||
: undefined;
|
||||
|
||||
const controller = new AbortController();
|
||||
request.socket.removeAllListeners('close');
|
||||
request.socket.on('close', () => controller.abort());
|
||||
|
||||
const config = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'api-key': apiKey,
|
||||
},
|
||||
body: JSON.stringify(apiRequestBody),
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
console.info(`Sending request to Azure OpenAI: ${endpointUrl}`);
|
||||
console.debug('Azure OpenAI Request Body:', apiRequestBody);
|
||||
try {
|
||||
const fetchResponse = await fetch(endpointUrl, config);
|
||||
|
||||
if (request.body.stream) {
|
||||
return forwardFetchResponse(fetchResponse, response);
|
||||
}
|
||||
|
||||
if (fetchResponse.ok) {
|
||||
/** @type {any} */
|
||||
const json = await fetchResponse.json();
|
||||
console.debug('Azure OpenAI response:', json);
|
||||
return response.send(json);
|
||||
}
|
||||
|
||||
const text = await fetchResponse.text();
|
||||
const data = tryParse(text) || { error: { message: fetchResponse.statusText || 'Unknown error occurred' } };
|
||||
return response.status(500).send(data);
|
||||
} catch (error) {
|
||||
const message = error.name === 'AbortError'
|
||||
? 'Request was aborted by the client.'
|
||||
: (error.message || 'An unknown network error occurred.');
|
||||
return response.status(500).send({ error: { message, ...error } });
|
||||
}
|
||||
}
|
||||
|
||||
export const router = express.Router();
|
||||
|
||||
router.post('/status', async function (request, statusResponse) {
|
||||
if (!request.body) return statusResponse.sendStatus(400);
|
||||
|
||||
let apiUrl;
|
||||
let apiKey;
|
||||
let headers;
|
||||
let apiUrl = '';
|
||||
let apiKey = '';
|
||||
let headers = {};
|
||||
let queryParams = {};
|
||||
|
||||
if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.OPENAI) {
|
||||
apiUrl = new URL(request.body.reverse_proxy || API_OPENAI).toString();
|
||||
@@ -1225,16 +1423,21 @@ router.post('/status', async function (request, statusResponse) {
|
||||
apiUrl = API_COHERE_V1;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.COHERE);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ELECTRONHUB) {
|
||||
apiUrl = API_ELECTRONHUB;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.ELECTRONHUB);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) {
|
||||
apiUrl = API_NANOGPT;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
|
||||
headers = {};
|
||||
queryParams = { detailed: true };
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.DEEPSEEK) {
|
||||
apiUrl = new URL(request.body.reverse_proxy || API_DEEPSEEK.replace('/beta', ''));
|
||||
apiUrl = new URL(request.body.reverse_proxy || API_DEEPSEEK.replace('/beta', '')).toString();
|
||||
apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.XAI) {
|
||||
apiUrl = new URL(request.body.reverse_proxy || API_XAI);
|
||||
apiUrl = new URL(request.body.reverse_proxy || API_XAI).toString();
|
||||
apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.XAI);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.AIMLAPI) {
|
||||
@@ -1253,6 +1456,7 @@ router.post('/status', async function (request, statusResponse) {
|
||||
apiUrl = API_COMETAPI;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.COMETAPI);
|
||||
headers = {};
|
||||
throw new Error('This provider is temporarily disabled.');
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.MOONSHOT) {
|
||||
apiUrl = API_MOONSHOT;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.MOONSHOT);
|
||||
@@ -1297,6 +1501,84 @@ router.post('/status', async function (request, statusResponse) {
|
||||
console.error('Error fetching Google AI Studio models:', error);
|
||||
return statusResponse.send({ error: true, bypass: true, data: { data: [] } });
|
||||
}
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.AZURE_OPENAI) {
|
||||
const { azure_base_url, azure_deployment_name, azure_api_version } = request.body;
|
||||
const apiKey = readSecret(request.user.directories, SECRET_KEYS.AZURE_OPENAI);
|
||||
|
||||
// 1) Validate configuration from the frontend
|
||||
if (!apiKey || !azure_base_url || !azure_deployment_name || !azure_api_version) {
|
||||
console.warn('Azure OpenAI status check failed: missing config from frontend.');
|
||||
return statusResponse.status(400).send({ error: true, message: 'Azure configuration is incomplete.' });
|
||||
}
|
||||
// 2) Build URLs using the URL API for consistency and robustness.
|
||||
const modelsUrl = new URL('/openai/models', azure_base_url);
|
||||
modelsUrl.searchParams.set('api-version', azure_api_version);
|
||||
|
||||
const chatUrl = new URL(`/openai/deployments/${azure_deployment_name}/chat/completions`, azure_base_url);
|
||||
chatUrl.searchParams.set('api-version', azure_api_version);
|
||||
|
||||
// Map common status codes to user-friendly error messages
|
||||
const azureStatusErrorMap = {
|
||||
400: 'API version may be invalid for this resource.',
|
||||
401: 'Invalid API key or insufficient permissions.',
|
||||
403: 'Invalid API key or insufficient permissions.',
|
||||
404: 'Endpoint URL appears incorrect (404).',
|
||||
};
|
||||
|
||||
try {
|
||||
// ---- A) GET /models: fast sanity check for endpoint + api key + api version ----
|
||||
const apiConfigTest = await fetch(modelsUrl, {
|
||||
method: 'GET',
|
||||
headers: { 'api-key': apiKey, 'Accept': 'application/json' },
|
||||
});
|
||||
|
||||
if (!apiConfigTest.ok) {
|
||||
let errText = '';
|
||||
try { errText = await apiConfigTest.text(); } catch { /* response body may be empty */ }
|
||||
|
||||
console.warn('Azure OpenAI GET /models failed:', apiConfigTest.status, apiConfigTest.statusText, errText || '');
|
||||
|
||||
const defaultMessage = `Azure Models endpoint error: ${apiConfigTest.statusText}`;
|
||||
const message = azureStatusErrorMap[apiConfigTest.status] ?? defaultMessage;
|
||||
return statusResponse.status(apiConfigTest.status).send({ error: true, message });
|
||||
}
|
||||
|
||||
// ---- B) POST /chat/completions: verify deployment + read underlying model ID ----
|
||||
// Small, deterministic probe to minimize cost/latency
|
||||
const modelPayload = {
|
||||
messages: [{ role: 'user', content: 'Say word Hi' }],
|
||||
stream: false,
|
||||
max_completion_tokens: 5,
|
||||
};
|
||||
|
||||
const modelRequest = await fetch(chatUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'api-key': apiKey, 'Content-Type': 'application/json', 'Accept': 'application/json' },
|
||||
body: JSON.stringify(modelPayload),
|
||||
});
|
||||
|
||||
let modelResponse;
|
||||
try {
|
||||
modelResponse = await modelRequest.json();
|
||||
} catch {
|
||||
modelResponse = { raw: 'Failed to parse JSON response from chat completions probe.' };
|
||||
}
|
||||
|
||||
const modelId = /** @type {any} */ (modelResponse)?.model;
|
||||
if (!modelId) {
|
||||
console.warn('Azure status check succeeded but could not find a model ID in the response.');
|
||||
console.debug('Azure Response Body:', modelResponse);
|
||||
// Keep a benign success to avoid UX disruption in the UI
|
||||
return statusResponse.send({ data: [] });
|
||||
}
|
||||
|
||||
console.info(color.green('Azure OpenAI connection successful. Detected model:'), modelId);
|
||||
// Consistent response format: always an array of { id }
|
||||
return statusResponse.send({ data: [{ id: modelId }] });
|
||||
} catch (error) {
|
||||
console.error('Azure OpenAI status check connection error:', error);
|
||||
return statusResponse.status(500).send({ error: true, message: 'Failed to connect to the Azure endpoint.' });
|
||||
}
|
||||
} else {
|
||||
console.warn('This chat completion source is not supported yet.');
|
||||
return statusResponse.status(400).send({ error: true });
|
||||
@@ -1308,7 +1590,11 @@ router.post('/status', async function (request, statusResponse) {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(apiUrl + '/models', {
|
||||
const modelsUrl = new URL(urlJoin(apiUrl, '/models'));
|
||||
Object.keys(queryParams).forEach(key => {
|
||||
modelsUrl.searchParams.append(key, queryParams[key]);
|
||||
});
|
||||
const response = await fetch(modelsUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + apiKey,
|
||||
@@ -1484,6 +1770,8 @@ router.post('/generate', function (request, response) {
|
||||
case CHAT_COMPLETION_SOURCES.DEEPSEEK: return sendDeepSeekRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.AIMLAPI: return sendAimlapiRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.XAI: return sendXaiRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.ELECTRONHUB: return sendElectronHubRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.AZURE_OPENAI: return sendAzureOpenAIRequest(request, response);
|
||||
}
|
||||
|
||||
let apiUrl;
|
||||
@@ -1643,7 +1931,17 @@ router.post('/generate', function (request, response) {
|
||||
if (request.body.enable_web_search && !/:online$/.test(request.body.model)) {
|
||||
request.body.model = `${request.body.model}:online`;
|
||||
}
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.POLLINATIONS) {
|
||||
const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean');
|
||||
const isClaude3or4 = /claude-(3|opus-4|sonnet-4)/.test(request.body.model);
|
||||
const cacheTTL = getConfigValue('claude.extendedTTL', false, 'boolean') ? '1h' : '5m';
|
||||
if (enableSystemPromptCache && isClaude3or4) {
|
||||
bodyParams['cache_control'] = {
|
||||
'enabled': true,
|
||||
'ttl': cacheTTL,
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.POLLINATIONS) {
|
||||
apiUrl = API_POLLINATIONS;
|
||||
apiKey = 'NONE';
|
||||
headers = {
|
||||
@@ -1673,6 +1971,7 @@ router.post('/generate', function (request, response) {
|
||||
bodyParams = {
|
||||
reasoning_effort: request.body.reasoning_effort,
|
||||
};
|
||||
throw new Error('This provider is temporarily disabled.');
|
||||
} else {
|
||||
console.warn('This chat completion source is not supported yet.');
|
||||
return response.status(400).send({ error: true });
|
||||
@@ -1680,26 +1979,8 @@ router.post('/generate', function (request, response) {
|
||||
|
||||
// A few of OpenAIs reasoning models support reasoning effort
|
||||
if (request.body.reasoning_effort && [CHAT_COMPLETION_SOURCES.CUSTOM, CHAT_COMPLETION_SOURCES.OPENAI].includes(request.body.chat_completion_source)) {
|
||||
const reasoningEffortModels = [
|
||||
'o1',
|
||||
'o3-mini',
|
||||
'o3-mini-2025-01-31',
|
||||
'o4-mini',
|
||||
'o4-mini-2025-04-16',
|
||||
'o3',
|
||||
'o3-2025-04-16',
|
||||
'gpt-5',
|
||||
'gpt-5-2025-08-07',
|
||||
'gpt-5-mini',
|
||||
'gpt-5-mini-2025-08-07',
|
||||
'gpt-5-nano',
|
||||
'gpt-5-nano-2025-08-07',
|
||||
];
|
||||
const reasoningEffortMap = {
|
||||
min: 'minimal',
|
||||
};
|
||||
if (reasoningEffortModels.includes(request.body.model)) {
|
||||
bodyParams['reasoning_effort'] = reasoningEffortMap[request.body.reasoning_effort] ?? request.body.reasoning_effort;
|
||||
if (OPENAI_REASONING_EFFORT_MODELS.includes(request.body.model)) {
|
||||
bodyParams['reasoning_effort'] = OPENAI_REASONING_EFFORT_MAP[request.body.reasoning_effort] ?? request.body.reasoning_effort;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1775,7 +2056,7 @@ router.post('/generate', function (request, response) {
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
console.debug(requestBody);
|
||||
console.debug('Chat Completion request:', requestBody);
|
||||
|
||||
makeRequest(config, response, request);
|
||||
|
||||
@@ -1784,10 +2065,8 @@ router.post('/generate', function (request, response) {
|
||||
* @param {import('node-fetch').RequestInit} config Fetch config
|
||||
* @param {express.Response} response Express response
|
||||
* @param {express.Request} request Express request
|
||||
* @param {Number} retries Number of retries left
|
||||
* @param {Number} timeout Request timeout in ms
|
||||
*/
|
||||
async function makeRequest(config, response, request, retries = 5, timeout = 5000) {
|
||||
async function makeRequest(config, response, request) {
|
||||
try {
|
||||
controller.signal.throwIfAborted();
|
||||
const fetchResponse = await fetch(endpointUrl, config);
|
||||
@@ -1802,14 +2081,7 @@ router.post('/generate', function (request, response) {
|
||||
/** @type {any} */
|
||||
let json = await fetchResponse.json();
|
||||
response.send(json);
|
||||
console.debug(json);
|
||||
console.debug(json?.choices?.[0]?.message);
|
||||
} else if (fetchResponse.status === 429 && retries > 0) {
|
||||
console.warn(`Out of quota, retrying in ${Math.round(timeout / 1000)}s`);
|
||||
setTimeout(() => {
|
||||
timeout *= 2;
|
||||
makeRequest(config, response, request, retries - 1, timeout);
|
||||
}, timeout);
|
||||
console.debug('Chat Completion response:', json);
|
||||
} else {
|
||||
await handleErrorResponse(fetchResponse);
|
||||
}
|
||||
@@ -1841,16 +2113,16 @@ router.post('/generate', function (request, response) {
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: { message }, quota_error: quota_error });
|
||||
} else if (!response.writableEnded) {
|
||||
response.write(errorResponse);
|
||||
response.write(responseText);
|
||||
} else {
|
||||
response.end();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const pollinations = express.Router();
|
||||
const multimodalModels = express.Router();
|
||||
|
||||
pollinations.post('/models/multimodal', async (_req, res) => {
|
||||
multimodalModels.post('/pollinations', async (_req, res) => {
|
||||
try {
|
||||
const response = await fetch('https://text.pollinations.ai/models');
|
||||
|
||||
@@ -1873,11 +2145,7 @@ pollinations.post('/models/multimodal', async (_req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.use('/pollinations', pollinations);
|
||||
|
||||
const aimlapi = express.Router();
|
||||
|
||||
aimlapi.post('/models/multimodal', async (_req, res) => {
|
||||
multimodalModels.post('/aimlapi', async (_req, res) => {
|
||||
try {
|
||||
const response = await fetch('https://api.aimlapi.com/v1/models');
|
||||
|
||||
@@ -1900,4 +2168,45 @@ aimlapi.post('/models/multimodal', async (_req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.use('/aimlapi', aimlapi);
|
||||
multimodalModels.post('/nanogpt', async (_req, res) => {
|
||||
try {
|
||||
const response = await fetch('https://nano-gpt.com/api/v1/models?detailed=true');
|
||||
|
||||
if (!response.ok) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await response.json();
|
||||
|
||||
if (!Array.isArray(data?.data)) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
const multimodalModels = data.data.filter(m => m?.capabilities?.vision).map(m => m.id);
|
||||
return res.json(multimodalModels);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
multimodalModels.post('/electronhub', async (_req, res) => {
|
||||
try {
|
||||
const response = await fetch('https://api.electronhub.ai/v1/models');
|
||||
|
||||
if (!response.ok) {
|
||||
return res.json([]);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await response.json();
|
||||
const multimodalModels = data.data.filter(m => m.metadata?.vision).map(m => m.id);
|
||||
return res.json(multimodalModels);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
router.use('/multimodal-models', multimodalModels);
|
||||
|
||||
@@ -478,7 +478,8 @@ ollama.post('/caption-image', async function (request, response) {
|
||||
});
|
||||
|
||||
if (!fetchResponse.ok) {
|
||||
console.error('Ollama caption error:', fetchResponse.status, fetchResponse.statusText);
|
||||
const errorText = await fetchResponse.text();
|
||||
console.error('Ollama caption error:', fetchResponse.status, fetchResponse.statusText, errorText);
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
|
||||
|
||||
@@ -544,10 +544,13 @@ async function downloadJannyCharacter(uuid) {
|
||||
const fileType = imageResult.headers.get('content-type');
|
||||
|
||||
return { buffer, fileName, fileType };
|
||||
} else {
|
||||
console.error('Janny failed to download', downloadResult);
|
||||
}
|
||||
} else {
|
||||
console.error('Janny returned error', result.statusText, await result.text());
|
||||
}
|
||||
|
||||
console.error('Janny returned error', result.statusText, await result.text());
|
||||
throw new Error('Failed to download character');
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,14 @@ router.post('/caption-image', async (request, response) => {
|
||||
key = readSecret(request.user.directories, SECRET_KEYS.MOONSHOT);
|
||||
}
|
||||
|
||||
if (request.body.api === 'nanogpt') {
|
||||
key = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
|
||||
}
|
||||
|
||||
if (request.body.api === 'electronhub') {
|
||||
key = readSecret(request.user.directories, SECRET_KEYS.ELECTRONHUB);
|
||||
}
|
||||
|
||||
const noKeyTypes = ['custom', 'ooba', 'koboldcpp', 'vllm', 'llamacpp', 'pollinations'];
|
||||
if (!key && !request.body.reverse_proxy && !noKeyTypes.includes(request.body.api)) {
|
||||
console.warn('No key found for API', request.body.api);
|
||||
@@ -161,6 +169,14 @@ router.post('/caption-image', async (request, response) => {
|
||||
apiUrl = 'https://api.moonshot.ai/v1/chat/completions';
|
||||
}
|
||||
|
||||
if (request.body.api === 'nanogpt') {
|
||||
apiUrl = 'https://nano-gpt.com/api/v1/chat/completions';
|
||||
}
|
||||
|
||||
if (request.body.api === 'electronhub') {
|
||||
apiUrl = 'https://api.electronhub.ai/v1/chat/completions';
|
||||
}
|
||||
|
||||
if (['koboldcpp', 'vllm', 'llamacpp', 'ooba'].includes(request.body.api)) {
|
||||
apiUrl = `${trimV1(request.body.server_url)}/v1/chat/completions`;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ router.post('/models/multimodal', async (_req, res) => {
|
||||
/** @type {any} */
|
||||
const data = await response.json();
|
||||
const models = data?.data || [];
|
||||
const multimodalModels = models.filter(m => m?.architecture?.modality === 'text+image->text').map(m => m.id);
|
||||
const multimodalModels = models.filter(m => ['text+image->text+image', 'text+image->text'].includes(m?.architecture?.modality)).map(m => m.id);
|
||||
|
||||
return res.json(multimodalModels);
|
||||
} catch (error) {
|
||||
|
||||
@@ -45,6 +45,7 @@ export const SECRET_KEYS = {
|
||||
STABILITY: 'api_key_stability',
|
||||
CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts',
|
||||
TAVILY: 'api_key_tavily',
|
||||
ELECTRONHUB: 'api_key_electronhub',
|
||||
NANOGPT: 'api_key_nanogpt',
|
||||
BFL: 'api_key_bfl',
|
||||
FALAI: 'api_key_falai',
|
||||
@@ -59,6 +60,7 @@ export const SECRET_KEYS = {
|
||||
MINIMAX_GROUP_ID: 'minimax_group_id',
|
||||
MOONSHOT: 'api_key_moonshot',
|
||||
COMETAPI: 'api_key_cometapi',
|
||||
AZURE_OPENAI: 'api_key_azure_openai',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -957,6 +957,118 @@ huggingface.post('/generate', async (request, response) => {
|
||||
}
|
||||
});
|
||||
|
||||
const electronhub = express.Router();
|
||||
|
||||
electronhub.post('/models', async (request, response) => {
|
||||
try {
|
||||
const key = readSecret(request.user.directories, SECRET_KEYS.ELECTRONHUB);
|
||||
|
||||
if (!key) {
|
||||
console.warn('Electron Hub key not found.');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
const modelsResponse = await fetch('https://api.electronhub.ai/v1/models', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${key}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!modelsResponse.ok) {
|
||||
console.warn('Electron Hub returned an error.');
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await modelsResponse.json();
|
||||
const models = data.data.filter(x => x.endpoints.includes('/v1/images/generations')).map(x => ({ value: x.id, text: x.name }));
|
||||
return response.send(models);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
electronhub.post('/generate', async (request, response) => {
|
||||
try {
|
||||
const key = readSecret(request.user.directories, SECRET_KEYS.ELECTRONHUB);
|
||||
|
||||
if (!key) {
|
||||
console.warn('Electron Hub key not found.');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
let bodyParams = {
|
||||
model: request.body.model,
|
||||
prompt: request.body.prompt,
|
||||
response_format: 'b64_json',
|
||||
};
|
||||
|
||||
if (request.body.size) {
|
||||
bodyParams.size = request.body.size;
|
||||
}
|
||||
|
||||
const result = await fetch('https://api.electronhub.ai/v1/images/generations', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${key}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...bodyParams,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
const errorText = await result.text();
|
||||
console.warn('Electron Hub returned an error.', result.status, result.statusText, errorText);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await result.json();
|
||||
const image = data?.data?.[0]?.b64_json;
|
||||
|
||||
if (!image) {
|
||||
console.warn('Electron Hub returned invalid data.');
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
|
||||
return response.send({ image });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
electronhub.post('/sizes', async (request, response) => {
|
||||
const result = await fetch(`https://api.electronhub.ai/v1/models/${request.body.model}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
console.warn('Electron Hub returned an error.');
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await result.json();
|
||||
|
||||
const sizes = data.sizes;
|
||||
|
||||
if (!sizes) {
|
||||
console.warn('Electron Hub returned invalid data.');
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
|
||||
return response.send({ sizes });
|
||||
});
|
||||
|
||||
const nanogpt = express.Router();
|
||||
|
||||
nanogpt.post('/models', async (request, response) => {
|
||||
@@ -1439,6 +1551,7 @@ router.use('/drawthings', drawthings);
|
||||
router.use('/pollinations', pollinations);
|
||||
router.use('/stability', stability);
|
||||
router.use('/huggingface', huggingface);
|
||||
router.use('/electronhub', electronhub);
|
||||
router.use('/nanogpt', nanogpt);
|
||||
router.use('/bfl', bfl);
|
||||
router.use('/falai', falai);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import path from 'node:path';
|
||||
import { color, getConfigValue, safeReadFileSync } from '../util.js';
|
||||
import { serverDirectory } from '../server-directory.js';
|
||||
import { isHostAllowed, hostValidationMiddleware } from 'host-validation-middleware';
|
||||
|
||||
const knownHosts = new Set();
|
||||
const maxKnownHosts = 1000;
|
||||
|
||||
const hostWhitelistEnabled = !!getConfigValue('hostWhitelist.enabled', false);
|
||||
const hostWhitelist = Object.freeze(getConfigValue('hostWhitelist.hosts', []));
|
||||
const hostWhitelistScan = !!getConfigValue('hostWhitelist.scan', false, 'boolean');
|
||||
|
||||
const hostNotAllowedHtml = safeReadFileSync(path.join(serverDirectory, 'public/error/host-not-allowed.html'))?.toString() ?? '';
|
||||
|
||||
const validationMiddleware = hostValidationMiddleware({
|
||||
allowedHosts: hostWhitelist,
|
||||
generateErrorMessage: () => hostNotAllowedHtml,
|
||||
errorResponseContentType: 'text/html',
|
||||
});
|
||||
|
||||
/**
|
||||
* Middleware to validate remote hosts.
|
||||
* Useful to protect against DNS rebinding attacks.
|
||||
* @param {import('express').Request} req Request
|
||||
* @param {import('express').Response} res Response
|
||||
* @param {import('express').NextFunction} next Next middleware
|
||||
*/
|
||||
export default function hostWhitelistMiddleware(req, res, next) {
|
||||
const hostValue = req.headers.host;
|
||||
if (hostWhitelistScan && !isHostAllowed(hostValue, hostWhitelist) && !knownHosts.has(hostValue) && knownHosts.size < maxKnownHosts) {
|
||||
const isFirstWarning = knownHosts.size === 0;
|
||||
console.warn(color.red('Request from untrusted host:'), hostValue);
|
||||
console.warn(`If you trust this host, you can add it to ${color.yellow('hostWhitelist.hosts')} in config.yaml`);
|
||||
if (!hostWhitelistEnabled && isFirstWarning) {
|
||||
console.warn(`To protect against host spoofing, consider setting ${color.yellow('hostWhitelist.enabled')} to true`);
|
||||
}
|
||||
if (isFirstWarning) {
|
||||
console.warn(`To disable this warning, set ${color.yellow('hostWhitelist.scan')} to false`);
|
||||
}
|
||||
knownHosts.add(hostValue);
|
||||
}
|
||||
|
||||
if (!hostWhitelistEnabled) {
|
||||
return next();
|
||||
}
|
||||
|
||||
return validationMiddleware(req, res, next);
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import multerMonkeyPatch from './middleware/multerMonkeyPatch.js';
|
||||
import initRequestProxy from './request-proxy.js';
|
||||
import cacheBuster from './middleware/cacheBuster.js';
|
||||
import corsProxyMiddleware from './middleware/corsProxy.js';
|
||||
import hostWhitelistMiddleware from './middleware/hostWhitelist.js';
|
||||
import {
|
||||
getVersion,
|
||||
color,
|
||||
@@ -116,6 +117,8 @@ if (cliArgs.whitelistMode) {
|
||||
app.use(whitelistMiddleware);
|
||||
}
|
||||
|
||||
app.use(hostWhitelistMiddleware);
|
||||
|
||||
if (cliArgs.listen) {
|
||||
app.use(accessLoggerMiddleware());
|
||||
}
|
||||
|
||||
@@ -233,9 +233,11 @@ export class ServerStartup {
|
||||
#createHttpsServer(url, ipVersion) {
|
||||
this.#verifySslOptions();
|
||||
return new Promise((resolve, reject) => {
|
||||
/** @type {import('https').ServerOptions} */
|
||||
const sslOptions = {
|
||||
cert: fs.readFileSync(this.cliArgs.certPath),
|
||||
key: fs.readFileSync(this.cliArgs.keyPath),
|
||||
passphrase: String(this.cliArgs.keyPassphrase ?? ''),
|
||||
};
|
||||
const server = https.createServer(sslOptions, this.app);
|
||||
server.on('error', reject);
|
||||
|
||||
Generated
+4
-4
@@ -1525,13 +1525,13 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.8.3",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz",
|
||||
"integrity": "sha512-iP4DebzoNlP/YN2dpwCgb8zoCmhtkajzS48JvwmkSkXvPI3DHc7m+XYL5tGnSlJtR6nImXZmdCuN5aP8dh1d8A==",
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.12.0.tgz",
|
||||
"integrity": "sha512-oXTDccv8PcfjZmPGlWsPSwtOJCZ/b6W5jAMCNcfwJbCzDckwG0jrYJFaWH1yvivfCXjVzV/SPDEhMB3Q+DSurg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.0",
|
||||
"form-data": "^4.0.4",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user