mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-18 13:10:40 +01:00
Compare commits
423 Commits
af8b9fe6d7
...
e37824a34f
Author | SHA1 | Date | |
---|---|---|---|
|
e37824a34f | ||
|
a771dd5478 | ||
|
ebe877e6b6 | ||
|
ec49b19aff | ||
|
75aec77271 | ||
|
7348e0274d | ||
|
362470da18 | ||
|
4d323ec76f | ||
|
0039b48d1b | ||
|
050e65861c | ||
|
a434d217cc | ||
|
1723ce0f22 | ||
|
eb6a158781 | ||
|
cc369d25c5 | ||
|
59928d37ff | ||
|
1f41124844 | ||
|
3d492523e2 | ||
|
fc488bd4fe | ||
|
fd38ca503a | ||
|
9a15890745 | ||
|
37d9d4c253 | ||
|
bae02a44ed | ||
|
23f0b6ed09 | ||
|
c87e203b4a | ||
|
dd50f49176 | ||
|
c37c9051a6 | ||
|
8a4cf86b65 | ||
|
a2a15b9978 | ||
|
96d6a6df07 | ||
|
dbbf069e85 | ||
|
d276d23310 | ||
|
c98d241f3c | ||
|
961a71877b | ||
|
13e38c7c86 | ||
|
61e056004a | ||
|
b029ae98dc | ||
|
f5bfbce0ad | ||
|
a4c124dff0 | ||
|
2445b6d9dc | ||
|
ad8f0f564f | ||
|
c47d997a2d | ||
|
dd55b2770a | ||
|
83f74a5d22 | ||
|
09aaa9181c | ||
|
5477586ce4 | ||
|
76becb43ae | ||
|
b033b98532 | ||
|
412d638e9e | ||
|
6e0ed8552f | ||
|
dd7391caaf | ||
|
f101dd571f | ||
|
1a52d3c293 | ||
|
d6bf3439b4 | ||
|
54a9e0afee | ||
|
5de2f8ea2d | ||
|
93f3334ad0 | ||
|
25a2582d15 | ||
|
d076a210a1 | ||
|
b5fc7d6d4d | ||
|
a204325136 | ||
|
0decd4d1b6 | ||
|
34db46d84b | ||
|
c2377f0c13 | ||
|
829888bda7 | ||
|
43f524bb5f | ||
|
34d17a4fcb | ||
|
340c03cedf | ||
|
5085f6cdc9 | ||
|
798f8d92a3 | ||
|
d4061cc139 | ||
|
93b6612c75 | ||
|
48dfee39ae | ||
|
6c0ea67d3d | ||
|
58b8e7908d | ||
|
4e94e83540 | ||
|
d1018a824c | ||
|
4c8ae0afd3 | ||
|
d9b2311e17 | ||
|
21af0243d6 | ||
|
63e3816e92 | ||
|
d60609716b | ||
|
76bd2547e1 | ||
|
ee101353d8 | ||
|
d5bdf1cb90 | ||
|
c8b103a9e8 | ||
|
c3dd3e246e | ||
|
47b06b4978 | ||
|
ad845b5fbf | ||
|
c7958a4bb8 | ||
|
aee8441fc4 | ||
|
703e876f4a | ||
|
d4e77280fc | ||
|
31f19d0d8a | ||
|
32ec475ca2 | ||
|
e8d8cebd8e | ||
|
d48db9aded | ||
|
33fa5aaab8 | ||
|
c501673241 | ||
|
0792c17f55 | ||
|
9697322f1e | ||
|
d8eeab0c00 | ||
|
b2bd73fa78 | ||
|
6e4a51b37f | ||
|
8b4414b799 | ||
|
a2cfcd4ca6 | ||
|
0bf18e7413 | ||
|
5e540f4f97 | ||
|
f83dccda39 | ||
|
98ea463e0e | ||
|
d5959a4681 | ||
|
c886de5deb | ||
|
c8e05a34d6 | ||
|
d94ac48b65 | ||
|
5886bb6b3a | ||
|
8387431534 | ||
|
754a14ff3e | ||
|
ca7d2aeec3 | ||
|
28ba262087 | ||
|
23d2c40e05 | ||
|
4094887624 | ||
|
4492828b9f | ||
|
a2aef5ea4a | ||
|
cc401b2c9d | ||
|
95a31cdd98 | ||
|
d1ec9eb8ab | ||
|
0bcf8b5d21 | ||
|
f32938981c | ||
|
25d1db3852 | ||
|
3ec3d71c5f | ||
|
79b8229b1b | ||
|
06303bb62f | ||
|
1acee3d4c9 | ||
|
b6d6727135 | ||
|
92a83ed01b | ||
|
f85e464ffd | ||
|
852ec86e26 | ||
|
72ae3aa33d | ||
|
d35bd3b073 | ||
|
b074f9fa89 | ||
|
ed46b96ba2 | ||
|
acf71fd702 | ||
|
5f564343ec | ||
|
dfb062af41 | ||
|
d9bb5e6b1f | ||
|
363d8a4121 | ||
|
d9fc76f336 | ||
|
e2c3af2114 | ||
|
7aa9b857c2 | ||
|
327f4b1074 | ||
|
4a58948b27 | ||
|
1f206c3a36 | ||
|
c9144cd824 | ||
|
dd2154c19b | ||
|
dade4eafa5 | ||
|
4f63b471d1 | ||
|
16bb9b3679 | ||
|
6ececb2ceb | ||
|
6edbb23903 | ||
|
50baaaae81 | ||
|
da531f12c2 | ||
|
ba0e852f20 | ||
|
d0ebac37c1 | ||
|
3f9af45493 | ||
|
fd3c427f07 | ||
|
524ecf8acd | ||
|
c4be4d7d61 | ||
|
89a16f2030 | ||
|
1dfc09e4d2 | ||
|
bfd57b66ef | ||
|
71e1fc91f1 | ||
|
14703846a7 | ||
|
5494e89fdb | ||
|
4ca55d3b9b | ||
|
5aa82eda2b | ||
|
d9f2ee0d48 | ||
|
ff83ae975d | ||
|
02130b848c | ||
|
900c0caffa | ||
|
4e74fd0467 | ||
|
6fe26f7f77 | ||
|
fb83a3ca3f | ||
|
14c3dae180 | ||
|
50869757d3 | ||
|
aecbc48d43 | ||
|
0c8a11e28b | ||
|
ffeb6b45aa | ||
|
76d1661768 | ||
|
a14e3b0657 | ||
|
2d335e27ff | ||
|
8fb95f9a84 | ||
|
a5399b6614 | ||
|
199be15f4b | ||
|
055a6527fc | ||
|
842b59605b | ||
|
3818290e4d | ||
|
c5dad20fc4 | ||
|
e5e931356b | ||
|
e7c799ae2a | ||
|
6deaa31d41 | ||
|
1f0aa29307 | ||
|
eeaec2697b | ||
|
630c7980d3 | ||
|
890c0c4723 | ||
|
9c31c21d79 | ||
|
b35a746470 | ||
|
d26f99b496 | ||
|
a1abe14e02 | ||
|
ae9296f989 | ||
|
ea1d9e1d1a | ||
|
b8821acb95 | ||
|
c11e64a782 | ||
|
cc7355358d | ||
|
d2cc8b36b8 | ||
|
3fe3430006 | ||
|
72e1dcb3f9 | ||
|
a2a6afb731 | ||
|
e59114c1c5 | ||
|
6180210170 | ||
|
2b98e96784 | ||
|
364078ce27 | ||
|
fda64ffb1f | ||
|
5257a45bde | ||
|
9a03aac224 | ||
|
f155cc7e92 | ||
|
cee7170763 | ||
|
a969d34c03 | ||
|
515a5f6943 | ||
|
47bb7ad6a1 | ||
|
7d937b36da | ||
|
9243a68b18 | ||
|
371208c24d | ||
|
26030f6ee4 | ||
|
5bd3d9a518 | ||
|
9710d88a88 | ||
|
a83e7318b0 | ||
|
ae376b4195 | ||
|
f7eab66026 | ||
|
9de142b9ad | ||
|
67a4d10b75 | ||
|
56c9b21a28 | ||
|
94af9fc1a3 | ||
|
4bf3bd8343 | ||
|
753a99faf9 | ||
|
9ecf261a76 | ||
|
dfc2eb32c8 | ||
|
2a904c4aea | ||
|
2a322faa6a | ||
|
e4dda3c488 | ||
|
07ef5122bb | ||
|
578c3dda73 | ||
|
0c121ee95a | ||
|
3a6d5faa8a | ||
|
1df209c284 | ||
|
80b29ed5cb | ||
|
4b2575f301 | ||
|
4e7326b61b | ||
|
e3f0a8d35b | ||
|
a1cacbe904 | ||
|
c32e0bdde7 | ||
|
7bc8087d02 | ||
|
91b2dc57fa | ||
|
7fc0ddb60c | ||
|
d0abba23dc | ||
|
15a3cfcb8a | ||
|
ee57675c12 | ||
|
249e2555d0 | ||
|
a6a7810be2 | ||
|
9e8fd3f5a0 | ||
|
cd05650164 | ||
|
d5f6ecf3c3 | ||
|
7f321c9cf6 | ||
|
4f456b2b80 | ||
|
6dde068e71 | ||
|
2aa1dd41f5 | ||
|
26feb448a3 | ||
|
0c9676e7fc | ||
|
bab8a09a80 | ||
|
b0e80137da | ||
|
35e8561bff | ||
|
552a418bae | ||
|
0c9b301a57 | ||
|
3a8a329b0f | ||
|
63e7acb87b | ||
|
145136059e | ||
|
283ceb6bbf | ||
|
d616dfef38 | ||
|
0fb9884ab8 | ||
|
0a413d63aa | ||
|
6fc342d446 | ||
|
fad4e4e75e | ||
|
3b8fd6f62f | ||
|
abe240397d | ||
|
8b5e0df2d7 | ||
|
2b919d0cf2 | ||
|
a03193b2f7 | ||
|
a5a8f6057b | ||
|
fd1fdc6466 | ||
|
6d43eea1bd | ||
|
312969462e | ||
|
999da4945a | ||
|
bf294aa684 | ||
|
a58476d079 | ||
|
65e32f720d | ||
|
35ab677ff1 | ||
|
bfedf20db5 | ||
|
a7516937f7 | ||
|
a42337ad0a | ||
|
c9ab987658 | ||
|
eb798fa4f1 | ||
|
17d4175b47 | ||
|
45d4d1bb3e | ||
|
8fc880b69b | ||
|
30426d21e7 | ||
|
9aac5a22f1 | ||
|
96143177ce | ||
|
c9a1a3eb94 | ||
|
44ade6ad64 | ||
|
44ad69ceca | ||
|
f78bf5e46f | ||
|
94ed548353 | ||
|
6099ffece1 | ||
|
347a515c25 | ||
|
9e54070c1d | ||
|
2d8da60ffc | ||
|
5ff402aabf | ||
|
e07faea874 | ||
|
a5dc505e61 | ||
|
538d66191e | ||
|
928487985d | ||
|
9d73189133 | ||
|
536d4218c2 | ||
|
e3885c2b5c | ||
|
9250be348d | ||
|
8d35ca90e1 | ||
|
24c16f622f | ||
|
9a2968d1eb | ||
|
0937f44f39 | ||
|
075368b5ae | ||
|
90459116e3 | ||
|
d4672b3517 | ||
|
bbf28c74f7 | ||
|
bbd85fc823 | ||
|
291a5f42cd | ||
|
1dd73e74ab | ||
|
03c98fb55a | ||
|
7f9b139ae0 | ||
|
6aaeb754ef | ||
|
144277bdcc | ||
|
823b9db6f6 | ||
|
adad1fde19 | ||
|
8b2d97b946 | ||
|
515f78619f | ||
|
71be63dbb1 | ||
|
a503f58d0c | ||
|
afae8d02be | ||
|
6fef696268 | ||
|
e4290140bc | ||
|
7c93acedc3 | ||
|
ae29f06e44 | ||
|
a2f71d387f | ||
|
8f18d35109 | ||
|
f1923c5364 | ||
|
636c8cb165 | ||
|
513ea97769 | ||
|
93b18e6440 | ||
|
11882827c7 | ||
|
9f1d431c99 | ||
|
d45e9a0c30 | ||
|
2b00cdce7b | ||
|
636e79c438 | ||
|
1641b1f91f | ||
|
7877e6601d | ||
|
08b6ee0297 | ||
|
d7bb92be54 | ||
|
4d18ddba6d | ||
|
1f9fa74786 | ||
|
d78c8b7cc8 | ||
|
d769798ba3 | ||
|
faaa4ba6bc | ||
|
aa10dd98c9 | ||
|
9f98bee362 | ||
|
f372e1a69d | ||
|
5b5b9a91aa | ||
|
b43ac187ec | ||
|
adc5940d15 | ||
|
45e7edc9b8 | ||
|
874127a4f9 | ||
|
d177314676 | ||
|
bab4f21056 | ||
|
188a043967 | ||
|
e75d03fea9 | ||
|
48be0ceb16 | ||
|
0e3ff1699a | ||
|
8a321a7450 | ||
|
092d11bbe6 | ||
|
d956e0ebdc | ||
|
93e0efa241 | ||
|
f27b3361e5 | ||
|
f67abf9e03 | ||
|
7744be3319 | ||
|
07cff878e5 | ||
|
dd6dcf1c5b | ||
|
0382afc488 | ||
|
19eae8cb49 | ||
|
1a1ab1d18a | ||
|
ae79616c73 | ||
|
9c0993908a | ||
|
647b89f8ad | ||
|
591a61a61c | ||
|
4a8b47a6ff | ||
|
1689baa2a4 | ||
|
ca283c0da6 | ||
|
9e049f44e2 | ||
|
0bc0569932 | ||
|
e861b18992 | ||
|
26c0b620f8 | ||
|
324eb695f5 | ||
|
b5139e3ff9 | ||
|
38b1c26396 | ||
|
418a2564b2 | ||
|
8d0261bab3 | ||
|
dc3b18de94 | ||
|
b0cb982978 |
2
.github/readme.md
vendored
2
.github/readme.md
vendored
@ -274,7 +274,7 @@ You will need two mandatory directory mappings and a port mapping to allow Silly
|
||||
1. Open your Command Line
|
||||
2. Run the following command
|
||||
|
||||
`docker create --name='sillytavern' --net='[DockerNet]' -p '8000:8000/tcp' -v '[plugins]':'/home/node/app/plugins':'rw' -v '[config]':'/home/node/app/config':'rw' -v '[data]':'/home/node/app/data':'rw' -v '[extensions]':'/home/node/app/public/scripts/extensions/third-party':'rw' 'ghcr.io/sillytavern/sillytavern:[version]'`
|
||||
`docker run --name='sillytavern' --net='[DockerNet]' -p '8000:8000/tcp' -v '[plugins]':'/home/node/app/plugins':'rw' -v '[config]':'/home/node/app/config':'rw' -v '[data]':'/home/node/app/data':'rw' -v '[extensions]':'/home/node/app/public/scripts/extensions/third-party':'rw' 'ghcr.io/sillytavern/sillytavern:[version]'`
|
||||
|
||||
> Note that 8000 is a default listening port. Don't forget to use an appropriate port if you change it in the config.
|
||||
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -45,6 +45,7 @@ access.log
|
||||
/vectors/
|
||||
/cache/
|
||||
public/css/user.css
|
||||
public/error/
|
||||
/plugins/
|
||||
/data
|
||||
/default/scaffold
|
||||
@ -52,3 +53,5 @@ public/scripts/extensions/third-party
|
||||
/certs
|
||||
.aider*
|
||||
.env
|
||||
/StartDev.bat
|
||||
|
||||
|
@ -6,7 +6,13 @@ cardsCacheCapacity: 100
|
||||
# -- SERVER CONFIGURATION --
|
||||
# Listen for incoming connections
|
||||
listen: false
|
||||
# Listen on a specific address, supports IPv4 and IPv6
|
||||
listenAddress:
|
||||
ipv4: 0.0.0.0
|
||||
ipv6: '[::]'
|
||||
# Enables IPv6 and/or IPv4 protocols. Need to have at least one enabled!
|
||||
# - Use option "auto" to automatically detect support
|
||||
# - Use true or false (no qoutes) to enable or disable each protocol
|
||||
protocol:
|
||||
ipv4: true
|
||||
ipv6: false
|
||||
@ -65,12 +71,14 @@ autheliaAuth: false
|
||||
# the username and passwords for basic auth are the same as those
|
||||
# for the individual accounts
|
||||
perUserBasicAuth: false
|
||||
# Minimum log level to display in the terminal (DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3)
|
||||
minLogLevel: 0
|
||||
|
||||
# User session timeout *in seconds* (defaults to 24 hours).
|
||||
## Set to a positive number to expire session after a certain time of inactivity
|
||||
## Set to 0 to expire session when the browser is closed
|
||||
## Set to a negative number to disable session expiration
|
||||
sessionTimeout: 86400
|
||||
sessionTimeout: -1
|
||||
# Used to sign session cookies. Will be auto-generated if not set
|
||||
cookieSecret: ''
|
||||
# Disable CSRF protection - NOT RECOMMENDED
|
||||
@ -133,24 +141,26 @@ whitelistImportDomains:
|
||||
## headers:
|
||||
## User-Agent: "Googlebot/2.1 (+http://www.google.com/bot.html)"
|
||||
requestOverrides: []
|
||||
# -- EXTENSIONS CONFIGURATION --
|
||||
# Enable UI extensions
|
||||
enableExtensions: true
|
||||
# Automatically update extensions when a release version changes
|
||||
enableExtensionsAutoUpdate: true
|
||||
|
||||
# EXTENSIONS CONFIGURATION
|
||||
extensions:
|
||||
# Enable UI extensions
|
||||
enabled: true
|
||||
# Automatically update extensions when a release version changes
|
||||
autoUpdate: true
|
||||
models:
|
||||
# Enables automatic model download from HuggingFace
|
||||
autoDownload: true
|
||||
# Additional models for extensions. Expects model IDs from HuggingFace model hub in ONNX format
|
||||
classification: Cohee/distilbert-base-uncased-go-emotions-onnx
|
||||
captioning: Xenova/vit-gpt2-image-captioning
|
||||
embedding: Cohee/jina-embeddings-v2-base-en
|
||||
speechToText: Xenova/whisper-small
|
||||
textToSpeech: Xenova/speecht5_tts
|
||||
|
||||
# Additional model tokenizers can be downloaded on demand.
|
||||
# Disabling will fallback to another locally available tokenizer.
|
||||
enableDownloadableTokenizers: true
|
||||
# Extension settings
|
||||
extras:
|
||||
# Disables automatic model download from HuggingFace
|
||||
disableAutoDownload: false
|
||||
# Extra models for plugins. Expects model IDs from HuggingFace model hub in ONNX format
|
||||
classificationModel: Cohee/distilbert-base-uncased-go-emotions-onnx
|
||||
captioningModel: Xenova/vit-gpt2-image-captioning
|
||||
embeddingModel: Cohee/jina-embeddings-v2-base-en
|
||||
speechToTextModel: Xenova/whisper-small
|
||||
textToSpeechModel: Xenova/speecht5_tts
|
||||
# -- OPENAI CONFIGURATION --
|
||||
# A placeholder message to use in strict prompt post-processing mode when the prompt doesn't start with a user message
|
||||
promptPlaceholder: "[Start a new chat]"
|
||||
@ -177,6 +187,10 @@ ollama:
|
||||
# * 0: Unload the model immediately after the request
|
||||
# * N (any positive number): Keep the model loaded for N seconds after the request.
|
||||
keepAlive: -1
|
||||
# Controls the "num_batch" (batch size) parameter of the generation request
|
||||
# * -1: Use the default value of the model
|
||||
# * N (positive number): Use the specified value. Must be a power of 2, e.g. 128, 256, 512, etc.
|
||||
batchSize: -1
|
||||
# -- ANTHROPIC CLAUDE API CONFIGURATION --
|
||||
claude:
|
||||
# Enables caching of the system prompt (if supported).
|
||||
@ -196,3 +210,5 @@ claude:
|
||||
cachingAtDepth: -1
|
||||
# -- SERVER PLUGIN CONFIGURATION --
|
||||
enableServerPlugins: false
|
||||
# Attempt to automatically update server plugins on startup
|
||||
enableServerPluginsAutoUpdate: true
|
||||
|
@ -671,10 +671,6 @@
|
||||
"filename": "presets/moving-ui/Default.json",
|
||||
"type": "moving_ui"
|
||||
},
|
||||
{
|
||||
"filename": "presets/moving-ui/Black Magic Time.json",
|
||||
"type": "moving_ui"
|
||||
},
|
||||
{
|
||||
"filename": "presets/quick-replies/Default.json",
|
||||
"type": "quick_replies"
|
||||
@ -782,5 +778,13 @@
|
||||
{
|
||||
"filename": "presets/context/Mistral V7.json",
|
||||
"type": "context"
|
||||
},
|
||||
{
|
||||
"filename": "presets/instruct/DeepSeek-V2.5.json",
|
||||
"type": "instruct"
|
||||
},
|
||||
{
|
||||
"filename": "presets/context/DeepSeek-V2.5.json",
|
||||
"type": "context"
|
||||
}
|
||||
]
|
||||
|
11
default/content/presets/context/DeepSeek-V2.5.json
Normal file
11
default/content/presets/context/DeepSeek-V2.5.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"story_string": "{{#if system}}{{system}}\n{{/if}}{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}{{trim}}\n",
|
||||
"example_separator": "",
|
||||
"chat_start": "",
|
||||
"use_stop_strings": false,
|
||||
"allow_jailbreak": false,
|
||||
"always_force_name2": true,
|
||||
"trim_sentences": false,
|
||||
"single_line": false,
|
||||
"name": "DeepSeek-V2.5"
|
||||
}
|
22
default/content/presets/instruct/DeepSeek-V2.5.json
Normal file
22
default/content/presets/instruct/DeepSeek-V2.5.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"input_sequence": "<|User|>",
|
||||
"output_sequence": "<|Assistant|>",
|
||||
"first_output_sequence": "",
|
||||
"last_output_sequence": "",
|
||||
"system_sequence_prefix": "",
|
||||
"system_sequence_suffix": "",
|
||||
"stop_sequence": "",
|
||||
"wrap": false,
|
||||
"macro": true,
|
||||
"names_behavior": "force",
|
||||
"activation_regex": "",
|
||||
"skip_examples": false,
|
||||
"output_suffix": "<|end▁of▁sentence|>",
|
||||
"input_suffix": "",
|
||||
"system_sequence": "",
|
||||
"system_suffix": "",
|
||||
"user_alignment_message": "",
|
||||
"last_system_sequence": "",
|
||||
"system_same_as_user": true,
|
||||
"name": "DeepSeek-V2.5"
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
{
|
||||
"name": "Black Magic Time",
|
||||
"movingUIState": {
|
||||
"sheld": {
|
||||
"top": 488,
|
||||
"left": 1407,
|
||||
"right": 1,
|
||||
"bottom": 4,
|
||||
"margin": "unset",
|
||||
"width": 471,
|
||||
"height": 439
|
||||
},
|
||||
"floatingPrompt": {
|
||||
"width": 369,
|
||||
"height": 441
|
||||
},
|
||||
"right-nav-panel": {
|
||||
"top": 0,
|
||||
"left": 1400,
|
||||
"right": 111,
|
||||
"bottom": 446,
|
||||
"margin": "unset",
|
||||
"width": 479,
|
||||
"height": 487
|
||||
},
|
||||
"WorldInfo": {
|
||||
"top": 41,
|
||||
"left": 369,
|
||||
"right": 642,
|
||||
"bottom": 51,
|
||||
"margin": "unset",
|
||||
"width": 1034,
|
||||
"height": 858
|
||||
},
|
||||
"left-nav-panel": {
|
||||
"top": 442,
|
||||
"left": 0,
|
||||
"right": 1546,
|
||||
"bottom": 25,
|
||||
"margin": "unset",
|
||||
"width": 368,
|
||||
"height": 483
|
||||
}
|
||||
}
|
||||
}
|
22
default/public/error/forbidden-by-whitelist.html
Normal file
22
default/public/error/forbidden-by-whitelist.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Forbidden</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Forbidden</h1>
|
||||
<p>
|
||||
If you are the system administrator, add your IP address to the
|
||||
whitelist or disable whitelist mode by editing
|
||||
<code>config.yaml</code> in the root directory of your installation.
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<em>Connection from {{ipDetails}} has been blocked. This attempt
|
||||
has been logged.</em>
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
17
default/public/error/unauthorized.html
Normal file
17
default/public/error/unauthorized.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Unauthorized</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Unauthorized</h1>
|
||||
<p>
|
||||
If you are the system administrator, you can configure the
|
||||
<code>basicAuthUser</code> credentials by editing
|
||||
<code>config.yaml</code> in the root directory of your installation.
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
15
default/public/error/url-not-found.html
Normal file
15
default/public/error/url-not-found.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Not found</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Not found</h1>
|
||||
<p>
|
||||
The requested URL was not found on this server.
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
26
index.d.ts
vendored
26
index.d.ts
vendored
@ -1,6 +1,24 @@
|
||||
import { UserDirectoryList, User } from "./src/users";
|
||||
import { CsrfSyncedToken } from "csrf-sync";
|
||||
|
||||
declare global {
|
||||
declare namespace CookieSessionInterfaces {
|
||||
export interface CookieSessionObject {
|
||||
/**
|
||||
* The CSRF token for the session.
|
||||
*/
|
||||
csrfToken: CsrfSyncedToken;
|
||||
/**
|
||||
* Authenticated user handle.
|
||||
*/
|
||||
handle: string;
|
||||
/**
|
||||
* Last time the session was extended.
|
||||
*/
|
||||
touch: number;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Express {
|
||||
export interface Request {
|
||||
user: {
|
||||
@ -15,11 +33,3 @@ declare global {
|
||||
*/
|
||||
var DATA_ROOT: string;
|
||||
}
|
||||
|
||||
declare module 'express-session' {
|
||||
export interface SessionData {
|
||||
handle: string;
|
||||
touch: number;
|
||||
// other properties...
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"**/.git/**",
|
||||
"public/lib/**",
|
||||
"public/**",
|
||||
"backups/**",
|
||||
"data/**",
|
||||
"cache/**",
|
||||
|
59
package-lock.json
generated
59
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "sillytavern",
|
||||
"version": "1.12.11",
|
||||
"version": "1.12.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sillytavern",
|
||||
"version": "1.12.11",
|
||||
"version": "1.12.12",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
@ -26,9 +26,9 @@
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cookie-session": "^2.1.0",
|
||||
"cors": "^2.8.5",
|
||||
"csrf-csrf": "^2.2.3",
|
||||
"csrf-sync": "^4.0.3",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"dompurify": "^3.1.7",
|
||||
"dompurify": "^3.2.4",
|
||||
"droll": "^0.2.1",
|
||||
"express": "^4.21.0",
|
||||
"form-data": "^4.0.0",
|
||||
@ -41,6 +41,7 @@
|
||||
"html-entities": "^2.5.2",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
"ip-regex": "^5.0.0",
|
||||
"ipaddr.js": "^2.0.1",
|
||||
"jimp": "^0.22.10",
|
||||
"localforage": "^1.10.0",
|
||||
@ -86,6 +87,7 @@
|
||||
"@types/cookie-session": "^2.0.49",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/deno": "^2.0.0",
|
||||
"@types/dompurify": "^3.2.0",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/jquery": "^3.5.29",
|
||||
"@types/jquery-cropper": "^1.0.4",
|
||||
@ -1179,6 +1181,17 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/dompurify": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.2.0.tgz",
|
||||
"integrity": "sha512-Fgg31wv9QbLDA0SpTOXO3MaxySc4DKGLi8sna4/Utjo4r3ZRPdCt4UQee8BWr+Q5z21yifghREPJGYaEOEIACg==",
|
||||
"deprecated": "This is a stub types definition. dompurify provides its own type definitions, so you do not need this installed.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dompurify": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
|
||||
@ -1462,6 +1475,13 @@
|
||||
"@types/jquery": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@types/write-file-atomic": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/write-file-atomic/-/write-file-atomic-4.0.3.tgz",
|
||||
@ -2987,10 +3007,10 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/csrf-csrf": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/csrf-csrf/-/csrf-csrf-2.2.4.tgz",
|
||||
"integrity": "sha512-LuhBmy5RfRmEfeqeYqgaAuS1eDpVtKZB/Eiec9xiKQLBynJxrGVRdM2yRT/YMl1Njo/yKh2L9AYsIwSlTPnx2A==",
|
||||
"node_modules/csrf-sync": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/csrf-sync/-/csrf-sync-4.0.3.tgz",
|
||||
"integrity": "sha512-wXzltBBzt/7imzDt6ZT7G/axQG7jo4Sm0uXDUzFY8hR59qhDHdjqpW2hojS4oAVIZDzwlMQloIVCTJoDDh0wwA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"http-errors": "^2.0.0"
|
||||
@ -3217,10 +3237,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "3.1.7",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.7.tgz",
|
||||
"integrity": "sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)"
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.4.tgz",
|
||||
"integrity": "sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optionalDependencies": {
|
||||
"@types/trusted-types": "^2.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "3.1.0",
|
||||
@ -4610,6 +4633,18 @@
|
||||
"integrity": "sha512-/ok+VhKMasgR5gvTRViwRFQfc0qYt9Vdowg6TO4/pFlDCob5ZjGPkwuOoQVCd5OrMm20zqh+1vA8KLJZTeWudg==",
|
||||
"license": "LGPL-3.0-only"
|
||||
},
|
||||
"node_modules/ip-regex": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",
|
||||
"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.1.0.tgz",
|
||||
|
@ -16,9 +16,9 @@
|
||||
"cookie-parser": "^1.4.6",
|
||||
"cookie-session": "^2.1.0",
|
||||
"cors": "^2.8.5",
|
||||
"csrf-csrf": "^2.2.3",
|
||||
"csrf-sync": "^4.0.3",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"dompurify": "^3.1.7",
|
||||
"dompurify": "^3.2.4",
|
||||
"droll": "^0.2.1",
|
||||
"express": "^4.21.0",
|
||||
"form-data": "^4.0.0",
|
||||
@ -31,6 +31,7 @@
|
||||
"html-entities": "^2.5.2",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
"ip-regex": "^5.0.0",
|
||||
"ipaddr.js": "^2.0.1",
|
||||
"jimp": "^0.22.10",
|
||||
"localforage": "^1.10.0",
|
||||
@ -86,9 +87,10 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/SillyTavern/SillyTavern.git"
|
||||
},
|
||||
"version": "1.12.11",
|
||||
"version": "1.12.12",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"debug": "node server.js --inspect",
|
||||
"start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js",
|
||||
"start:bun": "bun server.js",
|
||||
"start:no-csrf": "node server.js --disableCsrf",
|
||||
@ -114,6 +116,7 @@
|
||||
"@types/cookie-session": "^2.0.49",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/deno": "^2.0.0",
|
||||
"@types/dompurify": "^3.2.0",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/jquery": "^3.5.29",
|
||||
"@types/jquery-cropper": "^1.0.4",
|
||||
|
@ -48,6 +48,13 @@ async function updatePlugins() {
|
||||
console.log(`Updating plugin ${color.green(directory)}...`);
|
||||
const pluginPath = path.join(pluginsPath, directory);
|
||||
const pluginRepo = git(pluginPath);
|
||||
|
||||
const isRepo = await pluginRepo.checkIsRepo();
|
||||
if (!isRepo) {
|
||||
console.log(`Directory ${color.yellow(directory)} is not a Git repository`);
|
||||
continue;
|
||||
}
|
||||
|
||||
await pluginRepo.fetch();
|
||||
const commitHash = await pluginRepo.revparse(['HEAD']);
|
||||
const trackingBranch = await pluginRepo.revparse(['--abbrev-ref', '@{u}']);
|
||||
|
102
post-install.js
102
post-install.js
@ -64,6 +64,46 @@ const keyMigrationMap = [
|
||||
newKey: 'backups.chat.throttleInterval',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'enableExtensions',
|
||||
newKey: 'extensions.enabled',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'enableExtensionsAutoUpdate',
|
||||
newKey: 'extensions.autoUpdate',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.disableAutoDownload',
|
||||
newKey: 'extensions.models.autoDownload',
|
||||
migrate: (value) => !value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.classificationModel',
|
||||
newKey: 'extensions.models.classification',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.captioningModel',
|
||||
newKey: 'extensions.models.captioning',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.embeddingModel',
|
||||
newKey: 'extensions.models.embedding',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.speechToTextModel',
|
||||
newKey: 'extensions.models.speechToText',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
{
|
||||
oldKey: 'extras.textToSpeechModel',
|
||||
newKey: 'extensions.models.textToSpeech',
|
||||
migrate: (value) => value,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
@ -73,7 +113,7 @@ const keyMigrationMap = [
|
||||
* @returns {string[]} Array of all keys in the object
|
||||
*/
|
||||
function getAllKeys(obj, prefix = '') {
|
||||
if (typeof obj !== 'object' || Array.isArray(obj)) {
|
||||
if (typeof obj !== 'object' || Array.isArray(obj) || obj === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -173,20 +213,60 @@ function addMissingConfigValues() {
|
||||
* Creates the default config files if they don't exist yet.
|
||||
*/
|
||||
function createDefaultFiles() {
|
||||
const files = {
|
||||
config: './config.yaml',
|
||||
user: './public/css/user.css',
|
||||
};
|
||||
/**
|
||||
* @typedef DefaultItem
|
||||
* @type {object}
|
||||
* @property {'file' | 'directory'} type - Whether the item should be copied as a single file or merged into a directory structure.
|
||||
* @property {string} defaultPath - The path to the default item (typically in `default/`).
|
||||
* @property {string} productionPath - The path to the copied item for production use.
|
||||
*/
|
||||
|
||||
for (const file of Object.values(files)) {
|
||||
/** @type {DefaultItem[]} */
|
||||
const defaultItems = [
|
||||
{
|
||||
type: 'file',
|
||||
defaultPath: './default/config.yaml',
|
||||
productionPath: './config.yaml',
|
||||
},
|
||||
{
|
||||
type: 'directory',
|
||||
defaultPath: './default/public/',
|
||||
productionPath: './public/',
|
||||
},
|
||||
];
|
||||
|
||||
for (const defaultItem of defaultItems) {
|
||||
try {
|
||||
if (!fs.existsSync(file)) {
|
||||
const defaultFilePath = path.join('./default', path.parse(file).base);
|
||||
fs.copyFileSync(defaultFilePath, file);
|
||||
console.log(color.green(`Created default file: ${file}`));
|
||||
if (defaultItem.type === 'file') {
|
||||
if (!fs.existsSync(defaultItem.productionPath)) {
|
||||
fs.copyFileSync(
|
||||
defaultItem.defaultPath,
|
||||
defaultItem.productionPath,
|
||||
);
|
||||
console.log(
|
||||
color.green(`Created default file: ${defaultItem.productionPath}`),
|
||||
);
|
||||
}
|
||||
} else if (defaultItem.type === 'directory') {
|
||||
fs.cpSync(defaultItem.defaultPath, defaultItem.productionPath, {
|
||||
force: false, // Don't overwrite existing files!
|
||||
recursive: true,
|
||||
});
|
||||
console.log(
|
||||
color.green(`Synchronized missing files: ${defaultItem.productionPath}`),
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
'FATAL: Unexpected default file format in `post-install.js#createDefaultFiles()`.',
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(color.red(`FATAL: Could not write default file: ${file}`), error);
|
||||
console.error(
|
||||
color.red(
|
||||
`FATAL: Could not write default ${defaultItem.type}: ${defaultItem.productionPath}`,
|
||||
),
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -216,8 +216,6 @@
|
||||
|
||||
}
|
||||
|
||||
#showRawPrompt,
|
||||
#copyPromptToClipboard,
|
||||
#groupCurrentMemberPopoutButton,
|
||||
#summaryExtensionPopoutButton {
|
||||
display: none;
|
||||
|
@ -72,6 +72,10 @@ dialog {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.popup.left_aligned_dialogue_popup .popup-content {
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
/* Opening animation */
|
||||
.popup[opening] {
|
||||
animation: pop-in var(--popup-animation-speed) ease-in-out;
|
||||
|
@ -100,6 +100,13 @@
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
}
|
||||
|
||||
.select2-container .select2-results .select2-results__option--disabled {
|
||||
color: inherit;
|
||||
background-color: inherit;
|
||||
cursor: not-allowed;
|
||||
filter: brightness(0.5);
|
||||
}
|
||||
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice,
|
||||
.select2-container .select2-selection--single .select2-selection__choice {
|
||||
border-radius: 5px;
|
||||
|
@ -472,6 +472,11 @@ label[for="trim_spaces"]:has(input:checked) i.warning {
|
||||
display: none;
|
||||
}
|
||||
|
||||
label[for="trim_spaces"]:not(:has(input:checked)) small {
|
||||
color: var(--warning);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#claude_function_prefill_warning {
|
||||
display: none;
|
||||
color: red;
|
||||
@ -488,3 +493,7 @@ label[for="trim_spaces"]:has(input:checked) i.warning {
|
||||
#mistralai_other_models:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#banned_tokens_block_ooba:not(:has(#send_banned_tokens_textgenerationwebui:checked)) #banned_tokens_controls_ooba {
|
||||
filter: brightness(0.5);
|
||||
}
|
||||
|
@ -730,7 +730,7 @@
|
||||
<input type="range" id="top_k_openai" name="volume" min="0" max="500" step="1">
|
||||
</div>
|
||||
<div class="range-block-counter">
|
||||
<input type="number" min="0" max="200" step="1" data-for="top_k_openai" id="top_k_counter_openai">
|
||||
<input type="number" min="0" max="500" step="1" data-for="top_k_openai" id="top_k_counter_openai">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1587,6 +1587,10 @@
|
||||
<input type="checkbox" id="skip_special_tokens_textgenerationwebui" />
|
||||
<small data-i18n="Skip Special Tokens">Skip Special Tokens</small>
|
||||
</label>
|
||||
<label data-tg-type="openrouter" class="checkbox_label flexGrow flexShrink" for="include_reasoning_textgenerationwebui">
|
||||
<input type="checkbox" id="include_reasoning_textgenerationwebui" />
|
||||
<small data-i18n="Request Model Reasoning">Request Model Reasoning</small>
|
||||
</label>
|
||||
<label data-tg-type="ooba, aphrodite, tabby" class="checkbox_label flexGrow flexShrink" for="temperature_last_textgenerationwebui">
|
||||
<input type="checkbox" id="temperature_last_textgenerationwebui" />
|
||||
<label>
|
||||
@ -1617,17 +1621,34 @@
|
||||
</div>
|
||||
<div data-tg-type-mode="except" data-tg-type="generic" id="banned_tokens_block_ooba" class="wide100p">
|
||||
<hr class="width100p">
|
||||
<h4 class="range-block-title justifyCenter">
|
||||
<span data-i18n="Banned Tokens">Banned Tokens/Strings</span>
|
||||
<div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output. Unquoted text will be tokenized in the back end and banned as tokens. [token ids] will be banned as-is. Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure. Enclose text in double quotes to ban the entire string as a set. Quoted Strings and [Token ids] must be on their own line."></div>
|
||||
</h4>
|
||||
<div class="wide100p">
|
||||
<textarea id="banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens [420, 69, 1337] "Some verbatim string"'></textarea>
|
||||
<div class="range-block-title title_restorable">
|
||||
<div>
|
||||
<strong data-i18n="Banned Tokens">Banned Tokens/Strings</strong>
|
||||
<div class="margin5 fa-solid fa-circle-info opacity50p " data-i18n="[title]LLaMA / Mistral / Yi models only" title="Enter sequences you don't want to appear in the output. Unquoted text will be tokenized in the back end and banned as tokens. [token ids] will be banned as-is. Most tokens have a leading space. Use token counter (with the correct tokenizer selected first!) if you are unsure. Enclose text in double quotes to ban the entire string as a set. Quoted Strings and [Token ids] must be on their own line."></div>
|
||||
</div>
|
||||
<label id="send_banned_tokens_label" for="send_banned_tokens_textgenerationwebui" class="checkbox_label">
|
||||
<input id="send_banned_tokens_textgenerationwebui" type="checkbox" style="display:none;" />
|
||||
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
|
||||
</label>
|
||||
</div>
|
||||
<div id="banned_tokens_controls_ooba">
|
||||
<div class="textAlignCenter">
|
||||
<small data-i18n="Global list">Global list</small>
|
||||
</div>
|
||||
<div class="wide100p marginBot10">
|
||||
<textarea id="global_banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="global_banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens [420, 69, 1337] "Some verbatim string"'></textarea>
|
||||
</div>
|
||||
<div class="textAlignCenter">
|
||||
<small data-i18n="Preset-specific list">Preset-specific list</small>
|
||||
</div>
|
||||
<div class="wide100p">
|
||||
<textarea id="banned_tokens_textgenerationwebui" class="text_pole textarea_compact" name="banned_tokens_textgenerationwebui" rows="3" data-i18n="[placeholder]Example: some text [42, 69, 1337]" placeholder='some text as tokens [420, 69, 1337] "Some verbatim string"'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block wide100p">
|
||||
<div id="logit_bias_textgenerationwebui" class="range-block-title title_restorable">
|
||||
<span data-i18n="Logit Bias">Logit Bias</span>
|
||||
<strong data-i18n="Logit Bias">Logit Bias</strong>
|
||||
<div id="textgen_logit_bias_new_entry" class="menu_button menu_button_icon">
|
||||
<i class="fa-xs fa-solid fa-plus"></i>
|
||||
<small data-i18n="Add">Add</small>
|
||||
@ -1930,7 +1951,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq">
|
||||
<div class="range-block" data-source="openai,cohere,mistralai,custom,claude,openrouter,groq,deepseek">
|
||||
<label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand">
|
||||
<input id="openai_function_calling" type="checkbox" />
|
||||
<span data-i18n="Enable function calling">Enable function calling</span>
|
||||
@ -1953,14 +1974,16 @@
|
||||
<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">
|
||||
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
|
||||
Inline Image Quality
|
||||
</label>
|
||||
<select id="openai_inline_image_quality">
|
||||
<option data-i18n="openai_inline_image_quality_auto" value="auto">Auto</option>
|
||||
<option data-i18n="openai_inline_image_quality_low" value="low">Low</option>
|
||||
<option data-i18n="openai_inline_image_quality_high" value="high">High</option>
|
||||
</select>
|
||||
<div class="flex-container oneline-dropdown">
|
||||
<label for="openai_inline_image_quality" data-i18n="Inline Image Quality">
|
||||
Inline Image Quality
|
||||
</label>
|
||||
<select id="openai_inline_image_quality">
|
||||
<option data-i18n="openai_inline_image_quality_auto" value="auto">Auto</option>
|
||||
<option data-i18n="openai_inline_image_quality_low" value="low">Low</option>
|
||||
<option data-i18n="openai_inline_image_quality_high" value="high">High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="makersuite">
|
||||
@ -1977,20 +2000,32 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="makersuite">
|
||||
<div class="range-block" data-source="deepseek,openrouter">
|
||||
<label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
|
||||
<input id="openai_show_thoughts" type="checkbox" />
|
||||
<span>
|
||||
<span data-i18n="Show model thoughts">Show model thoughts</span>
|
||||
<i class="opacity50p fa-solid fa-circle-info" title="Gemini 2.0 Thinking"></i>
|
||||
<span data-i18n="Request model reasoning">Request model reasoning</span>
|
||||
<i class="opacity50p fa-solid fa-circle-info" title="DeepSeek Reasoner"></i>
|
||||
</span>
|
||||
</label>
|
||||
<div class="toggle-description justifyLeft marginBot5">
|
||||
<span data-i18n="Display the model's internal thoughts in the response.">
|
||||
Display the model's internal thoughts in the response.
|
||||
<span data-i18n="Allows the model to return its thinking process.">
|
||||
Allows the model to return its thinking process.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
|
||||
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.">
|
||||
<label for="openai_reasoning_effort" data-i18n="Reasoning Effort">
|
||||
Reasoning Effort
|
||||
</label>
|
||||
<select id="openai_reasoning_effort">
|
||||
<option data-i18n="openai_reasoning_effort_low" value="low">Low</option>
|
||||
<option data-i18n="openai_reasoning_effort_medium" value="medium">Medium</option>
|
||||
<option data-i18n="openai_reasoning_effort_high" value="high">High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="claude">
|
||||
<div class="wide100p">
|
||||
<div class="flex-container alignItemsCenter">
|
||||
@ -2692,7 +2727,7 @@
|
||||
<option value="windowai">Window AI</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<div class="inline-drawer wide100p" data-source="openai,claude,mistralai,makersuite">
|
||||
<div class="inline-drawer wide100p" data-source="openai,claude,mistralai,makersuite,deepseek">
|
||||
<div class="inline-drawer-toggle inline-drawer-header">
|
||||
<b data-i18n="Reverse Proxy">Reverse Proxy</b>
|
||||
<div class="fa-solid fa-circle-chevron-down inline-drawer-icon down"></div>
|
||||
@ -2755,7 +2790,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ReverseProxyWarningMessage" data-source="openai,claude,mistralai,makersuite">
|
||||
<div id="ReverseProxyWarningMessage" data-source="openai,claude,mistralai,makersuite,deepseek">
|
||||
<div class="reverse_proxy_warning">
|
||||
<b>
|
||||
<div data-i18n="Using a proxy that you're not running yourself is a risk to your data privacy.">
|
||||
@ -2805,27 +2840,6 @@
|
||||
<div>
|
||||
<h4 data-i18n="OpenAI Model">OpenAI Model</h4>
|
||||
<select id="model_openai_select">
|
||||
<optgroup label="GPT-3.5 Turbo">
|
||||
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
|
||||
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
|
||||
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-0613">gpt-3.5-turbo-0613 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-0301">gpt-3.5-turbo-0301 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-16k">gpt-3.5-turbo-16k</option>
|
||||
<option value="gpt-3.5-turbo-16k-0613">gpt-3.5-turbo-16k-0613 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-3.5 Turbo Instruct">
|
||||
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
|
||||
<option value="gpt-3.5-turbo-instruct-0914">gpt-3.5-turbo-instruct-0914</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4">
|
||||
<option value="gpt-4">gpt-4</option>
|
||||
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
|
||||
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
|
||||
<option value="gpt-4-32k">gpt-4-32k</option>
|
||||
<option value="gpt-4-32k-0613">gpt-4-32k-0613 (2023)</option>
|
||||
<option value="gpt-4-32k-0314">gpt-4-32k-0314 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4o">
|
||||
<option value="gpt-4o">gpt-4o</option>
|
||||
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
|
||||
@ -2833,29 +2847,44 @@
|
||||
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
|
||||
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
|
||||
</optgroup>
|
||||
<optgroup label="gpt-4o-mini">
|
||||
<optgroup label="GPT-4o mini">
|
||||
<option value="gpt-4o-mini">gpt-4o-mini</option>
|
||||
<option value="gpt-4o-mini-2024-07-18">gpt-4o-mini-2024-07-18</option>
|
||||
<option value="gpt-4o-2024-11-20">gpt-4o-2024-11-20</option>
|
||||
<option value="gpt-4o-2024-08-06">gpt-4o-2024-08-06</option>
|
||||
<option value="gpt-4o-2024-05-13">gpt-4o-2024-05-13</option>
|
||||
<option value="chatgpt-4o-latest">chatgpt-4o-latest</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4 Turbo">
|
||||
<optgroup label="o1 and o1-mini">
|
||||
<option value="o1">o1</option>
|
||||
<option value="o1-2024-12-17">o1-2024-12-17</option>
|
||||
<option value="o1-mini">o1-mini</option>
|
||||
<option value="o1-mini-2024-09-12">o1-mini-2024-09-12</option>
|
||||
<option value="o1-preview">o1-preview</option>
|
||||
<option value="o1-preview-2024-09-12">o1-preview-2024-09-12</option>
|
||||
</optgroup>
|
||||
<optgroup label="o3">
|
||||
<option value="o3-mini">o3-mini</option>
|
||||
<option value="o3-mini-2025-01-31">o3-mini-2025-01-31</option>
|
||||
</optgroup>
|
||||
<optgroup label="GPT-4 Turbo and GPT-4">
|
||||
<option value="gpt-4-turbo">gpt-4-turbo</option>
|
||||
<option value="gpt-4-turbo-2024-04-09">gpt-4-turbo-2024-04-09</option>
|
||||
<option value="gpt-4-turbo-preview">gpt-4-turbo-preview</option>
|
||||
<option value="gpt-4-vision-preview">gpt-4-vision-preview</option>
|
||||
<option value="gpt-4-0125-preview">gpt-4-0125-preview (2024)</option>
|
||||
<option value="gpt-4-1106-preview">gpt-4-1106-preview (2023)</option>
|
||||
<option value="gpt-4">gpt-4</option>
|
||||
<option value="gpt-4-0613">gpt-4-0613 (2023)</option>
|
||||
<option value="gpt-4-0314">gpt-4-0314 (2023)</option>
|
||||
</optgroup>
|
||||
<optgroup label="o1">
|
||||
<option value="o1-preview">o1-preview</option>
|
||||
<option value="o1-mini">o1-mini</option>
|
||||
<optgroup label="GPT-3.5 Turbo">
|
||||
<option value="gpt-3.5-turbo">gpt-3.5-turbo</option>
|
||||
<option value="gpt-3.5-turbo-0125">gpt-3.5-turbo-0125 (2024)</option>
|
||||
<option value="gpt-3.5-turbo-1106">gpt-3.5-turbo-1106 (2023)</option>
|
||||
<option value="gpt-3.5-turbo-instruct">gpt-3.5-turbo-instruct</option>
|
||||
</optgroup>
|
||||
<optgroup label="Other">
|
||||
<option value="text-davinci-003">text-davinci-003</option>
|
||||
<option value="text-davinci-002">text-davinci-002</option>
|
||||
<option value="text-curie-001">text-curie-001</option>
|
||||
<option value="text-babbage-001">text-babbage-001</option>
|
||||
<option value="text-ada-001">text-ada-001</option>
|
||||
<option value="code-davinci-002">code-davinci-002</option>
|
||||
<option value="babbage-002">babbage-002</option>
|
||||
<option value="davinci-002">davinci-002</option>
|
||||
</optgroup>
|
||||
<optgroup id="openai_external_category" label="External">
|
||||
</optgroup>
|
||||
@ -3054,6 +3083,7 @@
|
||||
<h4 data-i18n="Google Model">Google Model</h4>
|
||||
<select id="model_google_select">
|
||||
<optgroup label="Primary">
|
||||
<option value="gemini-2.0-flash">Gemini 2.0 Flash</option>
|
||||
<option value="gemini-1.5-pro">Gemini 1.5 Pro</option>
|
||||
<option value="gemini-1.5-flash">Gemini 1.5 Flash</option>
|
||||
<option value="gemini-1.0-pro">Gemini 1.0 Pro (Deprecated)</option>
|
||||
@ -3062,7 +3092,14 @@
|
||||
<option value="gemini-1.0-ultra-latest">Gemini 1.0 Ultra</option>
|
||||
</optgroup>
|
||||
<optgroup label="Subversions">
|
||||
<option value="gemini-2.0-flash-thinking-exp-1219">Gemini 2.0 Flash Thinking Experimental</option>
|
||||
<option value="gemini-2.0-pro-exp">Gemini 2.0 Pro Experimental</option>
|
||||
<option value="gemini-2.0-pro-exp-02-05">Gemini 2.0 Pro Experimental 2025-02-05</option>
|
||||
<option value="gemini-2.0-flash-lite-preview">Gemini 2.0 Flash-Lite Preview</option>
|
||||
<option value="gemini-2.0-flash-lite-preview-02-05">Gemini 2.0 Flash-Lite Preview 2025-02-05</option>
|
||||
<option value="gemini-2.0-flash-001">Gemini 2.0 Flash [001]</option>
|
||||
<option value="gemini-2.0-flash-thinking-exp">Gemini 2.0 Flash Thinking Experimental</option>
|
||||
<option value="gemini-2.0-flash-thinking-exp-01-21">Gemini 2.0 Flash Thinking Experimental 2025-01-21</option>
|
||||
<option value="gemini-2.0-flash-thinking-exp-1219">Gemini 2.0 Flash Thinking Experimental 2024-12-19</option>
|
||||
<option value="gemini-2.0-flash-exp">Gemini 2.0 Flash Experimental</option>
|
||||
<option value="gemini-exp-1114">Gemini Experimental 2024-11-14</option>
|
||||
<option value="gemini-exp-1121">Gemini Experimental 2024-11-21</option>
|
||||
@ -3149,34 +3186,22 @@
|
||||
</div>
|
||||
<h4 data-i18n="Groq Model">Groq Model</h4>
|
||||
<select id="model_groq_select">
|
||||
<optgroup label="Llama 3.3">
|
||||
<optgroup label="Production Models">
|
||||
<option value="gemma2-9b-it">gemma2-9b-it</option>
|
||||
<option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile</option>
|
||||
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option>
|
||||
<option value="llama3-70b-8192">llama3-70b-8192</option>
|
||||
<option value="llama3-8b-8192">llama3-8b-8192</option>
|
||||
<option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option>
|
||||
</optgroup>
|
||||
<optgroup label="Llama 3.2">
|
||||
<optgroup label="Preview Models">
|
||||
<option value="deepseek-r1-distill-llama-70b">deepseek-r1-distill-llama-70b</option>
|
||||
<option value="llama-3.3-70b-specdec">llama-3.3-70b-specdec</option>
|
||||
<option value="llama-3.2-1b-preview">llama-3.2-1b-preview</option>
|
||||
<option value="llama-3.2-3b-preview">llama-3.2-3b-preview</option>
|
||||
<option value="llama-3.2-11b-vision-preview">llama-3.2-11b-vision-preview</option>
|
||||
<option value="llama-3.2-90b-vision-preview">llama-3.2-90b-vision-preview</option>
|
||||
</optgroup>
|
||||
<optgroup label="Llama 3.1">
|
||||
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option>
|
||||
<option value="llama-3.1-70b-versatile">llama-3.1-70b-versatile</option>
|
||||
<option value="llama-3.1-405b-reasoning">llama-3.1-405b-reasoning</option>
|
||||
</optgroup>
|
||||
<optgroup label="Llama 3">
|
||||
<option value="llama3-groq-8b-8192-tool-use-preview">llama3-groq-8b-8192-tool-use-preview</option>
|
||||
<option value="llama3-groq-70b-8192-tool-use-preview">llama3-groq-70b-8192-tool-use-preview</option>
|
||||
<option value="llama3-8b-8192">llama3-8b-8192</option>
|
||||
<option value="llama3-70b-8192">llama3-70b-8192</option>
|
||||
</optgroup>
|
||||
<optgroup label="Gemma">
|
||||
<option value="gemma-7b-it">gemma-7b-it</option>
|
||||
<option value="gemma2-9b-it">gemma2-9b-it</option>
|
||||
</optgroup>
|
||||
<optgroup label="Other">
|
||||
<option value="mixtral-8x7b-32768">mixtral-8x7b-32768</option>
|
||||
<option value="llava-v1.5-7b-4096-preview">llava-v1.5-7b-4096-preview</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div id="nanogpt_form" data-source="nanogpt">
|
||||
@ -3209,6 +3234,7 @@
|
||||
<select id="model_deepseek_select">
|
||||
<option value="deepseek-chat">deepseek-chat</option>
|
||||
<option value="deepseek-coder">deepseek-coder</option>
|
||||
<option value="deepseek-reasoner">deepseek-reasoner</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -3224,32 +3250,19 @@
|
||||
<h4 data-i18n="Perplexity Model">Perplexity Model</h4>
|
||||
<select id="model_perplexity_select">
|
||||
<optgroup label="Perplexity Sonar Models">
|
||||
<option value="sonar">sonar</option>
|
||||
<option value="sonar-pro">sonar-pro</option>
|
||||
<option value="sonar-reasoning">sonar-reasoning</option>
|
||||
</optgroup>
|
||||
<optgroup label="Deprecated Models">
|
||||
<!-- These are scheduled for deprecation after 2/22/2025 -->
|
||||
<option value="llama-3.1-sonar-small-128k-online">llama-3.1-sonar-small-128k-online</option>
|
||||
<option value="llama-3.1-sonar-large-128k-online">llama-3.1-sonar-large-128k-online</option>
|
||||
<option value="llama-3.1-sonar-huge-128k-online">llama-3.1-sonar-huge-128k-online</option>
|
||||
</optgroup>
|
||||
<optgroup label="Perplexity Chat Models">
|
||||
<!-- These are not listed on the site anymore -->
|
||||
<option value="llama-3.1-sonar-small-128k-chat">llama-3.1-sonar-small-128k-chat</option>
|
||||
<option value="llama-3.1-sonar-large-128k-chat">llama-3.1-sonar-large-128k-chat</option>
|
||||
</optgroup>
|
||||
<optgroup label="Open-Source Models">
|
||||
<option value="llama-3.1-8b-instruct">llama-3.1-8b-instruct</option>
|
||||
<option value="llama-3.1-70b-instruct">llama-3.1-70b-instruct</option>
|
||||
</optgroup>
|
||||
<optgroup label="Deprecated Models">
|
||||
<option value="llama-3-sonar-small-32k-chat">llama-3-sonar-small-32k-chat</option>
|
||||
<option value="llama-3-sonar-small-32k-online">llama-3-sonar-small-32k-online</option>
|
||||
<option value="llama-3-sonar-large-32k-chat">llama-3-sonar-large-32k-chat</option>
|
||||
<option value="llama-3-sonar-large-32k-online">llama-3-sonar-large-32k-online</option>
|
||||
<option value="sonar-small-chat">sonar-small-chat</option>
|
||||
<option value="sonar-small-online">sonar-small-online</option>
|
||||
<option value="sonar-medium-chat">sonar-medium-chat</option>
|
||||
<option value="sonar-medium-online">sonar-medium-online</option>
|
||||
<option value="llama-3-8b-instruct">llama-3-8b-instruct</option>
|
||||
<option value="llama-3-70b-instruct">llama-3-70b-instruct</option>
|
||||
<option value="mistral-7b-instruct">mistral-7b-instruct (v0.2)</option>
|
||||
<option value="mixtral-8x7b-instruct">mixtral-8x7b-instruct</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<form id="cohere_form" data-source="cohere" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
@ -3521,7 +3534,7 @@
|
||||
</label>
|
||||
<label id="instruct_enabled_label"for="instruct_enabled" class="checkbox_label flex1" title="Enable Instruct Mode" data-i18n="[title]instruct_enabled">
|
||||
<input id="instruct_enabled" type="checkbox" style="display:none;" />
|
||||
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
|
||||
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
|
||||
</label>
|
||||
</div>
|
||||
</h4>
|
||||
@ -3699,7 +3712,7 @@
|
||||
<div class="flex-container">
|
||||
<label id="sysprompt_enabled_label" for="sysprompt_enabled" class="checkbox_label flex1" title="Enable System Prompt" data-i18n="[title]sysprompt_enabled">
|
||||
<input id="sysprompt_enabled" type="checkbox" style="display:none;" />
|
||||
<small><i class="fa-solid fa-power-off menu_button margin0"></i></small>
|
||||
<small><i class="fa-solid fa-power-off menu_button togglable margin0"></i></small>
|
||||
</label>
|
||||
</div>
|
||||
</h4>
|
||||
@ -3753,8 +3766,8 @@
|
||||
</div>
|
||||
<label class="checkbox_label" for="custom_stopping_strings_macro">
|
||||
<input id="custom_stopping_strings_macro" type="checkbox" checked>
|
||||
<small data-i18n="Replace Macro in Custom Stopping Strings">
|
||||
Replace Macro in Custom Stopping Strings
|
||||
<small data-i18n="Replace Macro in Stop Strings">
|
||||
Replace Macro in Stop Strings
|
||||
</small>
|
||||
</label>
|
||||
</div>
|
||||
@ -3796,6 +3809,66 @@
|
||||
<input id="token_padding" class="text_pole textarea_compact" type="number" min="-2048" max="2048" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="standoutHeader">
|
||||
<span data-i18n="Reasoning">Reasoning</span>
|
||||
</h4>
|
||||
<div>
|
||||
<div class="flex-container alignItemsBaseline">
|
||||
<label class="checkbox_label flex1" for="reasoning_auto_parse" title="Automatically parse reasoning blocks from main content between the reasoning prefix/suffix. Both fields must be defined and non-empty." data-i18n="[title]reasoning_auto_parse">
|
||||
<input id="reasoning_auto_parse" type="checkbox" />
|
||||
<small data-i18n="Auto-Parse">
|
||||
Auto-Parse
|
||||
</small>
|
||||
</label>
|
||||
<label class="checkbox_label flex1" for="reasoning_auto_expand" title="Automatically expand reasoning blocks." data-i18n="[title]reasoning_auto_expand">
|
||||
<input id="reasoning_auto_expand" type="checkbox" />
|
||||
<small data-i18n="Auto-Expand">
|
||||
Auto-Expand
|
||||
</small>
|
||||
</label>
|
||||
<label class="checkbox_label flex1" for="reasoning_show_hidden" title="Show reasoning time for models with hidden reasoning." data-i18n="[title]reasoning_show_hidden">
|
||||
<input id="reasoning_show_hidden" type="checkbox" />
|
||||
<small data-i18n="Show Hidden">
|
||||
Show Hidden
|
||||
</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex-container alignItemsBaseline">
|
||||
<label class="checkbox_label flex1" for="reasoning_add_to_prompts" title="Add existing reasoning blocks to prompts. To add a new reasoning block, use the message edit menu." data-i18n="[title]reasoning_add_to_prompts">
|
||||
<input id="reasoning_add_to_prompts" type="checkbox" />
|
||||
<small data-i18n="Add to Prompts">
|
||||
Add to Prompts
|
||||
</small>
|
||||
</label>
|
||||
<div class="flex1 flex-container alignItemsBaseline" title="Maximum number of reasoning blocks to be added per prompt, counting from the last message." data-i18n="[title]reasoning_max_additions">
|
||||
<input id="reasoning_max_additions" class="text_pole textarea_compact widthUnset" type="number" min="0" max="999"></textarea>
|
||||
<small data-i18n="Max">Max</small>
|
||||
</div>
|
||||
</div>
|
||||
<details>
|
||||
<summary data-i18n="Reasoning Formatting">
|
||||
Reasoning Formatting
|
||||
</summary>
|
||||
<div class="flex-container">
|
||||
<div class="flex1" title="Inserted before the reasoning content." data-i18n="[title]reasoning_prefix">
|
||||
<small data-i18n="Prefix">Prefix</small>
|
||||
<textarea id="reasoning_prefix" class="text_pole textarea_compact autoSetHeight"></textarea>
|
||||
</div>
|
||||
<div class="flex1" title="Inserted after the reasoning content." data-i18n="[title]reasoning_suffix">
|
||||
<small data-i18n="Suffix">Suffix</small>
|
||||
<textarea id="reasoning_suffix" class="text_pole textarea_compact autoSetHeight"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container">
|
||||
<div class="flex1" title="Inserted between the reasoning and the message content." data-i18n="[title]reasoning_separator">
|
||||
<small data-i18n="Separator">Separator</small>
|
||||
<textarea id="reasoning_separator" class="text_pole textarea_compact autoSetHeight"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="standoutHeader" data-i18n="Miscellaneous">Miscellaneous</h4>
|
||||
<div>
|
||||
@ -4809,6 +4882,7 @@
|
||||
</div>
|
||||
<div id="extensions_settings" class="flex1 wide50p">
|
||||
<div id="assets_container" class="extension_container"></div>
|
||||
<div id="typing_indicator_container" class="extension_container"></div>
|
||||
<div id="expressions_container" class="extension_container"></div>
|
||||
<div id="sd_container" class="extension_container"></div>
|
||||
<div id="tts_container" class="extension_container"></div>
|
||||
@ -5804,7 +5878,7 @@
|
||||
<div class="inline-drawer-content flex-container paddingBottom5px wide100p">
|
||||
<div class="flex-container wide100p alignitemscenter">
|
||||
<div name="keywordsAndLogicBlock" class="flex-container wide100p alignitemscenter">
|
||||
<div class="world_entry_form_control flex1">
|
||||
<div class="world_entry_form_control keyprimary flex1">
|
||||
<small class="displayNone">
|
||||
<span data-i18n="Comma separated (required)">
|
||||
Comma separated (required)
|
||||
@ -6218,14 +6292,31 @@
|
||||
<div class="mes_edit_buttons">
|
||||
<div class="mes_edit_done menu_button fa-solid fa-check" title="Confirm" data-i18n="[title]Confirm"></div>
|
||||
<div class="mes_edit_copy menu_button fa-solid fa-copy" title="Copy this message" data-i18n="[title]Copy this message"></div>
|
||||
<div class="mes_edit_delete menu_button fa-solid fa-trash-can" title="Delete this message" data-i18n="[title]Delete this message">
|
||||
</div>
|
||||
<div class="mes_edit_add_reasoning menu_button fa-solid fa-lightbulb" title="Add a reasoning block" data-i18n="[title]Add a reasoning block"></div>
|
||||
<div class="mes_edit_delete menu_button fa-solid fa-trash-can" title="Delete this message" data-i18n="[title]Delete this message"></div>
|
||||
<div class="mes_edit_up menu_button fa-solid fa-chevron-up " title="Move message up" data-i18n="[title]Move message up"></div>
|
||||
<div class="mes_edit_down menu_button fa-solid fa-chevron-down" title="Move message down" data-i18n="[title]Move message down">
|
||||
</div>
|
||||
<div class="mes_edit_down menu_button fa-solid fa-chevron-down" title="Move message down" data-i18n="[title]Move message down"></div>
|
||||
<div class="mes_edit_cancel menu_button fa-solid fa-xmark" title="Cancel" data-i18n="[title]Cancel"></div>
|
||||
</div>
|
||||
</div>
|
||||
<details class="mes_reasoning_details">
|
||||
<summary class="mes_reasoning_summary flex-container">
|
||||
<div class="mes_reasoning_header_block flex-container">
|
||||
<div class="mes_reasoning_header flex-container">
|
||||
<span class="mes_reasoning_header_title" data-i18n="Thought for some time">Thought for some time</span>
|
||||
<div class="mes_reasoning_arrow fa-solid fa-chevron-up"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mes_reasoning_actions flex-container">
|
||||
<div class="mes_reasoning_edit_done menu_button edit_button fa-solid fa-check" title="Confirm" data-i18n="[title]Confirmedit"></div>
|
||||
<div class="mes_reasoning_delete menu_button edit_button fa-solid fa-trash-can" title="Remove reasoning" data-i18n="[title]Remove reasoning"></div>
|
||||
<div class="mes_reasoning_edit_cancel menu_button edit_button fa-solid fa-xmark" title="Cancel edit" data-i18n="[title]Cancel edit"></div>
|
||||
<div class="mes_reasoning_copy mes_button fa-solid fa-copy" title="Copy reasoning" data-i18n="[title]Copy reasoning"></div>
|
||||
<div class="mes_reasoning_edit mes_button fa-solid fa-pencil" title="Edit reasoning" data-i18n="[title]Edit reasoning"></div>
|
||||
</div>
|
||||
</summary>
|
||||
<div class="mes_reasoning"></div>
|
||||
</details>
|
||||
<div class="mes_text"></div>
|
||||
<div class="mes_img_container">
|
||||
<div class="mes_img_controls">
|
||||
@ -6325,7 +6416,10 @@
|
||||
<img alt="Avatar" src="" />
|
||||
</div>
|
||||
<div class="group_member_name">
|
||||
<div class="ch_name"></div>
|
||||
<div class="character_name_block">
|
||||
<span class="ch_name"></span>
|
||||
<small class="ch_additional_info character_version"></small>
|
||||
</div>
|
||||
<div class="tags tags_inline"></div>
|
||||
</div>
|
||||
<input class="ch_fav" value="" hidden />
|
||||
@ -6437,9 +6531,6 @@
|
||||
</div>
|
||||
|
||||
<!-- chat and input bar -->
|
||||
<div id="typing_indicator_template" class="template_element">
|
||||
<div class="typing_indicator"><span class="typing_indicator_name">CHAR</span> is typing</div>
|
||||
</div>
|
||||
<div id="message_file_template" class="template_element">
|
||||
<div class="mes_file_container">
|
||||
<div class="fa-lg fa-solid fa-file-alt mes_file_icon"></div>
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "فصل بفواصل دون مسافة بينها",
|
||||
"Custom Stopping Strings": "سلاسل توقف مخصصة",
|
||||
"JSON serialized array of strings": "مصفوفة سلسلة JSON متسلسلة",
|
||||
"Replace Macro in Custom Stopping Strings": "استبدال الماكرو في سلاسل التوقف المخصصة",
|
||||
"Replace Macro in Stop Strings": "استبدال الماكرو في سلاسل التوقف المخصصة",
|
||||
"Auto-Continue": "المتابعة التلقائية",
|
||||
"Allow for Chat Completion APIs": "السماح بواجهات برمجة التطبيقات لإكمال الدردشة",
|
||||
"Target length (tokens)": "الطول المستهدف (رموز)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (رابط مباشر أو معرف)",
|
||||
"char_import_3": "حرف JanitorAI (رابط مباشر أو UUID)",
|
||||
"char_import_4": "حرف Pygmalion.chat (رابط مباشر أو UUID)",
|
||||
"char_import_5": "حرف AICharacterCard.com (رابط مباشر أو معرف)",
|
||||
"char_import_5": "حرف AICharacterCards.com (رابط مباشر أو معرف)",
|
||||
"char_import_6": "رابط PNG المباشر (راجع",
|
||||
"char_import_7": "للمضيفين المسموح بهم)",
|
||||
"char_import_8": "شخصية RisuRealm (رابط مباشر)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "getrennt durch Kommas ohne Leerzeichen dazwischen",
|
||||
"Custom Stopping Strings": "Benutzerdefinierte Stoppzeichenfolgen",
|
||||
"JSON serialized array of strings": "JSON serialisierte Reihe von Zeichenfolgen",
|
||||
"Replace Macro in Custom Stopping Strings": "Makro in benutzerdefinierten Stoppzeichenfolgen ersetzen",
|
||||
"Replace Macro in Stop Strings": "Makro in benutzerdefinierten Stoppzeichenfolgen ersetzen",
|
||||
"Auto-Continue": "Automatisch fortsetzen",
|
||||
"Allow for Chat Completion APIs": "Erlaube Chat-Vervollständigungs-APIs",
|
||||
"Target length (tokens)": "Ziel-Länge (Tokens)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (Direktlink oder ID)",
|
||||
"char_import_3": "JanitorAI-Charakter (Direktlink oder UUID)",
|
||||
"char_import_4": "Pygmalion.chat-Charakter (Direktlink oder UUID)",
|
||||
"char_import_5": "AICharacterCard.com-Charakter (Direktlink oder ID)",
|
||||
"char_import_5": "AICharacterCards.com-Charakter (Direktlink oder ID)",
|
||||
"char_import_6": "Direkter PNG-Link (siehe",
|
||||
"char_import_7": "für erlaubte Hosts)",
|
||||
"char_import_8": "RisuRealm-Charakter (Direktlink)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "separe con comas sin espacio entre ellas",
|
||||
"Custom Stopping Strings": "Cadenas de Detención Personalizadas",
|
||||
"JSON serialized array of strings": "Arreglo de cadenas serializado en JSON",
|
||||
"Replace Macro in Custom Stopping Strings": "Reemplazar macro en Cadenas de Detención Personalizadas",
|
||||
"Replace Macro in Stop Strings": "Reemplazar macro en Cadenas de Detención Personalizadas",
|
||||
"Auto-Continue": "Autocontinuar",
|
||||
"Allow for Chat Completion APIs": "Permitir para APIs de Completado de Chat",
|
||||
"Target length (tokens)": "Longitud objetivo (tokens)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (enlace directo o ID)",
|
||||
"char_import_3": "Carácter de JanitorAI (enlace directo o UUID)",
|
||||
"char_import_4": "Carácter Pygmalion.chat (enlace directo o UUID)",
|
||||
"char_import_5": "Carácter AICharacterCard.com (enlace directo o ID)",
|
||||
"char_import_5": "Carácter AICharacterCards.com (enlace directo o ID)",
|
||||
"char_import_6": "Enlace PNG directo (consulte",
|
||||
"char_import_7": "para hosts permitidos)",
|
||||
"char_import_8": "Personaje RisuRealm (Enlace directo)",
|
||||
|
@ -434,7 +434,7 @@
|
||||
"Non-markdown strings": "Chaînes non Markdown",
|
||||
"Custom Stopping Strings": "Chaînes d'arrêt personnalisées",
|
||||
"JSON serialized array of strings": "Tableau de chaînes sérialisé JSON",
|
||||
"Replace Macro in Custom Stopping Strings": "Remplacer les macro dans les chaînes d'arrêt personnalisées",
|
||||
"Replace Macro in Stop Strings": "Remplacer les macro dans les chaînes d'arrêt personnalisées",
|
||||
"Auto-Continue": "Auto-Continue",
|
||||
"Allow for Chat Completion APIs": "Autoriser les APIs de complétion de chat",
|
||||
"Target length (tokens)": "Longueur cible (tokens)",
|
||||
@ -1297,7 +1297,7 @@
|
||||
"char_import_2": "Lorebook de Chub (lien direct ou ID)",
|
||||
"char_import_3": "Personnage de JanitorAI (lien direct ou UUID)",
|
||||
"char_import_4": "Personnage de Pygmalion.chat (lien direct ou UUID)",
|
||||
"char_import_5": "Personnage de AICharacterCard.com (lien direct ou identifiant)",
|
||||
"char_import_5": "Personnage de AICharacterCards.com (lien direct ou identifiant)",
|
||||
"char_import_6": "Lien PNG direct (voir",
|
||||
"char_import_7": "pour les hôtes autorisés)",
|
||||
"char_import_8": "Personnage de RisuRealm (lien direct)",
|
||||
@ -1385,8 +1385,8 @@
|
||||
"enable_functions_desc_1": "Autorise l'utilisation",
|
||||
"enable_functions_desc_2": "outils de fonction",
|
||||
"enable_functions_desc_3": "Peut être utilisé par diverses extensions pour fournir des fonctionnalités supplémentaires.",
|
||||
"Show model thoughts": "Afficher les pensées du modèle",
|
||||
"Display the model's internal thoughts in the response.": "Afficher les pensées internes du modèle dans la réponse.",
|
||||
"Request model reasoning": "Demander les pensées du modèle",
|
||||
"Allows the model to return its thinking process.": "Permet au modèle de retourner son processus de réflexion.",
|
||||
"Confirm token parsing with": "Confirmer l'analyse des tokens avec",
|
||||
"openai_logit_bias_no_items": "Aucun élément",
|
||||
"api_no_connection": "Pas de connection...",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "aðskilið með kommum án bila milli",
|
||||
"Custom Stopping Strings": "Eigin stopp-strengir",
|
||||
"JSON serialized array of strings": "JSON raðað fylki af strengjum",
|
||||
"Replace Macro in Custom Stopping Strings": "Skiptu út í macro í sérsniðnum stoppa strengjum",
|
||||
"Replace Macro in Stop Strings": "Skiptu út í macro í sérsniðnum stoppa strengjum",
|
||||
"Auto-Continue": "Sjálfvirk Forná",
|
||||
"Allow for Chat Completion APIs": "Leyfa fyrir spjall Loka APIs",
|
||||
"Target length (tokens)": "Markaðarlengd (texti)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (beinn hlekkur eða auðkenni)",
|
||||
"char_import_3": "JanitorAI karakter (beinn hlekkur eða UUID)",
|
||||
"char_import_4": "Pygmalion.chat karakter (beinn hlekkur eða UUID)",
|
||||
"char_import_5": "AICharacterCard.com Karakter (beinn hlekkur eða auðkenni)",
|
||||
"char_import_5": "AICharacterCards.com Karakter (beinn hlekkur eða auðkenni)",
|
||||
"char_import_6": "Beinn PNG hlekkur (sjá",
|
||||
"char_import_7": "fyrir leyfilega gestgjafa)",
|
||||
"char_import_8": "RisuRealm karakter (beinn hlekkur)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "separati con virgole senza spazio tra loro",
|
||||
"Custom Stopping Strings": "Stringhe di Stop Personalizzate",
|
||||
"JSON serialized array of strings": "Matrice serializzata JSON di stringhe",
|
||||
"Replace Macro in Custom Stopping Strings": "Sostituisci Macro in Stringhe di Arresto Personalizzate",
|
||||
"Replace Macro in Stop Strings": "Sostituisci Macro in Stringhe di Arresto Personalizzate",
|
||||
"Auto-Continue": "Auto-continua",
|
||||
"Allow for Chat Completion APIs": "Consenti per API di completamento chat",
|
||||
"Target length (tokens)": "Lunghezza obiettivo (token)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Lorebook di Chub (collegamento diretto o ID)",
|
||||
"char_import_3": "Carattere JanitorAI (collegamento diretto o UUID)",
|
||||
"char_import_4": "Carattere Pygmalion.chat (collegamento diretto o UUID)",
|
||||
"char_import_5": "Carattere AICharacterCard.com (Link diretto o ID)",
|
||||
"char_import_5": "Carattere AICharacterCards.com (Link diretto o ID)",
|
||||
"char_import_6": "Collegamento PNG diretto (fare riferimento a",
|
||||
"char_import_7": "per gli host consentiti)",
|
||||
"char_import_8": "Personaggio RisuRealm (collegamento diretto)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "間にスペースのないカンマで区切ります",
|
||||
"Custom Stopping Strings": "カスタム停止文字列",
|
||||
"JSON serialized array of strings": "文字列のJSONシリアル化配列",
|
||||
"Replace Macro in Custom Stopping Strings": "カスタム停止文字列内のマクロを置換する",
|
||||
"Replace Macro in Stop Strings": "カスタム停止文字列内のマクロを置換する",
|
||||
"Auto-Continue": "自動継続",
|
||||
"Allow for Chat Completion APIs": "チャット補完APIを許可",
|
||||
"Target length (tokens)": "ターゲット長さ(トークン)",
|
||||
@ -1378,7 +1378,7 @@
|
||||
"char_import_2": "Chub ロアブック (直接リンクまたは ID)",
|
||||
"char_import_3": "JanitorAI キャラクター (直接リンクまたは UUID)",
|
||||
"char_import_4": "Pygmalion.chat キャラクター (直接リンクまたは UUID)",
|
||||
"char_import_5": "AICharacterCard.com キャラクター (直接リンクまたは ID)",
|
||||
"char_import_5": "AICharacterCards.com キャラクター (直接リンクまたは ID)",
|
||||
"char_import_6": "直接PNGリンク(参照",
|
||||
"char_import_7": "許可されたホストの場合)",
|
||||
"char_import_8": "RisuRealm キャラクター (直接リンク)",
|
||||
|
@ -211,7 +211,7 @@
|
||||
"Sampler Priority": "샘플러 우선 순위",
|
||||
"Ooba only. Determines the order of samplers.": "Ooba 전용. 샘플러의 순서를 결정합니다.",
|
||||
"Character Names Behavior": "캐릭터 이름 동작",
|
||||
"[title]character_names_none": "캐릭터 이름 접두사를 추가하지 않습니다. 그룹 채팅에서는 좋지 않을 수 있으므로, 이 설정을 선택할 때는 주의해야 합니다.",
|
||||
"character_names_none": "캐릭터 이름 접두사를 추가하지 않습니다. 그룹 채팅에서는 좋지 않을 수 있으므로, 이 설정을 선택할 때는 주의해야 합니다.",
|
||||
"Helps the model to associate messages with characters.": "모델이 메시지를 캐릭터와 연관시키는 데 도움이 됩니다.",
|
||||
"None": "없음",
|
||||
"None (not injected)": "없음 (삽입되지 않음)",
|
||||
@ -404,7 +404,7 @@
|
||||
"Custom API Key": "커스텀 API 키",
|
||||
"Available Models": "사용 가능한 모델",
|
||||
"Prompt Post-Processing": "신속한 후처리",
|
||||
"[title]API Connections;[no_connection_text]api_no_connection": "연결이 되지 않았습니다...",
|
||||
"api_no_connection": "연결이 되지 않았습니다...",
|
||||
"Applies additional processing to the prompt before sending it to the API.": "API로 보내기 전에 프롬프트에 추가 처리를 적용합니다.",
|
||||
"Verifies your API connection by sending a short test message. Be aware that you'll be credited for it!": "짧은 테스트 메시지를 보내어 API 연결을 확인합니다. 이에 대해 유료 크레딧이 지불될 수 있음을 인식하세요!",
|
||||
"Test Message": "테스트 메시지",
|
||||
@ -492,7 +492,7 @@
|
||||
"separate with commas w/o space between": "쉼표로 구분 (공백 없이)",
|
||||
"Custom Stopping Strings": "사용자 정의 중지 문자열",
|
||||
"JSON serialized array of strings": "문자열의 JSON 직렬화된 배열",
|
||||
"Replace Macro in Custom Stopping Strings": "사용자 정의 중단 문자열에서 매크로 교체",
|
||||
"Replace Macro in Stop Strings": "사용자 정의 중단 문자열에서 매크로 교체",
|
||||
"Auto-Continue": "자동 계속하기",
|
||||
"Allow for Chat Completion APIs": "채팅 완성 API 허용",
|
||||
"Target length (tokens)": "대상 길이 (토큰)",
|
||||
@ -625,7 +625,7 @@
|
||||
"Single-row message input area. Mobile only, no effect on PC": "한 줄짜리 메시지 입력 영역. 모바일 전용, PC에는 영향 없음",
|
||||
"Compact Input Area (Mobile)": "조그마한 입력 영역 (모바일)",
|
||||
"Swipe # for All Messages": "모든 스와이프 메시지에 대해 번호 매기기",
|
||||
"[title]Display swipe numbers for all messages, not just the last.": "마지막 메시지만이 아니라 모든 메시지에 대한 스와이프 번호를 표시합니다.",
|
||||
"Display swipe numbers for all messages, not just the last.": "마지막 메시지만이 아니라 모든 메시지에 대한 스와이프 번호를 표시합니다.",
|
||||
"In the Character Management panel, show quick selection buttons for favorited characters": "캐릭터 관리 패널에서 즐겨찾는 캐릭터에 대한 빠른 선택 버튼을 표시합니다",
|
||||
"Characters Hotswap": "캐릭터 핫스왑",
|
||||
"Enable magnification for zoomed avatar display.": "마우스 포인터를 아바타 위에 올려두면 아바타가 확대 됩니다.",
|
||||
@ -1395,7 +1395,7 @@
|
||||
"char_import_2": "Chub Lorebook(직접 링크 또는 ID)",
|
||||
"char_import_3": "JanitorAI 캐릭터(직접 링크 또는 UUID)",
|
||||
"char_import_4": "Pygmalion.chat 문자(직접 링크 또는 UUID)",
|
||||
"char_import_5": "AICharacterCard.com 캐릭터(직접 링크 또는 ID)",
|
||||
"char_import_5": "AICharacterCards.com 캐릭터(직접 링크 또는 ID)",
|
||||
"char_import_6": "직접 PNG 링크(참조",
|
||||
"char_import_7": "허용된 호스트의 경우)",
|
||||
"char_import_8": "RisuRealm 캐릭터 (직접링크)",
|
||||
@ -1538,7 +1538,7 @@
|
||||
"Only apply color as accent": "색상은 오직 강조로써만 적용됩니다",
|
||||
"qr--colorClear": "색상 지우기",
|
||||
"Color": "색상",
|
||||
"[title]world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift를 클릭하면 '월드 인포 링크' 팝업이 열립니다.",
|
||||
"world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift를 클릭하면 '월드 인포 링크' 팝업이 열립니다.",
|
||||
"Select TTS Provider": "TTS 공급자 선택",
|
||||
"tts_enabled": "활성화",
|
||||
"Narrate user messages": "사용자 메시지 나레이션",
|
||||
@ -1583,15 +1583,15 @@
|
||||
"Prompt Content": "프롬프트 내용",
|
||||
"Instruct Sequences": "지시 시퀀스",
|
||||
"Prefer Character Card Instructions": "캐릭터 카드의 지시사항을 선호",
|
||||
"[title]If checked and the character card contains a Post-History Instructions override, use that instead": "활성화 된 경우, 캐릭터 카드에 Post-History 지시 무시 항목이 포함되어 있으면, 카드 지시사항의 내용으로 대신 사용합니다.",
|
||||
"If checked and the character card contains a Post-History Instructions override, use that instead": "활성화 된 경우, 캐릭터 카드에 Post-History 지시 무시 항목이 포함되어 있으면, 카드 지시사항의 내용으로 대신 사용합니다.",
|
||||
"Auto-select Input Text": "입력 텍스트 자동 선택",
|
||||
"[title]Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields.": "일부 텍스트 필드를 클릭하거나 선택할 때 자동으로 입력된 텍스트가 선택되도록 설정합니다. 팝업 입력창과 기타 커스텀 입력 필드에 적용됩니다.",
|
||||
"Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields.": "일부 텍스트 필드를 클릭하거나 선택할 때 자동으로 입력된 텍스트가 선택되도록 설정합니다. 팝업 입력창과 기타 커스텀 입력 필드에 적용됩니다.",
|
||||
"Markdown Hotkeys": "마크다운 입력 단축키",
|
||||
"[title]markdown_hotkeys_desc": "특정 텍스트 입력창에서 마크다운 형식 문자를 입력하기 위한 단축키를 활성화합니다. '/help hotkeys'를 참고하세요.",
|
||||
"markdown_hotkeys_desc": "특정 텍스트 입력창에서 마크다운 형식 문자를 입력하기 위한 단축키를 활성화합니다. '/help hotkeys'를 참고하세요.",
|
||||
"Show group chat queue": "그룹 채팅 대기열 표시",
|
||||
"[title]In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond.": "그룹 채팅에서 응답을 생성하기 위해 현재 대기 중인 캐릭터와 응답할 순서를 강조 표시합니다.",
|
||||
"In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond.": "그룹 채팅에서 응답을 생성하기 위해 현재 대기 중인 캐릭터와 응답할 순서를 강조 표시합니다.",
|
||||
"Quick 'Impersonate' button": "빠른 '사칭' 버튼",
|
||||
"[title]Show a button in the input area to ask the AI to impersonate your character for a single message": "입력 영역에 AI에게 한 메시지 동안 당신의 캐릭터 연기를 사칭하도록 요청하는 버튼을 표시합니다.",
|
||||
"Show a button in the input area to ask the AI to impersonate your character for a single message": "입력 영역에 AI에게 한 메시지 동안 당신의 캐릭터 연기를 사칭하도록 요청하는 버튼을 표시합니다.",
|
||||
"Injection Template": "삽입 템플릿",
|
||||
"Query messages": "쿼리 메시지 수",
|
||||
"Score threshold": "점수 임계값",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "gescheiden met komma's zonder spatie ertussen",
|
||||
"Custom Stopping Strings": "Aangepaste Stopreeksen",
|
||||
"JSON serialized array of strings": "JSON geserialiseerde reeks van strings",
|
||||
"Replace Macro in Custom Stopping Strings": "Macro vervangen in aangepaste stopreeksen",
|
||||
"Replace Macro in Stop Strings": "Macro vervangen in aangepaste stopreeksen",
|
||||
"Auto-Continue": "Automatisch doorgaan",
|
||||
"Allow for Chat Completion APIs": "Chatvervolledigings-API's toestaan",
|
||||
"Target length (tokens)": "Doellengte (tokens)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (directe link of ID)",
|
||||
"char_import_3": "JanitorAI-personage (directe link of UUID)",
|
||||
"char_import_4": "Pygmalion.chat-teken (directe link of UUID)",
|
||||
"char_import_5": "AICharacterCard.com-teken (directe link of ID)",
|
||||
"char_import_5": "AICharacterCards.com-teken (directe link of ID)",
|
||||
"char_import_6": "Directe PNG-link (zie",
|
||||
"char_import_7": "voor toegestane hosts)",
|
||||
"char_import_8": "RisuRealm-personage (directe link)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "separe com vírgulas sem espaço entre",
|
||||
"Custom Stopping Strings": "Cadeias de parada personalizadas",
|
||||
"JSON serialized array of strings": "Matriz de strings serializada em JSON",
|
||||
"Replace Macro in Custom Stopping Strings": "Substituir Macro em Strings de Parada Personalizadas",
|
||||
"Replace Macro in Stop Strings": "Substituir Macro em Strings de Parada Personalizadas",
|
||||
"Auto-Continue": "Auto-Continuar",
|
||||
"Allow for Chat Completion APIs": "Permitir APIs de Completar Chat",
|
||||
"Target length (tokens)": "Comprimento alvo (tokens)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (link direto ou ID)",
|
||||
"char_import_3": "Personagem JanitorAI (Link Direto ou UUID)",
|
||||
"char_import_4": "Caractere Pygmalion.chat (Link Direto ou UUID)",
|
||||
"char_import_5": "Personagem AICharacterCard.com (link direto ou ID)",
|
||||
"char_import_5": "Personagem AICharacterCards.com (link direto ou ID)",
|
||||
"char_import_6": "Link PNG direto (consulte",
|
||||
"char_import_7": "para hosts permitidos)",
|
||||
"char_import_8": "Personagem RisuRealm (link direto)",
|
||||
|
@ -161,7 +161,7 @@
|
||||
"View hidden API keys": "Посмотреть скрытые API-ключи",
|
||||
"Advanced Formatting": "Расширенное форматирование",
|
||||
"Context Template": "Шаблон контекста",
|
||||
"Replace Macro in Custom Stopping Strings": "Заменять макросы в пользовательских стоп-строках",
|
||||
"Replace Macro in Stop Strings": "Заменять макросы в пользовательских стоп-строках",
|
||||
"Story String": "Строка истории",
|
||||
"Example Separator": "Разделитель примеров сообщений",
|
||||
"Chat Start": "Начало чата",
|
||||
@ -966,7 +966,7 @@
|
||||
"char_import_2": "Лорбук с Chub (прямая ссылка или ID)",
|
||||
"char_import_3": "Персонаж с JanitorAI (прямая ссылка или UUID)",
|
||||
"char_import_4": "Персонаж с Pygmalion.chat (прямая ссылка или UUID)",
|
||||
"char_import_5": "Персонаж с AICharacterCard.com (прямая ссылка или ID)",
|
||||
"char_import_5": "Персонаж с AICharacterCards.com (прямая ссылка или ID)",
|
||||
"char_import_6": "Прямая ссылка на PNG-файл (чтобы узнать список разрешённых хостов, загляните в",
|
||||
"char_import_7": ")",
|
||||
"Grammar String": "Грамматика",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "розділяйте комами без пропусків між ними",
|
||||
"Custom Stopping Strings": "Власні рядки зупинки",
|
||||
"JSON serialized array of strings": "JSON-серіалізований масив рядків",
|
||||
"Replace Macro in Custom Stopping Strings": "Замінювати макроси у власних рядках зупинки",
|
||||
"Replace Macro in Stop Strings": "Замінювати макроси у власних рядках зупинки",
|
||||
"Auto-Continue": "Автоматичне продовження",
|
||||
"Allow for Chat Completion APIs": "Дозволити для Chat Completion API",
|
||||
"Target length (tokens)": "Цільова довжина (токени)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub Lorebook (пряме посилання або ID)",
|
||||
"char_import_3": "Символ JanitorAI (пряме посилання або UUID)",
|
||||
"char_import_4": "Символ Pygmalion.chat (пряме посилання або UUID)",
|
||||
"char_import_5": "Символ AICharacterCard.com (пряме посилання або ідентифікатор)",
|
||||
"char_import_5": "Символ AICharacterCards.com (пряме посилання або ідентифікатор)",
|
||||
"char_import_6": "Пряме посилання на PNG (див",
|
||||
"char_import_7": "для дозволених хостів)",
|
||||
"char_import_8": "Персонаж RisuRealm (пряме посилання)",
|
||||
|
@ -482,7 +482,7 @@
|
||||
"separate with commas w/o space between": "phân tách bằng dấu phẩy không có khoảng trắng giữa",
|
||||
"Custom Stopping Strings": "Chuỗi dừng tùy chỉnh",
|
||||
"JSON serialized array of strings": "Mảng chuỗi được tuần tự hóa JSON",
|
||||
"Replace Macro in Custom Stopping Strings": "Thay thế Macro trong Chuỗi Dừng Tùy chỉnh",
|
||||
"Replace Macro in Stop Strings": "Thay thế Macro trong Chuỗi Dừng Tùy chỉnh",
|
||||
"Auto-Continue": "Tự động Tiếp tục",
|
||||
"Allow for Chat Completion APIs": "Cho phép các API hoàn thành Trò chuyện",
|
||||
"Target length (tokens)": "Độ dài mục tiêu (token)",
|
||||
@ -1376,7 +1376,7 @@
|
||||
"char_import_2": "Chub (Nhập URL trực tiếp hoặc ID)",
|
||||
"char_import_3": "JanitorAI (Nhập URL trực tiếp hoặc UUID)",
|
||||
"char_import_4": "Pygmalion.chat (Nhập URL trực tiếp hoặc UUID)",
|
||||
"char_import_5": "AICharacterCard.com (Nhập URL trực tiếp hoặc ID)",
|
||||
"char_import_5": "AICharacterCards.com (Nhập URL trực tiếp hoặc ID)",
|
||||
"char_import_6": "Nhập PNG trực tiếp (tham khảo",
|
||||
"char_import_7": "đối với các máy chủ được phép)",
|
||||
"char_import_8": "RisuRealm (URL trực tiếp)",
|
||||
|
@ -215,7 +215,7 @@
|
||||
"Classifier Free Guidance. More helpful tip coming soon": "无分类器指导(CFG)。更多有用的提示敬请期待。",
|
||||
"Scale": "缩放比例",
|
||||
"Negative Prompt": "负面提示词",
|
||||
"Used if CFG Scale is unset globally, per chat or character": "如果无分类器指导(CFG)缩放比例未在全局设置,它将作用于每个聊天或每个角色",
|
||||
"Used if CFG Scale is unset globally, per chat or character": "如果CFG缩放比例未被全局设置,它将作用于所有聊天或角色",
|
||||
"Add text here that would make the AI generate things you don't want in your outputs.": "请在此处添加文本,以避免生成您不希望出现在输出中的内容。",
|
||||
"Grammar String": "语法字符串",
|
||||
"GBNF or EBNF, depends on the backend in use. If you're using this you should know which.": "GBNF 或 EBNF,取决于使用的后端。如果您使用这个,您应该知道该用哪一个。",
|
||||
@ -266,8 +266,8 @@
|
||||
"Use system prompt": "使用系统提示词",
|
||||
"Merges_all_system_messages_desc_1": "合并所有系统消息,直到第一条具有非系统角色的消息,然后通过",
|
||||
"Merges_all_system_messages_desc_2": "字段发送。",
|
||||
"Show model thoughts": "展示思维链",
|
||||
"Display the model's internal thoughts in the response.": "展示模型在回复时的内部思维链。",
|
||||
"Request model reasoning": "请求思维链",
|
||||
"Allows the model to return its thinking process.": "允许模型返回其思维过程。",
|
||||
"Assistant Prefill": "AI预填",
|
||||
"Expand the editor": "展开编辑器",
|
||||
"Start Claude's answer with...": "以如下内容开始Claude的回答...",
|
||||
@ -559,7 +559,7 @@
|
||||
"Prompt Content": "提示词内容",
|
||||
"Custom Stopping Strings": "自定义停止字符串",
|
||||
"JSON serialized array of strings": "JSON序列化的字符串数组",
|
||||
"Replace Macro in Custom Stopping Strings": "替换自定义停止字符串中的宏",
|
||||
"Replace Macro in Stop Strings": "替换自定义停止字符串中的宏",
|
||||
"Token Padding": "词符填充",
|
||||
"Miscellaneous": "杂项",
|
||||
"Non-markdown strings": "非 Markdown 字符串",
|
||||
@ -1191,9 +1191,9 @@
|
||||
"welcome_message_part_8": "您可随时通过",
|
||||
"welcome_message_part_9": "图标来更改此设置。",
|
||||
"Persona Name:": "用户角色名称:",
|
||||
"Temporarily disable automatic replies from this character": "暂时禁用此角色的自动回复",
|
||||
"Enable automatic replies from this character": "启用此角色的自动回复",
|
||||
"Trigger a message from this character": "从此角色触发消息",
|
||||
"Temporarily disable automatic replies from this character": "临时禁言此角色",
|
||||
"Enable automatic replies from this character": "解除禁言此角色",
|
||||
"Trigger a message from this character": "强制触发该角色发言",
|
||||
"Move up": "向上移动",
|
||||
"Move down": "向下移动",
|
||||
"View character card": "查看角色卡片",
|
||||
@ -1208,7 +1208,7 @@
|
||||
"View contents": "查看内容",
|
||||
"Remove the file": "删除文件",
|
||||
"Author's Note": "作者注释",
|
||||
"Unique to this chat": "此聊天独有",
|
||||
"Unique to this chat": "仅对此聊天生效",
|
||||
"Checkpoints inherit the Note from their parent, and can be changed individually after that.": "检查点从其父级继承注释,之后可以单独更改。",
|
||||
"Include in World Info Scanning": "纳入世界信息扫描",
|
||||
"Before Main Prompt / Story String": "主提示词/故事线之前",
|
||||
@ -1224,13 +1224,13 @@
|
||||
"Replace Author's Note": "替换作者注",
|
||||
"Default Author's Note": "默认作者注",
|
||||
"Will be automatically added as the Author's Note for all new chats.": "将自动添加为所有新聊天的作者注释。",
|
||||
"Chat CFG": "聊天CFG",
|
||||
"1 = disabled": "“1”为已禁用",
|
||||
"Chat CFG": "本聊天的CFG缩放",
|
||||
"1 = disabled": "“1”为禁用",
|
||||
"write short replies, write replies using past tense": "写简短的回复,用过去时写回复",
|
||||
"Positive Prompt": "正面提示词",
|
||||
"Use character CFG scales": "单独为各个角色设置CFG缩放",
|
||||
"Character CFG": "角色CFG配置",
|
||||
"Will be automatically added as the CFG for this character.": "将自动添加为该角色的 CFG。",
|
||||
"Will be automatically added as the CFG for this character.": "将自动添加到该角色的CFG设置中。",
|
||||
"Global CFG": "全局CFG",
|
||||
"Will be used as the default CFG options for every chat unless overridden.": "除非被覆盖,否则将用作每次聊天的默认 CFG 选项。",
|
||||
"CFG Prompt Cascading": "CFG 提示词级联",
|
||||
@ -1486,7 +1486,7 @@
|
||||
"ext_regex_replace_string_placeholder": "使用 {{match}} 包含来自“查找正则表达式”或“$1”、“$2”等的匹配文本作为捕获组。",
|
||||
"Trim Out": "修剪掉",
|
||||
"ext_regex_trim_placeholder": "在替换之前全局修剪正则表达式匹配中任何不需要的部分。用回车键分隔每个元素。",
|
||||
"ext_regex_affects": "影响",
|
||||
"ext_regex_affects": "作用范围",
|
||||
"ext_regex_user_input_desc": "用户发送的消息",
|
||||
"ext_regex_user_input": "用户输入",
|
||||
"ext_regex_ai_input_desc": "从生成式API中获取的信息。",
|
||||
@ -1720,9 +1720,9 @@
|
||||
"Chat Lorebook for": "聊天知识书",
|
||||
"chat_world_template_txt": "选定的世界信息将绑定到此聊天。生成 AI 回复时,\n它将与全球和角色传说书中的条目相结合。",
|
||||
"chat_rename_1": "输入聊天的新名称:",
|
||||
"chat_rename_2": "注意!!使用已有文件名会导致错误!!",
|
||||
"chat_rename_3": "此举会将次聊天与标记为“检查点”的聊天解绑。",
|
||||
"chat_rename_4": "不需要在结尾添加 '.JSONL'",
|
||||
"chat_rename_2": "注意!!与其他文件重名会导致错误!!",
|
||||
"chat_rename_3": "此举会将此聊天与标记为“检查点”的聊天解绑。",
|
||||
"chat_rename_4": "(不需要在结尾添加 '.JSONL' 后缀)",
|
||||
"Enter Checkpoint Name:": "输入检查点名称:",
|
||||
"(Leave empty to auto-generate)": "(留空以自动生成)",
|
||||
"The currently existing checkpoint will be unlinked and replaced with the new checkpoint, but can still be found in the Chat Management.": "当前检查点将会被解绑并替换为新的检查点,但仍可在聊天管理中找到。",
|
||||
@ -1829,7 +1829,7 @@
|
||||
"char_import_2": "Chub 知识书(直链或ID)",
|
||||
"char_import_3": "JanitorAI 角色(直链或UUID)",
|
||||
"char_import_4": "Pygmalion.chat 角色(直链或UUID)",
|
||||
"char_import_5": "AICharacterCard.com 角色(直链或ID)",
|
||||
"char_import_5": "AICharacterCards.com 角色(直链或ID)",
|
||||
"char_import_6": "被允许的PNG直链(请参阅",
|
||||
"char_import_7": ")",
|
||||
"char_import_8": "RisuRealm 角色(直链)",
|
||||
@ -1838,7 +1838,7 @@
|
||||
"Enter the Git URL of the extension to install": "输入扩展程序的 Git URL 以安装",
|
||||
"Disclaimer:": "免责声明:",
|
||||
"Please be aware that using external extensions can have unintended side effects and may pose security risks. Always make sure you trust the source before importing an extension. We are not responsible for any damage caused by third-party extensions.": "使用外部的扩展程序可能存在意料外的副作用和安全隐患。在导入扩展程序前,请一定确认其来源可信。我们不为第三方扩展程序造成的任何损失负责。",
|
||||
"Prompt Itemization": "将提示词分条",
|
||||
"Prompt Itemization": "提示词拆分",
|
||||
"Show Raw Prompt": "显示原始提示词",
|
||||
"Copy Prompt": "复制提示词",
|
||||
"Show Prompt Differences": "显示提示词差异",
|
||||
@ -1975,7 +1975,7 @@
|
||||
"Enter your password below to confirm:": "输入您的密码以确认:",
|
||||
"Chat Scenario Override": "聊天场景覆盖",
|
||||
"Remove": "移除",
|
||||
"Unique to this chat.": "Unique to this chat.",
|
||||
"Unique to this chat.": "仅对此聊天生效。",
|
||||
"All group members will use the following scenario text instead of what is specified in their character cards.": "All group members will use the following scenario text instead of what is specified in their character cards.",
|
||||
"The following scenario text will be used instead of the value set in the character card.": "The following scenario text will be used instead of the value set in the character card.",
|
||||
"Checkpoints inherit the scenario override from their parent, and can be changed individually after that.": "Checkpoints inherit the scenario override from their parent, and can be changed individually after that.",
|
||||
@ -2045,8 +2045,8 @@
|
||||
"Post a GitHub issue": "在 GitHub 发布问题",
|
||||
"Contact the developers": "联系开发者",
|
||||
"If you're connected to an API, try asking me something!": "若您已经配置好API,尝试发送些什么吧!",
|
||||
"Title/Memo": "标题/备忘录",
|
||||
"Strategy": "Strategy",
|
||||
"Position": "位置",
|
||||
"Trigger %": "触发率 %"
|
||||
"Title/Memo": "标题(备忘)",
|
||||
"Strategy": "触发策略",
|
||||
"Position": "插入位置",
|
||||
"Trigger %": "触发概率%"
|
||||
}
|
||||
|
@ -483,7 +483,7 @@
|
||||
"separate with commas w/o space between": "用逗號分隔,之間無空格",
|
||||
"Custom Stopping Strings": "自訂停止字串",
|
||||
"JSON serialized array of strings": "JSON 序列化字串數組",
|
||||
"Replace Macro in Custom Stopping Strings": "取代自訂停止字串中的巨集",
|
||||
"Replace Macro in Stop Strings": "取代自訂停止字串中的巨集",
|
||||
"Auto-Continue": "自動繼續",
|
||||
"Allow for Chat Completion APIs": "允許聊天補全 API",
|
||||
"Target length (tokens)": "目標長度(符元)",
|
||||
@ -1381,7 +1381,7 @@
|
||||
"char_import_2": "Chub Lorebook(直接連結或 ID)",
|
||||
"char_import_3": "JanitorAI 角色(直接連結或 ID)",
|
||||
"char_import_4": "Pygmalion.chat 角色(直接連結或 ID)",
|
||||
"char_import_5": "AICharacterCard.com 角色(直接連結或 ID)",
|
||||
"char_import_5": "AICharacterCards.com 角色(直接連結或 ID)",
|
||||
"char_import_6": "直接 PNG 連結(請參閱",
|
||||
"char_import_7": "對於允許的主機)",
|
||||
"char_import_8": "RisuRealm角色(直接連結)",
|
||||
@ -2357,8 +2357,8 @@
|
||||
"Forbid": "禁止",
|
||||
"Aphrodite only. Determines the order of samplers. Skew is always applied post-softmax, so it's not included here.": "僅限 Aphrodite 使用。決定採樣器的順序。偏移總是在 softmax 後應用,因此不包括在此。",
|
||||
"Aphrodite only. Determines the order of samplers.": "僅限 Aphrodite 使用。決定採樣器的順序。",
|
||||
"Show model thoughts": "顯示模型思維鏈",
|
||||
"Display the model's internal thoughts in the response.": "在回應中顯示模型的思維鏈(內部思考過程)。",
|
||||
"Request model reasoning": "請求模型思維鏈",
|
||||
"Allows the model to return its thinking process.": "讓模型回傳其思考過程。",
|
||||
"Generic (OpenAI-compatible) [LM Studio, LiteLLM, etc.]": "通用(兼容 OpenAI)[LM Studio, LiteLLM 等]",
|
||||
"Model ID (optional)": "模型 ID(可選)",
|
||||
"DeepSeek API Key": "DeepSeek API 金鑰",
|
||||
|
496
public/script.js
496
public/script.js
File diff suppressed because it is too large
Load Diff
@ -27,7 +27,6 @@ import {
|
||||
send_on_enter_options,
|
||||
} from './power-user.js';
|
||||
|
||||
import { LoadLocal, SaveLocal, LoadLocalBool } from './f-localStorage.js';
|
||||
import { selected_group, is_group_generating, openGroupById } from './group-chats.js';
|
||||
import { getTagKeyForEntity, applyTagsOnCharacterSelect } from './tags.js';
|
||||
import {
|
||||
@ -41,6 +40,8 @@ import { textgen_types, textgenerationwebui_settings as textgen_settings, getTex
|
||||
import { debounce_timeout } from './constants.js';
|
||||
|
||||
import { Popup } from './popup.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
import { getCurrentUserHandle } from './user.js';
|
||||
|
||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
||||
@ -409,32 +410,34 @@ function RA_autoconnect(PrevApi) {
|
||||
function OpenNavPanels() {
|
||||
if (!isMobile()) {
|
||||
//auto-open R nav if locked and previously open
|
||||
if (LoadLocalBool('NavLockOn') == true && LoadLocalBool('NavOpened') == true) {
|
||||
if (accountStorage.getItem('NavLockOn') == 'true' && accountStorage.getItem('NavOpened') == 'true') {
|
||||
//console.log("RA -- clicking right nav to open");
|
||||
$('#rightNavDrawerIcon').click();
|
||||
}
|
||||
|
||||
//auto-open L nav if locked and previously open
|
||||
if (LoadLocalBool('LNavLockOn') == true && LoadLocalBool('LNavOpened') == true) {
|
||||
if (accountStorage.getItem('LNavLockOn') == 'true' && accountStorage.getItem('LNavOpened') == 'true') {
|
||||
console.debug('RA -- clicking left nav to open');
|
||||
$('#leftNavDrawerIcon').click();
|
||||
}
|
||||
|
||||
//auto-open WI if locked and previously open
|
||||
if (LoadLocalBool('WINavLockOn') == true && LoadLocalBool('WINavOpened') == true) {
|
||||
if (accountStorage.getItem('WINavLockOn') == 'true' && accountStorage.getItem('WINavOpened') == 'true') {
|
||||
console.debug('RA -- clicking WI to open');
|
||||
$('#WIDrawerIcon').click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getUserInputKey = () => getCurrentUserHandle() + '_userInput';
|
||||
|
||||
function restoreUserInput() {
|
||||
if (!power_user.restore_user_input) {
|
||||
console.debug('restoreUserInput disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
const userInput = LoadLocal('userInput');
|
||||
const userInput = localStorage.getItem(getUserInputKey());
|
||||
if (userInput) {
|
||||
$('#send_textarea').val(userInput)[0].dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
@ -442,7 +445,8 @@ function restoreUserInput() {
|
||||
|
||||
function saveUserInput() {
|
||||
const userInput = String($('#send_textarea').val());
|
||||
SaveLocal('userInput', userInput);
|
||||
localStorage.setItem(getUserInputKey(), userInput);
|
||||
console.debug('User Input -- ', userInput);
|
||||
}
|
||||
const saveUserInputDebounced = debounce(saveUserInput);
|
||||
|
||||
@ -739,7 +743,7 @@ export function initRossMods() {
|
||||
|
||||
//toggle pin class when lock toggle clicked
|
||||
$(RPanelPin).on('click', function () {
|
||||
SaveLocal('NavLockOn', $(RPanelPin).prop('checked'));
|
||||
accountStorage.setItem('NavLockOn', $(RPanelPin).prop('checked'));
|
||||
if ($(RPanelPin).prop('checked') == true) {
|
||||
//console.log('adding pin class to right nav');
|
||||
$(RightNavPanel).addClass('pinnedOpen');
|
||||
@ -757,7 +761,7 @@ export function initRossMods() {
|
||||
}
|
||||
});
|
||||
$(LPanelPin).on('click', function () {
|
||||
SaveLocal('LNavLockOn', $(LPanelPin).prop('checked'));
|
||||
accountStorage.setItem('LNavLockOn', $(LPanelPin).prop('checked'));
|
||||
if ($(LPanelPin).prop('checked') == true) {
|
||||
//console.log('adding pin class to Left nav');
|
||||
$(LeftNavPanel).addClass('pinnedOpen');
|
||||
@ -776,7 +780,7 @@ export function initRossMods() {
|
||||
});
|
||||
|
||||
$(WIPanelPin).on('click', function () {
|
||||
SaveLocal('WINavLockOn', $(WIPanelPin).prop('checked'));
|
||||
accountStorage.setItem('WINavLockOn', $(WIPanelPin).prop('checked'));
|
||||
if ($(WIPanelPin).prop('checked') == true) {
|
||||
console.debug('adding pin class to WI');
|
||||
$(WorldInfo).addClass('pinnedOpen');
|
||||
@ -796,8 +800,8 @@ export function initRossMods() {
|
||||
});
|
||||
|
||||
// read the state of right Nav Lock and apply to rightnav classlist
|
||||
$(RPanelPin).prop('checked', LoadLocalBool('NavLockOn'));
|
||||
if (LoadLocalBool('NavLockOn') == true) {
|
||||
$(RPanelPin).prop('checked', accountStorage.getItem('NavLockOn') == 'true');
|
||||
if (accountStorage.getItem('NavLockOn') == 'true') {
|
||||
//console.log('setting pin class via local var');
|
||||
$(RightNavPanel).addClass('pinnedOpen');
|
||||
$(RightNavDrawerIcon).addClass('drawerPinnedOpen');
|
||||
@ -808,8 +812,8 @@ export function initRossMods() {
|
||||
$(RightNavDrawerIcon).addClass('drawerPinnedOpen');
|
||||
}
|
||||
// read the state of left Nav Lock and apply to leftnav classlist
|
||||
$(LPanelPin).prop('checked', LoadLocalBool('LNavLockOn'));
|
||||
if (LoadLocalBool('LNavLockOn') == true) {
|
||||
$(LPanelPin).prop('checked', accountStorage.getItem('LNavLockOn') === 'true');
|
||||
if (accountStorage.getItem('LNavLockOn') == 'true') {
|
||||
//console.log('setting pin class via local var');
|
||||
$(LeftNavPanel).addClass('pinnedOpen');
|
||||
$(LeftNavDrawerIcon).addClass('drawerPinnedOpen');
|
||||
@ -821,8 +825,8 @@ export function initRossMods() {
|
||||
}
|
||||
|
||||
// read the state of left Nav Lock and apply to leftnav classlist
|
||||
$(WIPanelPin).prop('checked', LoadLocalBool('WINavLockOn'));
|
||||
if (LoadLocalBool('WINavLockOn') == true) {
|
||||
$(WIPanelPin).prop('checked', accountStorage.getItem('WINavLockOn') === 'true');
|
||||
if (accountStorage.getItem('WINavLockOn') == 'true') {
|
||||
//console.log('setting pin class via local var');
|
||||
$(WorldInfo).addClass('pinnedOpen');
|
||||
$(WIDrawerIcon).addClass('drawerPinnedOpen');
|
||||
@ -837,22 +841,22 @@ export function initRossMods() {
|
||||
//save state of Right nav being open or closed
|
||||
$('#rightNavDrawerIcon').on('click', function () {
|
||||
if (!$('#rightNavDrawerIcon').hasClass('openIcon')) {
|
||||
SaveLocal('NavOpened', 'true');
|
||||
} else { SaveLocal('NavOpened', 'false'); }
|
||||
accountStorage.setItem('NavOpened', 'true');
|
||||
} else { accountStorage.setItem('NavOpened', 'false'); }
|
||||
});
|
||||
|
||||
//save state of Left nav being open or closed
|
||||
$('#leftNavDrawerIcon').on('click', function () {
|
||||
if (!$('#leftNavDrawerIcon').hasClass('openIcon')) {
|
||||
SaveLocal('LNavOpened', 'true');
|
||||
} else { SaveLocal('LNavOpened', 'false'); }
|
||||
accountStorage.setItem('LNavOpened', 'true');
|
||||
} else { accountStorage.setItem('LNavOpened', 'false'); }
|
||||
});
|
||||
|
||||
//save state of Left nav being open or closed
|
||||
$('#WorldInfo').on('click', function () {
|
||||
if (!$('#WorldInfo').hasClass('openIcon')) {
|
||||
SaveLocal('WINavOpened', 'true');
|
||||
} else { SaveLocal('WINavOpened', 'false'); }
|
||||
accountStorage.setItem('WINavOpened', 'true');
|
||||
} else { accountStorage.setItem('WINavOpened', 'false'); }
|
||||
});
|
||||
|
||||
var chatbarInFocus = false;
|
||||
@ -868,8 +872,8 @@ export function initRossMods() {
|
||||
OpenNavPanels();
|
||||
}, 300);
|
||||
|
||||
$(SelectedCharacterTab).click(function () { SaveLocal('SelectedNavTab', 'rm_button_selected_ch'); });
|
||||
$('#rm_button_characters').click(function () { SaveLocal('SelectedNavTab', 'rm_button_characters'); });
|
||||
$(SelectedCharacterTab).click(function () { accountStorage.setItem('SelectedNavTab', 'rm_button_selected_ch'); });
|
||||
$('#rm_button_characters').click(function () { accountStorage.setItem('SelectedNavTab', 'rm_button_characters'); });
|
||||
|
||||
// when a char is selected from the list, save them as the auto-load character for next page load
|
||||
|
||||
@ -1063,14 +1067,21 @@ export function initRossMods() {
|
||||
// Ctrl+Enter for Regeneration Last Response. If editing, accept the edits instead
|
||||
if (event.ctrlKey && event.key == 'Enter') {
|
||||
const editMesDone = $('.mes_edit_done:visible');
|
||||
const reasoningMesDone = $('.mes_reasoning_edit_done:visible');
|
||||
if (editMesDone.length > 0) {
|
||||
console.debug('Accepting edits with Ctrl+Enter');
|
||||
$('#send_textarea').focus();
|
||||
$('#send_textarea').trigger('focus');
|
||||
editMesDone.trigger('click');
|
||||
return;
|
||||
} else if (is_send_press == false) {
|
||||
} else if (reasoningMesDone.length > 0) {
|
||||
console.debug('Accepting edits with Ctrl+Enter');
|
||||
$('#send_textarea').trigger('focus');
|
||||
reasoningMesDone.trigger('click');
|
||||
return;
|
||||
}
|
||||
else if (is_send_press == false) {
|
||||
const skipConfirmKey = 'RegenerateWithCtrlEnter';
|
||||
const skipConfirm = LoadLocalBool(skipConfirmKey);
|
||||
const skipConfirm = accountStorage.getItem(skipConfirmKey) === 'true';
|
||||
function doRegenerate() {
|
||||
console.debug('Regenerating with Ctrl+Enter');
|
||||
$('#option_regenerate').trigger('click');
|
||||
@ -1082,13 +1093,15 @@ export function initRossMods() {
|
||||
let regenerateWithCtrlEnter = false;
|
||||
const result = await Popup.show.confirm('Regenerate Message', 'Are you sure you want to regenerate the latest message?', {
|
||||
customInputs: [{ id: 'regenerateWithCtrlEnter', label: 'Don\'t ask again' }],
|
||||
onClose: (popup) => regenerateWithCtrlEnter = popup.inputResults.get('regenerateWithCtrlEnter') ?? false,
|
||||
onClose: (popup) => {
|
||||
regenerateWithCtrlEnter = popup.inputResults.get('regenerateWithCtrlEnter') ?? false;
|
||||
},
|
||||
});
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
SaveLocal(skipConfirmKey, regenerateWithCtrlEnter);
|
||||
accountStorage.setItem(skipConfirmKey, String(regenerateWithCtrlEnter));
|
||||
doRegenerate();
|
||||
}
|
||||
return;
|
||||
|
@ -566,7 +566,7 @@ export function initAuthorsNote() {
|
||||
namedArgumentList: [],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'position', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user', 'assistant'],
|
||||
'role', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user', 'assistant'],
|
||||
),
|
||||
],
|
||||
helpString: `
|
||||
|
@ -96,8 +96,13 @@ function highlightLockedBackground() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the background for the current chat
|
||||
* @param {Event} e Click event
|
||||
* @returns {string} Empty string
|
||||
*/
|
||||
function onLockBackgroundClick(e) {
|
||||
e.stopPropagation();
|
||||
e?.stopPropagation();
|
||||
|
||||
const chatName = getCurrentChatId();
|
||||
|
||||
@ -106,7 +111,7 @@ function onLockBackgroundClick(e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const relativeBgImage = getUrlParameter(this);
|
||||
const relativeBgImage = getUrlParameter(this) ?? background_settings.url;
|
||||
|
||||
saveBackgroundMetadata(relativeBgImage);
|
||||
setCustomBackground();
|
||||
@ -114,8 +119,13 @@ function onLockBackgroundClick(e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks the background for the current chat
|
||||
* @param {Event} e Click event
|
||||
* @returns {string} Empty string
|
||||
*/
|
||||
function onUnlockBackgroundClick(e) {
|
||||
e.stopPropagation();
|
||||
e?.stopPropagation();
|
||||
removeBackgroundMetadata();
|
||||
unsetCustomBackground();
|
||||
highlightLockedBackground();
|
||||
@ -482,10 +492,10 @@ function highlightNewBackground(bg) {
|
||||
*/
|
||||
function setFittingClass(fitting) {
|
||||
const backgrounds = $('#bg1, #bg_custom');
|
||||
backgrounds.toggleClass('cover', fitting === 'cover');
|
||||
backgrounds.toggleClass('contain', fitting === 'contain');
|
||||
backgrounds.toggleClass('stretch', fitting === 'stretch');
|
||||
backgrounds.toggleClass('center', fitting === 'center');
|
||||
for (const option of ['cover', 'contain', 'stretch', 'center']) {
|
||||
backgrounds.toggleClass(option, option === fitting);
|
||||
}
|
||||
background_settings.fitting = fitting;
|
||||
}
|
||||
|
||||
function onBackgroundFilterInput() {
|
||||
@ -513,12 +523,12 @@ export function initBackgrounds() {
|
||||
$('#add_bg_button').on('change', onBackgroundUploadSelected);
|
||||
$('#bg-filter').on('input', onBackgroundFilterInput);
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'lockbg',
|
||||
callback: onLockBackgroundClick,
|
||||
callback: () => onLockBackgroundClick(new CustomEvent('click')),
|
||||
aliases: ['bglock'],
|
||||
helpString: 'Locks a background for the currently selected chat',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'unlockbg',
|
||||
callback: onUnlockBackgroundClick,
|
||||
callback: () => onUnlockBackgroundClick(new CustomEvent('click')),
|
||||
aliases: ['bgunlock'],
|
||||
helpString: 'Unlocks a background for the currently selected chat',
|
||||
}));
|
||||
|
@ -59,6 +59,17 @@ const hash_derivations = {
|
||||
// Tulu-3-8B
|
||||
// Tulu-3-70B
|
||||
'Tulu'
|
||||
,
|
||||
|
||||
// DeepSeek V2.5
|
||||
'54d400beedcd17f464e10063e0577f6f798fa896266a912d8a366f8a2fcc0bca':
|
||||
'DeepSeek-V2.5'
|
||||
,
|
||||
|
||||
// DeepSeek R1
|
||||
'b6835114b7303ddd78919a82e4d9f7d8c26ed0d7dfc36beeb12d524f6144eab1':
|
||||
'DeepSeek-V2.5'
|
||||
,
|
||||
};
|
||||
|
||||
const substr_derivations = {
|
||||
@ -87,6 +98,6 @@ export async function deriveTemplatesFromChatTemplate(chat_template, hash) {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Unknown chat template hash: ${hash} for [${chat_template}]`);
|
||||
console.warn(`Unknown chat template hash: ${hash} for [${chat_template}]`);
|
||||
return null;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
getCurrentChatId,
|
||||
getRequestHeaders,
|
||||
hideSwipeButtons,
|
||||
name1,
|
||||
name2,
|
||||
reloadCurrentChat,
|
||||
saveChatDebounced,
|
||||
@ -21,6 +22,7 @@ import {
|
||||
chat_metadata,
|
||||
neutralCharacterName,
|
||||
updateChatMetadata,
|
||||
system_message_types,
|
||||
} from '../script.js';
|
||||
import { selected_group } from './group-chats.js';
|
||||
import { power_user } from './power-user.js';
|
||||
@ -34,6 +36,7 @@ import {
|
||||
humanFileSize,
|
||||
saveBase64AsFile,
|
||||
extractTextFromOffice,
|
||||
download,
|
||||
} from './utils.js';
|
||||
import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
|
||||
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||
@ -41,6 +44,8 @@ import { ScraperManager } from './scrapers.js';
|
||||
import { DragAndDropHandler } from './dragdrop.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { t } from './i18n.js';
|
||||
import { humanizedDateTime } from './RossAscends-mods.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileAttachment
|
||||
@ -617,21 +622,56 @@ async function enlargeMessageImage() {
|
||||
}
|
||||
|
||||
async function deleteMessageImage() {
|
||||
const value = await callGenericPopup('<h3>Delete image from message?<br>This action can\'t be undone.</h3>', POPUP_TYPE.CONFIRM);
|
||||
const value = await callGenericPopup('<h3>Delete image from message?<br>This action can\'t be undone.</h3>', POPUP_TYPE.TEXT, '', {
|
||||
okButton: t`Delete one`,
|
||||
customButtons: [
|
||||
{
|
||||
text: t`Delete all`,
|
||||
appendAtEnd: true,
|
||||
result: POPUP_RESULT.CUSTOM1,
|
||||
},
|
||||
{
|
||||
text: t`Cancel`,
|
||||
appendAtEnd: true,
|
||||
result: POPUP_RESULT.CANCELLED,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (value !== POPUP_RESULT.AFFIRMATIVE) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mesBlock = $(this).closest('.mes');
|
||||
const mesId = mesBlock.attr('mesid');
|
||||
const message = chat[mesId];
|
||||
delete message.extra.image;
|
||||
delete message.extra.inline_image;
|
||||
delete message.extra.title;
|
||||
delete message.extra.append_title;
|
||||
mesBlock.find('.mes_img_container').removeClass('img_extra');
|
||||
mesBlock.find('.mes_img').attr('src', '');
|
||||
|
||||
let isLastImage = true;
|
||||
|
||||
if (Array.isArray(message.extra.image_swipes)) {
|
||||
const indexOf = message.extra.image_swipes.indexOf(message.extra.image);
|
||||
if (indexOf > -1) {
|
||||
message.extra.image_swipes.splice(indexOf, 1);
|
||||
isLastImage = message.extra.image_swipes.length === 0;
|
||||
if (!isLastImage) {
|
||||
const newIndex = Math.min(indexOf, message.extra.image_swipes.length - 1);
|
||||
message.extra.image = message.extra.image_swipes[newIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isLastImage || value === POPUP_RESULT.CUSTOM1) {
|
||||
delete message.extra.image;
|
||||
delete message.extra.inline_image;
|
||||
delete message.extra.title;
|
||||
delete message.extra.append_title;
|
||||
delete message.extra.image_swipes;
|
||||
mesBlock.find('.mes_img_container').removeClass('img_extra');
|
||||
mesBlock.find('.mes_img').attr('src', '');
|
||||
} else {
|
||||
appendMediaToMessage(message, mesBlock);
|
||||
}
|
||||
|
||||
await saveChatConditional();
|
||||
}
|
||||
|
||||
@ -1039,8 +1079,8 @@ async function openAttachmentManager() {
|
||||
renderAttachments();
|
||||
});
|
||||
|
||||
let sortField = localStorage.getItem('DataBank_sortField') || 'created';
|
||||
let sortOrder = localStorage.getItem('DataBank_sortOrder') || 'desc';
|
||||
let sortField = accountStorage.getItem('DataBank_sortField') || 'created';
|
||||
let sortOrder = accountStorage.getItem('DataBank_sortOrder') || 'desc';
|
||||
let filterString = '';
|
||||
|
||||
const template = $(await renderExtensionTemplateAsync('attachments', 'manager', {}));
|
||||
@ -1056,8 +1096,8 @@ async function openAttachmentManager() {
|
||||
|
||||
sortField = this.selectedOptions[0].dataset.sortField;
|
||||
sortOrder = this.selectedOptions[0].dataset.sortOrder;
|
||||
localStorage.setItem('DataBank_sortField', sortField);
|
||||
localStorage.setItem('DataBank_sortOrder', sortOrder);
|
||||
accountStorage.setItem('DataBank_sortField', sortField);
|
||||
accountStorage.setItem('DataBank_sortOrder', sortOrder);
|
||||
renderAttachments();
|
||||
});
|
||||
function handleBulkAction(action) {
|
||||
@ -1437,6 +1477,19 @@ jQuery(function () {
|
||||
await viewMessageFile(messageId);
|
||||
});
|
||||
|
||||
$(document).on('click', '.assistant_note_export', async function () {
|
||||
const chatToSave = [
|
||||
{
|
||||
user_name: name1,
|
||||
character_name: name2,
|
||||
chat_metadata: chat_metadata,
|
||||
},
|
||||
...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
|
||||
];
|
||||
|
||||
download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json');
|
||||
});
|
||||
|
||||
// Do not change. #attachFile is added by extension.
|
||||
$(document).on('click', '#attachFile', function () {
|
||||
$('#file_form_input').trigger('click');
|
||||
|
@ -9,6 +9,7 @@ import { getContext } from './st-context.js';
|
||||
import { isAdmin } from './user.js';
|
||||
import { t } from './i18n.js';
|
||||
import { debounce_timeout } from './constants.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
export {
|
||||
getContext,
|
||||
@ -714,7 +715,7 @@ async function showExtensionsDetails() {
|
||||
htmlExternal.append(htmlLoading);
|
||||
|
||||
const sortOrderKey = 'extensions_sortByName';
|
||||
const sortByName = localStorage.getItem(sortOrderKey) === 'true';
|
||||
const sortByName = accountStorage.getItem(sortOrderKey) === 'true';
|
||||
const sortFn = sortByName ? sortManifestsByName : sortManifestsByOrder;
|
||||
const extensions = Object.entries(manifests).sort((a, b) => sortFn(a[1], b[1])).map(getExtensionData);
|
||||
|
||||
@ -745,7 +746,7 @@ async function showExtensionsDetails() {
|
||||
text: sortByName ? t`Sort: Display Name` : t`Sort: Loading Order`,
|
||||
action: async () => {
|
||||
abortController.abort();
|
||||
localStorage.setItem(sortOrderKey, sortByName ? 'false' : 'true');
|
||||
accountStorage.setItem(sortOrderKey, sortByName ? 'false' : 'true');
|
||||
await showExtensionsDetails();
|
||||
},
|
||||
};
|
||||
@ -1153,11 +1154,11 @@ async function checkForExtensionUpdates(force) {
|
||||
const currentDate = new Date().toDateString();
|
||||
|
||||
// Don't nag more than once a day
|
||||
if (localStorage.getItem(STORAGE_NAG_KEY) === currentDate) {
|
||||
if (accountStorage.getItem(STORAGE_NAG_KEY) === currentDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
localStorage.setItem(STORAGE_NAG_KEY, currentDate);
|
||||
accountStorage.setItem(STORAGE_NAG_KEY, currentDate);
|
||||
}
|
||||
|
||||
const isCurrentUserAdmin = isAdmin();
|
||||
|
@ -8,6 +8,7 @@ import { getRequestHeaders, processDroppedFiles, eventSource, event_types } from
|
||||
import { deleteExtension, extensionNames, getContext, installExtension, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
|
||||
import { executeSlashCommands } from '../../slash-commands.js';
|
||||
import { accountStorage } from '../../util/AccountStorage.js';
|
||||
import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js';
|
||||
export { MODULE_NAME };
|
||||
|
||||
@ -432,14 +433,14 @@ jQuery(async () => {
|
||||
connectButton.on('click', async function () {
|
||||
const url = DOMPurify.sanitize(String(assetsJsonUrl.val()));
|
||||
const rememberKey = `Assets_SkipConfirm_${getStringHash(url)}`;
|
||||
const skipConfirm = localStorage.getItem(rememberKey) === 'true';
|
||||
const skipConfirm = accountStorage.getItem(rememberKey) === 'true';
|
||||
|
||||
const confirmation = skipConfirm || await Popup.show.confirm('Loading Asset List', `<span>Are you sure you want to connect to the following url?</span><var>${url}</var>`, {
|
||||
customInputs: [{ id: 'assets-remember', label: 'Don\'t ask again for this URL' }],
|
||||
onClose: popup => {
|
||||
if (popup.result) {
|
||||
const rememberValue = popup.inputResults.get('assets-remember');
|
||||
localStorage.setItem(rememberKey, String(rememberValue));
|
||||
accountStorage.setItem(rememberKey, String(rememberValue));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -10,7 +10,7 @@
|
||||
<select id="caption_source" class="text_pole">
|
||||
<option value="local" data-i18n="Local">Local</option>
|
||||
<option value="multimodal" data-i18n="Multimodal (OpenAI / Anthropic / llama / Google)">Multimodal (OpenAI / Anthropic / llama / Google)</option>
|
||||
<option value="extras" data-i18n="Extras">Extras</option>
|
||||
<option value="extras" data-i18n="Extras">Extras (deprecated)</option>
|
||||
<option value="horde" data-i18n="Horde">Horde</option>
|
||||
</select>
|
||||
<div id="caption_multimodal_block" class="flex-container wide100p">
|
||||
@ -53,7 +53,15 @@
|
||||
<option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option>
|
||||
<option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option>
|
||||
<option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option>
|
||||
<option data-type="google" value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option>
|
||||
<option data-type="google" value="gemini-2.0-pro-exp-02-05">gemini-2.0-pro-exp-02-05</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-lite-preview">gemini-2.0-flash-lite-preview</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-lite-preview-02-05">gemini-2.0-flash-lite-preview-02-05</option>
|
||||
<option data-type="google" value="gemini-2.0-flash">gemini-2.0-flash</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-001">gemini-2.0-flash-001</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-exp">gemini-2.0-flash-exp</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-thinking-exp">gemini-2.0-flash-thinking-exp</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-thinking-exp-01-21">gemini-2.0-flash-thinking-exp-01-21</option>
|
||||
<option data-type="google" value="gemini-2.0-flash-thinking-exp-1219">gemini-2.0-flash-thinking-exp-1219</option>
|
||||
<option data-type="google" value="gemini-1.5-flash">gemini-1.5-flash</option>
|
||||
<option data-type="google" value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option>
|
||||
|
@ -30,6 +30,7 @@ const CC_COMMANDS = [
|
||||
'api-url',
|
||||
'model',
|
||||
'proxy',
|
||||
'stop-strings',
|
||||
];
|
||||
|
||||
const TC_COMMANDS = [
|
||||
@ -43,6 +44,7 @@ const TC_COMMANDS = [
|
||||
'context',
|
||||
'instruct-state',
|
||||
'tokenizer',
|
||||
'stop-strings',
|
||||
];
|
||||
|
||||
const FANCY_NAMES = {
|
||||
@ -57,6 +59,7 @@ const FANCY_NAMES = {
|
||||
'instruct': 'Instruct Template',
|
||||
'context': 'Context Template',
|
||||
'tokenizer': 'Tokenizer',
|
||||
'stop-strings': 'Custom Stopping Strings',
|
||||
};
|
||||
|
||||
/**
|
||||
@ -138,6 +141,7 @@ const profilesProvider = () => [
|
||||
* @property {string} [context] Context Template
|
||||
* @property {string} [instruct-state] Instruct Mode
|
||||
* @property {string} [tokenizer] Tokenizer
|
||||
* @property {string} [stop-strings] Custom Stopping Strings
|
||||
* @property {string[]} [exclude] Commands to exclude
|
||||
*/
|
||||
|
||||
|
@ -2178,7 +2178,6 @@ function migrateSettings() {
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
isRequired: true,
|
||||
enumProvider: commonEnumProviders.characters('character'),
|
||||
forceEnum: true,
|
||||
}),
|
||||
],
|
||||
helpString: 'Returns the last set sprite / expression for the named character.',
|
||||
|
@ -23,7 +23,7 @@
|
||||
<small data-i18n="Select the API for classifying expressions.">Select the API for classifying expressions.</small>
|
||||
<select id="expression_api" class="flex1 margin0">
|
||||
<option value="0" data-i18n="Local">Local</option>
|
||||
<option value="1" data-i18n="Extras">Extras</option>
|
||||
<option value="1" data-i18n="Extras">Extras (deprecated)</option>
|
||||
<option value="2" data-i18n="Main API">Main API</option>
|
||||
<option value="3" data-i18n="WebLLM Extension">WebLLM Extension</option>
|
||||
</select>
|
||||
|
@ -441,7 +441,6 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
description: 'character name',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
enumProvider: commonEnumProviders.characters('character'),
|
||||
forceEnum: true,
|
||||
}),
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'group',
|
||||
|
@ -12,7 +12,7 @@
|
||||
<label for="summary_source" data-i18n="ext_sum_with">Summarize with:</label>
|
||||
<select id="summary_source">
|
||||
<option value="main" data-i18n="ext_sum_main_api">Main API</option>
|
||||
<option value="extras">Extras API</option>
|
||||
<option value="extras">Extras API (deprecated)</option>
|
||||
<option value="webllm" data-i18n="ext_sum_webllm">WebLLM Extension</option>
|
||||
</select><br>
|
||||
|
||||
|
@ -10,6 +10,7 @@ import { SlashCommandExecutor } from '../../../slash-commands/SlashCommandExecut
|
||||
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
|
||||
import { SlashCommandParserError } from '../../../slash-commands/SlashCommandParserError.js';
|
||||
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
|
||||
import { accountStorage } from '../../../util/AccountStorage.js';
|
||||
import { debounce, delay, getSortableDelay, showFontAwesomePicker } from '../../../utils.js';
|
||||
import { log, quickReplyApi, warn } from '../index.js';
|
||||
import { QuickReplyContextLink } from './QuickReplyContextLink.js';
|
||||
@ -544,9 +545,9 @@ export class QuickReply {
|
||||
this.editorSyntax = messageSyntaxInner;
|
||||
/**@type {HTMLInputElement}*/
|
||||
const wrap = dom.querySelector('#qr--modal-wrap');
|
||||
wrap.checked = JSON.parse(localStorage.getItem('qr--wrap') ?? 'false');
|
||||
wrap.checked = JSON.parse(accountStorage.getItem('qr--wrap') ?? 'false');
|
||||
wrap.addEventListener('click', () => {
|
||||
localStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
|
||||
accountStorage.setItem('qr--wrap', JSON.stringify(wrap.checked));
|
||||
updateWrap();
|
||||
});
|
||||
const updateWrap = () => {
|
||||
@ -594,27 +595,27 @@ export class QuickReply {
|
||||
};
|
||||
/**@type {HTMLInputElement}*/
|
||||
const tabSize = dom.querySelector('#qr--modal-tabSize');
|
||||
tabSize.value = JSON.parse(localStorage.getItem('qr--tabSize') ?? '4');
|
||||
tabSize.value = JSON.parse(accountStorage.getItem('qr--tabSize') ?? '4');
|
||||
const updateTabSize = () => {
|
||||
message.style.tabSize = tabSize.value;
|
||||
messageSyntaxInner.style.tabSize = tabSize.value;
|
||||
updateScrollDebounced();
|
||||
};
|
||||
tabSize.addEventListener('change', () => {
|
||||
localStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
|
||||
accountStorage.setItem('qr--tabSize', JSON.stringify(Number(tabSize.value)));
|
||||
updateTabSize();
|
||||
});
|
||||
/**@type {HTMLInputElement}*/
|
||||
const executeShortcut = dom.querySelector('#qr--modal-executeShortcut');
|
||||
executeShortcut.checked = JSON.parse(localStorage.getItem('qr--executeShortcut') ?? 'true');
|
||||
executeShortcut.checked = JSON.parse(accountStorage.getItem('qr--executeShortcut') ?? 'true');
|
||||
executeShortcut.addEventListener('click', () => {
|
||||
localStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
|
||||
accountStorage.setItem('qr--executeShortcut', JSON.stringify(executeShortcut.checked));
|
||||
});
|
||||
/**@type {HTMLInputElement}*/
|
||||
const syntax = dom.querySelector('#qr--modal-syntax');
|
||||
syntax.checked = JSON.parse(localStorage.getItem('qr--syntax') ?? 'true');
|
||||
syntax.checked = JSON.parse(accountStorage.getItem('qr--syntax') ?? 'true');
|
||||
syntax.addEventListener('click', () => {
|
||||
localStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
|
||||
accountStorage.setItem('qr--syntax', JSON.stringify(syntax.checked));
|
||||
updateSyntaxEnabled();
|
||||
});
|
||||
if (navigator.keyboard) {
|
||||
|
@ -1,15 +1,14 @@
|
||||
import { getRequestHeaders, substituteParams } from '../../../../script.js';
|
||||
import { Popup, POPUP_RESULT, POPUP_TYPE } from '../../../popup.js';
|
||||
import { executeSlashCommands, executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
|
||||
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
|
||||
import { executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
|
||||
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
|
||||
import { debounceAsync, log, warn } from '../index.js';
|
||||
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
|
||||
import { debounceAsync, warn } from '../index.js';
|
||||
import { QuickReply } from './QuickReply.js';
|
||||
|
||||
export class QuickReplySet {
|
||||
/**@type {QuickReplySet[]}*/ static list = [];
|
||||
|
||||
|
||||
static from(props) {
|
||||
props.qrList = []; //props.qrList?.map(it=>QuickReply.from(it));
|
||||
const instance = Object.assign(new this(), props);
|
||||
@ -24,9 +23,6 @@ export class QuickReplySet {
|
||||
return this.list.find(it=>it.name == name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**@type {string}*/ name;
|
||||
/**@type {boolean}*/ disableSend = false;
|
||||
/**@type {boolean}*/ placeBeforeInput = false;
|
||||
@ -34,19 +30,12 @@ export class QuickReplySet {
|
||||
/**@type {string}*/ color = 'transparent';
|
||||
/**@type {boolean}*/ onlyBorderColor = false;
|
||||
/**@type {QuickReply[]}*/ qrList = [];
|
||||
|
||||
/**@type {number}*/ idIndex = 0;
|
||||
|
||||
/**@type {boolean}*/ isDeleted = false;
|
||||
|
||||
/**@type {function}*/ save;
|
||||
|
||||
/**@type {HTMLElement}*/ dom;
|
||||
/**@type {HTMLElement}*/ settingsDom;
|
||||
|
||||
|
||||
|
||||
|
||||
constructor() {
|
||||
this.save = debounceAsync(()=>this.performSave(), 200);
|
||||
}
|
||||
@ -55,9 +44,6 @@ export class QuickReplySet {
|
||||
this.qrList.forEach(qr=>this.hookQuickReply(qr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unrender() {
|
||||
this.dom?.remove();
|
||||
this.dom = null;
|
||||
@ -100,9 +86,6 @@ export class QuickReplySet {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
renderSettings() {
|
||||
if (!this.settingsDom) {
|
||||
this.settingsDom = document.createElement('div'); {
|
||||
@ -123,9 +106,6 @@ export class QuickReplySet {
|
||||
this.settingsDom.append(qr.renderSettings(idx));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {QuickReply} qr
|
||||
@ -138,6 +118,7 @@ export class QuickReplySet {
|
||||
closure.scope.setMacro('arg::*', '');
|
||||
return (await closure.execute())?.pipe;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {QuickReply} qr The QR to execute.
|
||||
@ -207,6 +188,7 @@ export class QuickReplySet {
|
||||
document.querySelector('#send_but').click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {QuickReply} qr
|
||||
* @param {string} [message] - optional altered message to be used
|
||||
@ -220,9 +202,6 @@ export class QuickReplySet {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
addQuickReply(data = {}) {
|
||||
const id = Math.max(this.idIndex, this.qrList.reduce((max,qr)=>Math.max(max,qr.id),0)) + 1;
|
||||
data.id =
|
||||
@ -239,6 +218,7 @@ export class QuickReplySet {
|
||||
this.save();
|
||||
return qr;
|
||||
}
|
||||
|
||||
addQuickReplyFromText(qrJson) {
|
||||
let data;
|
||||
if (qrJson) {
|
||||
@ -371,7 +351,6 @@ export class QuickReplySet {
|
||||
this.save();
|
||||
}
|
||||
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
version: 2,
|
||||
@ -386,7 +365,6 @@ export class QuickReplySet {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
async performSave() {
|
||||
const response = await fetch('/api/quick-replies/save', {
|
||||
method: 'POST',
|
||||
|
@ -883,6 +883,10 @@ export class SlashCommandHandler {
|
||||
}
|
||||
}
|
||||
getQuickReply(args) {
|
||||
if (!args.id && !args.label) {
|
||||
toastr.error('Please provide a valid id or label.');
|
||||
return '';
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(this.api.getQrByLabel(args.set, args.id !== undefined ? Number(args.id) : args.label));
|
||||
} catch (ex) {
|
||||
|
@ -346,7 +346,7 @@ export class SettingsUi {
|
||||
}
|
||||
|
||||
async addQrSet() {
|
||||
const name = await Popup.show.input('Create a new World Info', 'Enter a name for the new Quick Reply Set:');
|
||||
const name = await Popup.show.input('Create a new Quick Reply Set', 'Enter a name for the new Quick Reply Set:');
|
||||
if (name && name.length > 0) {
|
||||
const oldQrs = QuickReplySet.get(name);
|
||||
if (oldQrs) {
|
||||
|
@ -94,6 +94,12 @@
|
||||
<span data-i18n="World Info">World Info</span>
|
||||
</label>
|
||||
</div>
|
||||
<div data-i18n="[title]ext_regex_reasoning_desc" title="Reasoning block contents. When 'Only Format Prompt' is checked, it will also affect the reasoning contents added to the prompt.">
|
||||
<label class="checkbox flex-container">
|
||||
<input type="checkbox" name="replace_position" value="6">
|
||||
<span data-i18n="Reasoning">Reasoning</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex-container wide100p marginTop5">
|
||||
<div class="flex1 flex-container flexNoGap">
|
||||
<small data-i18n="[title]ext_regex_min_depth_desc" title="When applied to prompts or display, only affect messages that are at least N levels deep. 0 = last message, 1 = penultimate message, etc. Only counts WI entries @Depth and usable messages, i.e. not hidden or system.">
|
||||
|
@ -20,6 +20,7 @@ const regex_placement = {
|
||||
SLASH_COMMAND: 3,
|
||||
// 4 - sendAs (legacy)
|
||||
WORLD_INFO: 5,
|
||||
REASONING: 6,
|
||||
};
|
||||
|
||||
export const substitute_find_regex = {
|
||||
@ -94,7 +95,7 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown,
|
||||
// Script applies to Generate and input is Generate
|
||||
(script.promptOnly && isPrompt) ||
|
||||
// Script applies to all cases when neither "only"s are true, but there's no need to do it when `isMarkdown`, the as source (chat history) should already be changed beforehand
|
||||
(!script.markdownOnly && !script.promptOnly && !isMarkdown)
|
||||
(!script.markdownOnly && !script.promptOnly && !isMarkdown && !isPrompt)
|
||||
) {
|
||||
if (isEdit && !script.runOnEdit) {
|
||||
console.debug(`getRegexedString: Skipping script ${script.scriptName} because it does not run on edit`);
|
||||
|
@ -10,6 +10,7 @@ import { SlashCommandParser } from '../../slash-commands/SlashCommandParser.js';
|
||||
import { download, getFileText, getSortableDelay, uuidv4 } from '../../utils.js';
|
||||
import { regex_placement, runRegexScript, substitute_find_regex } from './engine.js';
|
||||
import { t } from '../../i18n.js';
|
||||
import { accountStorage } from '../../util/AccountStorage.js';
|
||||
|
||||
/**
|
||||
* @typedef {object} RegexScript
|
||||
@ -18,7 +19,7 @@ import { t } from '../../i18n.js';
|
||||
* @property {string} replaceString - The replace string
|
||||
* @property {string[]} trimStrings - The trim strings
|
||||
* @property {string?} findRegex - The find regex
|
||||
* @property {string?} substituteRegex - The substitute regex
|
||||
* @property {number?} substituteRegex - The substitute regex
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -440,8 +441,8 @@ async function checkEmbeddedRegexScripts() {
|
||||
if (avatar && !extension_settings.character_allowed_regex.includes(avatar)) {
|
||||
const checkKey = `AlertRegex_${characters[chid].avatar}`;
|
||||
|
||||
if (!localStorage.getItem(checkKey)) {
|
||||
localStorage.setItem(checkKey, 'true');
|
||||
if (!accountStorage.getItem(checkKey)) {
|
||||
accountStorage.setItem(checkKey, 'true');
|
||||
const template = await renderExtensionTemplateAsync('regex', 'embeddedScripts', {});
|
||||
const result = await callGenericPopup(template, POPUP_TYPE.CONFIRM, '', { okButton: 'Yes' });
|
||||
|
||||
|
@ -81,6 +81,7 @@ const sources = {
|
||||
huggingface: 'huggingface',
|
||||
nanogpt: 'nanogpt',
|
||||
bfl: 'bfl',
|
||||
falai: 'falai',
|
||||
};
|
||||
|
||||
const initiators = {
|
||||
@ -1169,6 +1170,10 @@ async function onBflKeyClick() {
|
||||
return onApiKeyClick('BFL API Key:', SECRET_KEYS.BFL);
|
||||
}
|
||||
|
||||
async function onFalaiKeyClick() {
|
||||
return onApiKeyClick('FALAI API Key:', SECRET_KEYS.FALAI);
|
||||
}
|
||||
|
||||
function onBflUpsamplingInput() {
|
||||
extension_settings.sd.bfl_upsampling = !!$('#sd_bfl_upsampling').prop('checked');
|
||||
saveSettingsDebounced();
|
||||
@ -1299,6 +1304,7 @@ async function onModelChange() {
|
||||
sources.huggingface,
|
||||
sources.nanogpt,
|
||||
sources.bfl,
|
||||
sources.falai,
|
||||
];
|
||||
|
||||
if (cloudSources.includes(extension_settings.sd.source)) {
|
||||
@ -1707,6 +1713,9 @@ async function loadModels() {
|
||||
case sources.bfl:
|
||||
models = await loadBflModels();
|
||||
break;
|
||||
case sources.falai:
|
||||
models = await loadFalaiModels();
|
||||
break;
|
||||
}
|
||||
|
||||
for (const model of models) {
|
||||
@ -1744,6 +1753,21 @@ async function loadBflModels() {
|
||||
];
|
||||
}
|
||||
|
||||
async function loadFalaiModels() {
|
||||
$('#sd_falai_key').toggleClass('success', !!secret_state[SECRET_KEYS.FALAI]);
|
||||
|
||||
const result = await fetch('/api/sd/falai/models', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
});
|
||||
|
||||
if (result.ok) {
|
||||
return await result.json();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
async function loadPollinationsModels() {
|
||||
const result = await fetch('/api/sd/pollinations/models', {
|
||||
method: 'POST',
|
||||
@ -2081,6 +2105,9 @@ async function loadSchedulers() {
|
||||
case sources.bfl:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
case sources.falai:
|
||||
schedulers = ['N/A'];
|
||||
break;
|
||||
}
|
||||
|
||||
for (const scheduler of schedulers) {
|
||||
@ -2735,6 +2762,9 @@ async function sendGenerationRequest(generationType, prompt, additionalNegativeP
|
||||
case sources.bfl:
|
||||
result = await generateBflImage(prefixedPrompt, signal);
|
||||
break;
|
||||
case sources.falai:
|
||||
result = await generateFalaiImage(prefixedPrompt, negativePrompt, signal);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!result.data) {
|
||||
@ -3496,6 +3526,40 @@ async function generateBflImage(prompt, signal) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an image using the FAL.AI API.
|
||||
* @param {string} prompt - The main instruction used to guide the image generation.
|
||||
* @param {string} negativePrompt - The negative prompt used to guide the image generation.
|
||||
* @param {AbortSignal} signal - An AbortSignal object that can be used to cancel the request.
|
||||
* @returns {Promise<{format: string, data: string}>} - A promise that resolves when the image generation and processing are complete.
|
||||
*/
|
||||
async function generateFalaiImage(prompt, negativePrompt, signal) {
|
||||
const result = await fetch('/api/sd/falai/generate', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
signal: signal,
|
||||
body: JSON.stringify({
|
||||
prompt: prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
model: extension_settings.sd.model,
|
||||
steps: clamp(extension_settings.sd.steps, 1, 50),
|
||||
guidance: clamp(extension_settings.sd.scale, 1.5, 5),
|
||||
width: clamp(extension_settings.sd.width, 256, 1440),
|
||||
height: clamp(extension_settings.sd.height, 256, 1440),
|
||||
seed: extension_settings.sd.seed >= 0 ? extension_settings.sd.seed : undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
if (result.ok) {
|
||||
const data = await result.json();
|
||||
return { format: 'jpg', data: data.image };
|
||||
} else {
|
||||
const text = await result.text();
|
||||
console.log(text);
|
||||
throw new Error(text);
|
||||
}
|
||||
}
|
||||
|
||||
async function onComfyOpenWorkflowEditorClick() {
|
||||
let workflow = await (await fetch('/api/sd/comfy/workflow', {
|
||||
method: 'POST',
|
||||
@ -3782,6 +3846,8 @@ function isValidState() {
|
||||
return secret_state[SECRET_KEYS.NANOGPT];
|
||||
case sources.bfl:
|
||||
return secret_state[SECRET_KEYS.BFL];
|
||||
case sources.falai:
|
||||
return secret_state[SECRET_KEYS.FALAI];
|
||||
}
|
||||
}
|
||||
|
||||
@ -4443,6 +4509,7 @@ jQuery(async () => {
|
||||
$('#sd_function_tool').on('input', onFunctionToolInput);
|
||||
$('#sd_bfl_key').on('click', onBflKeyClick);
|
||||
$('#sd_bfl_upsampling').on('input', onBflUpsamplingInput);
|
||||
$('#sd_falai_key').on('click', onFalaiKeyClick);
|
||||
|
||||
if (!CSS.supports('field-sizing', 'content')) {
|
||||
$('.sd_settings .inline-drawer-toggle').on('click', function () {
|
||||
|
@ -41,7 +41,8 @@
|
||||
<option value="blockentropy">Block Entropy</option>
|
||||
<option value="comfy">ComfyUI</option>
|
||||
<option value="drawthings">DrawThings HTTP API</option>
|
||||
<option value="extras">Extras API (local / remote)</option>
|
||||
<option value="extras">Extras API (deprecated)</option>
|
||||
<option value="falai">FAL.AI</option>
|
||||
<option value="huggingface">HuggingFace Inference API (serverless)</option>
|
||||
<option value="nanogpt">NanoGPT</option>
|
||||
<option value="novel">NovelAI Diffusion</option>
|
||||
@ -256,6 +257,20 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div data-sd-source="falai">
|
||||
<div class="flex-container flexnowrap alignItemsBaseline marginBot5">
|
||||
<a href="https://fal.ai/dashboard" target="_blank" rel="noopener noreferrer">
|
||||
<strong data-i18n="API Key">API Key</strong>
|
||||
<i class="fa-solid fa-share-from-square"></i>
|
||||
</a>
|
||||
<span class="expander"></span>
|
||||
<div id="sd_falai_key" class="menu_button menu_button_icon">
|
||||
<i class="fa-fw fa-solid fa-key"></i>
|
||||
<span data-i18n="Click to set">Click to set</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-container">
|
||||
<div class="flex1">
|
||||
<label for="sd_model" data-i18n="Model">Model</label>
|
||||
|
@ -31,6 +31,7 @@ import { KokoroTtsProvider } from './kokoro.js';
|
||||
export { talkingAnimation };
|
||||
|
||||
const UPDATE_INTERVAL = 1000;
|
||||
const wrapper = new ModuleWorkerWrapper(moduleWorker);
|
||||
|
||||
let voiceMapEntries = [];
|
||||
let voiceMap = {}; // {charName:voiceid, charName2:voiceid2}
|
||||
@ -122,7 +123,7 @@ async function onNarrateOneMessage() {
|
||||
}
|
||||
|
||||
resetTtsPlayback();
|
||||
ttsJobQueue.push(message);
|
||||
processAndQueueTtsMessage(message);
|
||||
moduleWorker();
|
||||
}
|
||||
|
||||
@ -149,7 +150,7 @@ async function onNarrateText(args, text) {
|
||||
}
|
||||
|
||||
resetTtsPlayback();
|
||||
ttsJobQueue.push({ mes: text, name: name });
|
||||
processAndQueueTtsMessage({ mes: text, name: name });
|
||||
await moduleWorker();
|
||||
|
||||
// Return back to the chat voices
|
||||
@ -222,6 +223,36 @@ function isTtsProcessing() {
|
||||
return processing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a message into lines and adds each non-empty line to the TTS job queue.
|
||||
* @param {Object} message - The message object to be processed.
|
||||
* @param {string} message.mes - The text of the message to be split into lines.
|
||||
* @param {string} message.name - The name associated with the message.
|
||||
* @returns {void}
|
||||
*/
|
||||
function processAndQueueTtsMessage(message) {
|
||||
if (!extension_settings.tts.narrate_by_paragraphs) {
|
||||
ttsJobQueue.push(message);
|
||||
return;
|
||||
}
|
||||
|
||||
const lines = message.mes.split('\n');
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
|
||||
if (line.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ttsJobQueue.push(
|
||||
Object.assign({}, message, {
|
||||
mes: line,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function debugTtsPlayback() {
|
||||
console.log(JSON.stringify(
|
||||
{
|
||||
@ -352,7 +383,7 @@ function onAudioControlClicked() {
|
||||
talkingAnimation(false);
|
||||
} else {
|
||||
// Default play behavior if not processing or playing is to play the last message.
|
||||
ttsJobQueue.push(context.chat[context.chat.length - 1]);
|
||||
processAndQueueTtsMessage(context.chat[context.chat.length - 1]);
|
||||
}
|
||||
updateUiAudioPlayState();
|
||||
}
|
||||
@ -378,6 +409,7 @@ function completeCurrentAudioJob() {
|
||||
currentAudioJob = null;
|
||||
talkingAnimation(false); //stop lip animation
|
||||
// updateUiPlayState();
|
||||
wrapper.update();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -468,7 +500,7 @@ async function processTtsQueue() {
|
||||
}
|
||||
|
||||
if (extension_settings.tts.skip_tags) {
|
||||
text = text.replace(/<.*?>.*?<\/.*?>/g, '').trim();
|
||||
text = text.replace(/<.*?>[\s\S]*?<\/.*?>/g, '').trim();
|
||||
}
|
||||
|
||||
if (!extension_settings.tts.pass_asterisks) {
|
||||
@ -571,6 +603,7 @@ function loadSettings() {
|
||||
$('#tts_narrate_quoted').prop('checked', extension_settings.tts.narrate_quoted_only);
|
||||
$('#tts_auto_generation').prop('checked', extension_settings.tts.auto_generation);
|
||||
$('#tts_periodic_auto_generation').prop('checked', extension_settings.tts.periodic_auto_generation);
|
||||
$('#tts_narrate_by_paragraphs').prop('checked', extension_settings.tts.narrate_by_paragraphs);
|
||||
$('#tts_narrate_translated_only').prop('checked', extension_settings.tts.narrate_translated_only);
|
||||
$('#tts_narrate_user').prop('checked', extension_settings.tts.narrate_user);
|
||||
$('#tts_pass_asterisks').prop('checked', extension_settings.tts.pass_asterisks);
|
||||
@ -640,6 +673,11 @@ function onPeriodicAutoGenerationClick() {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function onNarrateByParagraphsClick() {
|
||||
extension_settings.tts.narrate_by_paragraphs = !!$('#tts_narrate_by_paragraphs').prop('checked');
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
|
||||
function onNarrateDialoguesClick() {
|
||||
extension_settings.tts.narrate_dialogues_only = !!$('#tts_narrate_dialogues').prop('checked');
|
||||
@ -818,7 +856,12 @@ async function onMessageEvent(messageId, lastCharIndex) {
|
||||
lastChatId = context.chatId;
|
||||
|
||||
console.debug(`Adding message from ${message.name} for TTS processing: "${message.mes}"`);
|
||||
ttsJobQueue.push(message);
|
||||
|
||||
if (extension_settings.tts.periodic_auto_generation) {
|
||||
ttsJobQueue.push(message);
|
||||
} else {
|
||||
processAndQueueTtsMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
async function onMessageDeleted() {
|
||||
@ -1158,6 +1201,7 @@ jQuery(async function () {
|
||||
$('#tts_pass_asterisks').on('click', onPassAsterisksClick);
|
||||
$('#tts_auto_generation').on('click', onAutoGenerationClick);
|
||||
$('#tts_periodic_auto_generation').on('click', onPeriodicAutoGenerationClick);
|
||||
$('#tts_narrate_by_paragraphs').on('click', onNarrateByParagraphsClick);
|
||||
$('#tts_narrate_user').on('click', onNarrateUserClick);
|
||||
|
||||
$('#playback_rate').on('input', function () {
|
||||
@ -1179,7 +1223,6 @@ jQuery(async function () {
|
||||
loadSettings(); // Depends on Extension Controls and loadTtsProvider
|
||||
loadTtsProvider(extension_settings.tts.currentProvider); // No dependencies
|
||||
addAudioControl(); // Depends on Extension Controls
|
||||
const wrapper = new ModuleWorkerWrapper(moduleWorker);
|
||||
setInterval(wrapper.update.bind(wrapper), UPDATE_INTERVAL); // Init depends on all the things
|
||||
eventSource.on(event_types.MESSAGE_SWIPED, resetTtsPlayback);
|
||||
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
|
||||
|
@ -30,6 +30,10 @@
|
||||
<input type="checkbox" id="tts_periodic_auto_generation">
|
||||
<small data-i18n="Narrate by paragraphs (when streaming)">Narrate by paragraphs (when streaming)</small>
|
||||
</label>
|
||||
<label class="checkbox_label" for="tts_narrate_by_paragraphs">
|
||||
<input type="checkbox" id="tts_narrate_by_paragraphs">
|
||||
<small data-i18n="Narrate by paragraphs (when not streaming)">Narrate by paragraphs (when not streaming)</small>
|
||||
</label>
|
||||
<label class="checkbox_label" for="tts_narrate_quoted">
|
||||
<input type="checkbox" id="tts_narrate_quoted">
|
||||
<small data-i18n="Only narrate quotes">Only narrate "quotes"</small>
|
||||
|
@ -1621,14 +1621,14 @@ jQuery(async () => {
|
||||
const attachments = source ? getDataBankAttachmentsForSource(source, false) : getDataBankAttachments(false);
|
||||
const collectionIds = await ingestDataBankAttachments(String(source));
|
||||
const queryResults = await queryMultipleCollections(collectionIds, String(query), count, threshold);
|
||||
|
||||
|
||||
// Get URLs
|
||||
const urls = Object
|
||||
.keys(queryResults)
|
||||
.map(x => attachments.find(y => getFileCollectionId(y.url) === x))
|
||||
.filter(x => x)
|
||||
.map(x => x.url);
|
||||
|
||||
|
||||
// Gets the actual text content of chunks
|
||||
const getChunksText = () => {
|
||||
let textResult = '';
|
||||
@ -1638,14 +1638,12 @@ jQuery(async () => {
|
||||
}
|
||||
return textResult;
|
||||
};
|
||||
|
||||
if (args.return === 'chunks') {
|
||||
return getChunksText();
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return slashCommandReturnHelper.doReturn(args.return ?? 'object', urls, { objectToStringFunc: list => list.join('\n') });
|
||||
|
||||
},
|
||||
aliases: ['databank-search', 'data-bank-search'],
|
||||
helpString: 'Search the Data Bank for a specific query using vector similarity. Returns a list of file URLs with the most relevant content.',
|
||||
@ -1660,10 +1658,10 @@ jQuery(async () => {
|
||||
defaultValue: 'object',
|
||||
enumList: [
|
||||
new SlashCommandEnumValue('chunks', 'Return the actual content chunks', enumTypes.enum, '{}'),
|
||||
...slashCommandReturnHelper.enumList({ allowObject: true })
|
||||
...slashCommandReturnHelper.enumList({ allowObject: true }),
|
||||
],
|
||||
forceEnum: true,
|
||||
})
|
||||
}),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument('Query to search by.', ARGUMENT_TYPE.STRING, true, false),
|
||||
|
@ -11,7 +11,7 @@
|
||||
</label>
|
||||
<select id="vectors_source" class="text_pole">
|
||||
<option value="cohere">Cohere</option>
|
||||
<option value="extras">Extras</option>
|
||||
<option value="extras">Extras (deprecated)</option>
|
||||
<option value="palm">Google AI Studio</option>
|
||||
<option value="llamacpp">llama.cpp</option>
|
||||
<option value="transformers" data-i18n="Local (Transformers)">Local (Transformers)</option>
|
||||
|
@ -1,18 +1,30 @@
|
||||
////////////////// LOCAL STORAGE HANDLING /////////////////////
|
||||
|
||||
/**
|
||||
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
|
||||
*/
|
||||
export function SaveLocal(target, val) {
|
||||
localStorage.setItem(target, val);
|
||||
console.debug('SaveLocal -- ' + target + ' : ' + val);
|
||||
}
|
||||
/**
|
||||
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
|
||||
*/
|
||||
export function LoadLocal(target) {
|
||||
console.debug('LoadLocal -- ' + target);
|
||||
return localStorage.getItem(target);
|
||||
|
||||
}
|
||||
/**
|
||||
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
|
||||
*/
|
||||
export function LoadLocalBool(target) {
|
||||
let result = localStorage.getItem(target) === 'true';
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
|
||||
*/
|
||||
export function CheckLocal() {
|
||||
console.log('----------local storage---------');
|
||||
var i;
|
||||
@ -22,6 +34,9 @@ export function CheckLocal() {
|
||||
console.log('------------------------------');
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated THIS FUNCTION IS OBSOLETE. DO NOT USE
|
||||
*/
|
||||
export function ClearLocal() { localStorage.clear(); console.log('Removed All Local Storage'); }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,9 +78,11 @@ import { FILTER_TYPES, FilterHelper } from './filters.js';
|
||||
import { isExternalMediaAllowed } from './chats.js';
|
||||
import { POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
export {
|
||||
selected_group,
|
||||
openGroupId,
|
||||
is_group_automode_enabled,
|
||||
hideMutedSprites,
|
||||
is_group_generating,
|
||||
@ -291,10 +293,11 @@ export function getGroupNames() {
|
||||
|
||||
/**
|
||||
* Finds the character ID for a group member.
|
||||
* @param {string} arg 0-based member index or character name
|
||||
* @returns {number} 0-based character ID
|
||||
* @param {number|string} arg 0-based member index or character name
|
||||
* @param {Boolean} full Whether to return a key-value object containing extra data
|
||||
* @returns {number|Object} 0-based character ID or key-value object if full is true
|
||||
*/
|
||||
export function findGroupMemberId(arg) {
|
||||
export function findGroupMemberId(arg, full = false) {
|
||||
arg = arg?.trim();
|
||||
|
||||
if (!arg) {
|
||||
@ -310,15 +313,19 @@ export function findGroupMemberId(arg) {
|
||||
}
|
||||
|
||||
const index = parseInt(arg);
|
||||
const searchByName = isNaN(index);
|
||||
const searchByString = isNaN(index);
|
||||
|
||||
if (searchByName) {
|
||||
const memberNames = group.members.map(x => ({ name: characters.find(y => y.avatar === x)?.name, index: characters.findIndex(y => y.avatar === x) }));
|
||||
const fuse = new Fuse(memberNames, { keys: ['name'] });
|
||||
if (searchByString) {
|
||||
const memberNames = group.members.map(x => ({
|
||||
avatar: x,
|
||||
name: characters.find(y => y.avatar === x)?.name,
|
||||
index: characters.findIndex(y => y.avatar === x),
|
||||
}));
|
||||
const fuse = new Fuse(memberNames, { keys: ['avatar', 'name'] });
|
||||
const result = fuse.search(arg);
|
||||
|
||||
if (!result.length) {
|
||||
console.warn(`WARN: No group member found with name ${arg}`);
|
||||
console.warn(`WARN: No group member found using string ${arg}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -329,9 +336,11 @@ export function findGroupMemberId(arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Triggering group member ${chid} (${arg}) from search result`, result[0]);
|
||||
return chid;
|
||||
} else {
|
||||
console.log(`Targeting group member ${chid} (${arg}) from search result`, result[0]);
|
||||
|
||||
return !full ? chid : { ...{ id: chid }, ...result[0].item };
|
||||
}
|
||||
else {
|
||||
const memberAvatar = group.members[index];
|
||||
|
||||
if (memberAvatar === undefined) {
|
||||
@ -346,8 +355,14 @@ export function findGroupMemberId(arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Triggering group member ${memberAvatar} at index ${index}`);
|
||||
return chid;
|
||||
console.log(`Targeting group member ${memberAvatar} at index ${index}`);
|
||||
|
||||
return !full ? chid : {
|
||||
id: chid,
|
||||
avatar: memberAvatar,
|
||||
name: characters.find(y => y.avatar === memberAvatar)?.name,
|
||||
index: index,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -804,7 +819,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||
|
||||
/** @type {any} Caution: JS war crimes ahead */
|
||||
let textResult = '';
|
||||
let typingIndicator = $('#chat .typing_indicator');
|
||||
const group = groups.find((x) => x.id === selected_group);
|
||||
|
||||
if (!group || !Array.isArray(group.members) || !group.members.length) {
|
||||
@ -820,14 +834,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||
setCharacterId(undefined);
|
||||
const userInput = String($('#send_textarea').val());
|
||||
|
||||
if (typingIndicator.length === 0 && !isStreamingEnabled()) {
|
||||
typingIndicator = $(
|
||||
'#typing_indicator_template .typing_indicator',
|
||||
).clone();
|
||||
typingIndicator.hide();
|
||||
$('#chat').append(typingIndicator);
|
||||
}
|
||||
|
||||
// id of this specific batch for regeneration purposes
|
||||
group_generation_id = Date.now();
|
||||
const lastMessage = chat[chat.length - 1];
|
||||
@ -905,14 +911,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||
}
|
||||
await eventSource.emit(event_types.GROUP_MEMBER_DRAFTED, chId);
|
||||
|
||||
if (type !== 'swipe' && type !== 'impersonate' && !isStreamingEnabled()) {
|
||||
// update indicator and scroll down
|
||||
typingIndicator
|
||||
.find('.typing_indicator_name')
|
||||
.text(characters[chId].name);
|
||||
typingIndicator.show();
|
||||
}
|
||||
|
||||
// Wait for generation to finish
|
||||
textResult = await Generate(generateType, { automatic_trigger: by_auto_mode, ...(params || {}) });
|
||||
let messageChunk = textResult?.messageChunk;
|
||||
@ -929,8 +927,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
typingIndicator.hide();
|
||||
|
||||
is_group_generating = false;
|
||||
setSendButtonState(false);
|
||||
setCharacterId(undefined);
|
||||
@ -1314,10 +1310,10 @@ function printGroupCandidates() {
|
||||
formatNavigator: PAGINATION_TEMPLATE,
|
||||
showNavigator: true,
|
||||
showSizeChanger: true,
|
||||
pageSize: Number(localStorage.getItem(storageKey)) || 5,
|
||||
pageSize: Number(accountStorage.getItem(storageKey)) || 5,
|
||||
sizeChangerOptions: [5, 10, 25, 50, 100, 200, 500, 1000],
|
||||
afterSizeSelectorChange: function (e) {
|
||||
localStorage.setItem(storageKey, e.target.value);
|
||||
accountStorage.setItem(storageKey, e.target.value);
|
||||
},
|
||||
callback: function (data) {
|
||||
$('#rm_group_add_members').empty();
|
||||
@ -1341,10 +1337,10 @@ function printGroupMembers() {
|
||||
formatNavigator: PAGINATION_TEMPLATE,
|
||||
showNavigator: true,
|
||||
showSizeChanger: true,
|
||||
pageSize: Number(localStorage.getItem(storageKey)) || 5,
|
||||
pageSize: Number(accountStorage.getItem(storageKey)) || 5,
|
||||
sizeChangerOptions: [5, 10, 25, 50, 100, 200, 500, 1000],
|
||||
afterSizeSelectorChange: function (e) {
|
||||
localStorage.setItem(storageKey, e.target.value);
|
||||
accountStorage.setItem(storageKey, e.target.value);
|
||||
},
|
||||
callback: function (data) {
|
||||
$('.rm_group_members').empty();
|
||||
@ -1367,6 +1363,15 @@ function getGroupCharacterBlock(character) {
|
||||
template.find('.ch_fav').val(isFav);
|
||||
template.toggleClass('is_fav', isFav);
|
||||
|
||||
const auxFieldName = power_user.aux_field || 'character_version';
|
||||
const auxFieldValue = (character.data && character.data[auxFieldName]) || '';
|
||||
if (auxFieldValue) {
|
||||
template.find('.character_version').text(auxFieldValue);
|
||||
}
|
||||
else {
|
||||
template.find('.character_version').hide();
|
||||
}
|
||||
|
||||
let queuePosition = groupChatQueueOrder.get(character.avatar);
|
||||
if (queuePosition) {
|
||||
template.find('.queue_position').text(queuePosition);
|
||||
|
@ -188,7 +188,7 @@ export async function generateKoboldWithStreaming(generate_data, signal) {
|
||||
if (data?.token) {
|
||||
text += data.token;
|
||||
}
|
||||
yield { text, swipes: [], toolCalls: [] };
|
||||
yield { text, swipes: [], toolCalls: [], state: {} };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -27,24 +27,45 @@ export async function hideLoader() {
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
// Spinner blurs/fades out
|
||||
$('#load-spinner').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function () {
|
||||
const spinner = $('#load-spinner');
|
||||
if (!spinner.length) {
|
||||
console.warn('Spinner element not found, skipping animation');
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if transitions are enabled
|
||||
const transitionDuration = spinner[0] ? getComputedStyle(spinner[0]).transitionDuration : '0s';
|
||||
const hasTransitions = parseFloat(transitionDuration) > 0;
|
||||
|
||||
if (hasTransitions) {
|
||||
Promise.race([
|
||||
new Promise((r) => setTimeout(r, 500)), // Fallback timeout
|
||||
new Promise((r) => spinner.one('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', r)),
|
||||
]).finally(cleanup);
|
||||
} else {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
$('#loader').remove();
|
||||
// Yoink preloader entirely; it only exists to cover up unstyled content while loading JS
|
||||
// If it's present, we remove it once and then it's gone.
|
||||
yoinkPreloader();
|
||||
|
||||
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE).then(() => {
|
||||
loaderPopup = null;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
loaderPopup.complete(POPUP_RESULT.AFFIRMATIVE)
|
||||
.catch((err) => console.error('Error completing loaderPopup:', err))
|
||||
.finally(() => {
|
||||
loaderPopup = null;
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
$('#load-spinner')
|
||||
.css({
|
||||
'filter': 'blur(15px)',
|
||||
'opacity': '0',
|
||||
});
|
||||
// Apply the styles
|
||||
spinner.css({
|
||||
'filter': 'blur(15px)',
|
||||
'opacity': '0',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,7 @@ export async function generateNovelWithStreaming(generate_data, signal) {
|
||||
text += data.token;
|
||||
}
|
||||
|
||||
yield { text, swipes: [], logprobs: parseNovelAILogprobs(data.logprobs), toolCalls: [] };
|
||||
yield { text, swipes: [], logprobs: parseNovelAILogprobs(data.logprobs), toolCalls: [], state: {} };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js
|
||||
import { Popup, POPUP_RESULT } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { ToolManager } from './tool-calling.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
export {
|
||||
openai_messages_count,
|
||||
@ -82,7 +83,6 @@ export {
|
||||
setOpenAIMessageExamples,
|
||||
setupChatCompletionPromptManager,
|
||||
sendOpenAIRequest,
|
||||
getChatCompletionModel,
|
||||
TokenHandler,
|
||||
IdentifierNotFoundError,
|
||||
Message,
|
||||
@ -258,8 +258,8 @@ const default_settings = {
|
||||
ai21_model: 'jamba-1.5-large',
|
||||
mistralai_model: 'mistral-large-latest',
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'llama-3.1-70b-instruct',
|
||||
groq_model: 'llama-3.1-70b-versatile',
|
||||
perplexity_model: 'sonar-pro',
|
||||
groq_model: 'llama-3.3-70b-versatile',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
zerooneai_model: 'yi-large',
|
||||
blockentropy_model: 'be-70b-base-llama3.1',
|
||||
@ -298,7 +298,8 @@ const default_settings = {
|
||||
names_behavior: character_names_behavior.DEFAULT,
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: false,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@ -337,7 +338,7 @@ const oai_settings = {
|
||||
ai21_model: 'jamba-1.5-large',
|
||||
mistralai_model: 'mistral-large-latest',
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'llama-3.1-70b-instruct',
|
||||
perplexity_model: 'sonar-pro',
|
||||
groq_model: 'llama-3.1-70b-versatile',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
zerooneai_model: 'yi-large',
|
||||
@ -377,7 +378,8 @@ const oai_settings = {
|
||||
names_behavior: character_names_behavior.DEFAULT,
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
show_thoughts: false,
|
||||
show_thoughts: true,
|
||||
reasoning_effort: 'medium',
|
||||
seed: -1,
|
||||
n: 1,
|
||||
};
|
||||
@ -412,7 +414,7 @@ async function validateReverseProxy() {
|
||||
throw err;
|
||||
}
|
||||
const rememberKey = `Proxy_SkipConfirm_${getStringHash(oai_settings.reverse_proxy)}`;
|
||||
const skipConfirm = localStorage.getItem(rememberKey) === 'true';
|
||||
const skipConfirm = accountStorage.getItem(rememberKey) === 'true';
|
||||
|
||||
const confirmation = skipConfirm || await Popup.show.confirm(t`Connecting To Proxy`, await renderTemplateAsync('proxyConnectionWarning', { proxyURL: DOMPurify.sanitize(oai_settings.reverse_proxy) }));
|
||||
|
||||
@ -423,7 +425,7 @@ async function validateReverseProxy() {
|
||||
throw new Error('Proxy connection denied.');
|
||||
}
|
||||
|
||||
localStorage.setItem(rememberKey, String(true));
|
||||
accountStorage.setItem(rememberKey, String(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1096,8 +1098,8 @@ async function preparePromptsForChatCompletion({ Scenario, charPersonality, name
|
||||
// Unordered prompts without marker
|
||||
{ role: 'system', content: impersonationPrompt, identifier: 'impersonate' },
|
||||
{ role: 'system', content: quietPrompt, identifier: 'quietPrompt' },
|
||||
{ role: 'system', content: bias, identifier: 'bias' },
|
||||
{ role: 'system', content: groupNudge, identifier: 'groupNudge' },
|
||||
{ role: 'assistant', content: bias, identifier: 'bias' },
|
||||
];
|
||||
|
||||
// Tavern Extras - Summary
|
||||
@ -1443,9 +1445,7 @@ async function sendWindowAIRequest(messages, signal, stream) {
|
||||
}
|
||||
|
||||
const onStreamResult = (res, err) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
if (err) return;
|
||||
|
||||
const thisContent = res?.message?.content;
|
||||
|
||||
@ -1497,7 +1497,7 @@ async function sendWindowAIRequest(messages, signal, stream) {
|
||||
}
|
||||
}
|
||||
|
||||
function getChatCompletionModel() {
|
||||
export function getChatCompletionModel() {
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
case chat_completion_sources.CLAUDE:
|
||||
return oai_settings.claude_model;
|
||||
@ -1869,7 +1869,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
const isQuiet = type === 'quiet';
|
||||
const isImpersonate = type === 'impersonate';
|
||||
const isContinue = type === 'continue';
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !isScale && !(isGoogle && oai_settings.google_model.includes('bison')) && !(isOAI && oai_settings.openai_model.startsWith('o1-'));
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !isScale && !(isOAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model));
|
||||
const useLogprobs = !!power_user.request_token_probabilities;
|
||||
const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom);
|
||||
|
||||
@ -1913,16 +1913,21 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
'user_name': name1,
|
||||
'char_name': name2,
|
||||
'group_names': getGroupNames(),
|
||||
'show_thoughts': Boolean(oai_settings.show_thoughts),
|
||||
'include_reasoning': Boolean(oai_settings.show_thoughts),
|
||||
'reasoning_effort': String(oai_settings.reasoning_effort),
|
||||
};
|
||||
|
||||
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
||||
await ToolManager.registerFunctionToolsOpenAI(generate_data);
|
||||
}
|
||||
|
||||
// Empty array will produce a validation error
|
||||
if (!Array.isArray(generate_data.stop) || !generate_data.stop.length) {
|
||||
delete generate_data.stop;
|
||||
}
|
||||
|
||||
// Proxy is only supported for Claude, OpenAI, Mistral, and Google MakerSuite
|
||||
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI, chat_completion_sources.MAKERSUITE].includes(oai_settings.chat_completion_source)) {
|
||||
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI, chat_completion_sources.MAKERSUITE, chat_completion_sources.DEEPSEEK].includes(oai_settings.chat_completion_source)) {
|
||||
await validateReverseProxy();
|
||||
generate_data['reverse_proxy'] = oai_settings.reverse_proxy;
|
||||
generate_data['proxy_password'] = oai_settings.proxy_password;
|
||||
@ -2030,17 +2035,25 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
// 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;
|
||||
delete generate_data.tools;
|
||||
delete generate_data.tool_choice;
|
||||
}
|
||||
}
|
||||
|
||||
if ((isOAI || isOpenRouter || isMistral || isCustom || isCohere || isNano) && oai_settings.seed >= 0) {
|
||||
generate_data['seed'] = oai_settings.seed;
|
||||
}
|
||||
|
||||
if (!canMultiSwipe && ToolManager.canPerformToolCalls(type)) {
|
||||
await ToolManager.registerFunctionToolsOpenAI(generate_data);
|
||||
}
|
||||
|
||||
if (isOAI && oai_settings.openai_model.startsWith('o1-')) {
|
||||
if (isOAI && (oai_settings.openai_model.startsWith('o1') || oai_settings.openai_model.startsWith('o3'))) {
|
||||
generate_data.messages.forEach((msg) => {
|
||||
if (msg.role === 'system') {
|
||||
msg.role = 'user';
|
||||
@ -2048,7 +2061,6 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
});
|
||||
generate_data.max_completion_tokens = generate_data.max_tokens;
|
||||
delete generate_data.max_tokens;
|
||||
delete generate_data.stream;
|
||||
delete generate_data.logprobs;
|
||||
delete generate_data.top_logprobs;
|
||||
delete generate_data.n;
|
||||
@ -2059,8 +2071,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
delete generate_data.tools;
|
||||
delete generate_data.tool_choice;
|
||||
delete generate_data.stop;
|
||||
// It does support logit_bias, but the tokenizer used and its effect is yet unknown.
|
||||
// delete generate_data.logit_bias;
|
||||
delete generate_data.logit_bias;
|
||||
}
|
||||
|
||||
await eventSource.emit(event_types.CHAT_COMPLETION_SETTINGS_READY, generate_data);
|
||||
@ -2085,6 +2096,7 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
let text = '';
|
||||
const swipes = [];
|
||||
const toolCalls = [];
|
||||
const state = { reasoning: '' };
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) return;
|
||||
@ -2095,14 +2107,14 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
|
||||
if (Array.isArray(parsed?.choices) && parsed?.choices?.[0]?.index > 0) {
|
||||
const swipeIndex = parsed.choices[0].index - 1;
|
||||
swipes[swipeIndex] = (swipes[swipeIndex] || '') + getStreamingReply(parsed);
|
||||
swipes[swipeIndex] = (swipes[swipeIndex] || '') + getStreamingReply(parsed, state);
|
||||
} else {
|
||||
text += getStreamingReply(parsed);
|
||||
text += getStreamingReply(parsed, state);
|
||||
}
|
||||
|
||||
ToolManager.parseToolCalls(toolCalls, parsed);
|
||||
|
||||
yield { text, swipes: swipes, logprobs: parseChatCompletionLogprobs(parsed), toolCalls: toolCalls };
|
||||
yield { text, swipes: swipes, logprobs: parseChatCompletionLogprobs(parsed), toolCalls: toolCalls, state: state };
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -2129,13 +2141,32 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||
}
|
||||
}
|
||||
|
||||
function getStreamingReply(data) {
|
||||
/**
|
||||
* Extracts the reply from the response data from a chat completions-like source
|
||||
* @param {object} data Response data from the chat completions-like source
|
||||
* @param {object} state Additional state to keep track of
|
||||
* @returns {string} The reply extracted from the response data
|
||||
*/
|
||||
function getStreamingReply(data, state) {
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.CLAUDE) {
|
||||
return data?.delta?.text || '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.MAKERSUITE) {
|
||||
return data?.candidates?.[0]?.content?.parts?.filter(x => oai_settings.show_thoughts || !x.thought)?.map(x => x.text)?.filter(x => x)?.join('\n\n') || '';
|
||||
if (oai_settings.show_thoughts) {
|
||||
state.reasoning += (data?.candidates?.[0]?.content?.parts?.filter(x => x.thought)?.map(x => x.text)?.[0] || '');
|
||||
}
|
||||
return data?.candidates?.[0]?.content?.parts?.filter(x => !x.thought)?.map(x => x.text)?.[0] || '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) {
|
||||
return data?.delta?.message?.content?.text || data?.delta?.message?.tool_plan || '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.DEEPSEEK) {
|
||||
if (oai_settings.show_thoughts) {
|
||||
state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content || '');
|
||||
}
|
||||
return data.choices?.[0]?.delta?.content || '';
|
||||
} else if (oai_settings.chat_completion_source === chat_completion_sources.OPENROUTER) {
|
||||
if (oai_settings.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 {
|
||||
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
|
||||
}
|
||||
@ -3094,6 +3125,7 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.inline_image_quality = settings.inline_image_quality ?? default_settings.inline_image_quality;
|
||||
oai_settings.bypass_status_check = settings.bypass_status_check ?? default_settings.bypass_status_check;
|
||||
oai_settings.show_thoughts = settings.show_thoughts ?? default_settings.show_thoughts;
|
||||
oai_settings.reasoning_effort = settings.reasoning_effort ?? default_settings.reasoning_effort;
|
||||
oai_settings.seed = settings.seed ?? default_settings.seed;
|
||||
oai_settings.n = settings.n ?? default_settings.n;
|
||||
|
||||
@ -3223,6 +3255,9 @@ function loadOpenAISettings(data, settings) {
|
||||
$('#n_openai').val(oai_settings.n);
|
||||
$('#openai_show_thoughts').prop('checked', oai_settings.show_thoughts);
|
||||
|
||||
$('#openai_reasoning_effort').val(oai_settings.reasoning_effort);
|
||||
$(`#openai_reasoning_effort option[value="${oai_settings.reasoning_effort}"]`).prop('selected', true);
|
||||
|
||||
if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy;
|
||||
$('#openai_reverse_proxy').val(oai_settings.reverse_proxy);
|
||||
|
||||
@ -3346,7 +3381,7 @@ async function getStatusOpen() {
|
||||
chat_completion_source: oai_settings.chat_completion_source,
|
||||
};
|
||||
|
||||
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI, chat_completion_sources.MAKERSUITE].includes(oai_settings.chat_completion_source)) {
|
||||
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI, chat_completion_sources.MAKERSUITE, chat_completion_sources.DEEPSEEK].includes(oai_settings.chat_completion_source)) {
|
||||
await validateReverseProxy();
|
||||
}
|
||||
|
||||
@ -3483,6 +3518,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
continue_postfix: settings.continue_postfix,
|
||||
function_calling: settings.function_calling,
|
||||
show_thoughts: settings.show_thoughts,
|
||||
reasoning_effort: settings.reasoning_effort,
|
||||
seed: settings.seed,
|
||||
n: settings.n,
|
||||
};
|
||||
@ -3941,6 +3977,7 @@ function onSettingsPresetChange() {
|
||||
continue_postfix: ['#continue_postfix', 'continue_postfix', false],
|
||||
function_calling: ['#openai_function_calling', 'function_calling', true],
|
||||
show_thoughts: ['#openai_show_thoughts', 'show_thoughts', true],
|
||||
reasoning_effort: ['#openai_reasoning_effort', 'reasoning_effort', false],
|
||||
seed: ['#seed_openai', 'seed', false],
|
||||
n: ['#n_openai', 'n', false],
|
||||
};
|
||||
@ -3997,7 +4034,7 @@ function getMaxContextOpenAI(value) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
return unlocked_max;
|
||||
}
|
||||
else if (value.startsWith('o1-')) {
|
||||
else if (value.startsWith('o1') || value.startsWith('o3')) {
|
||||
return max_128k;
|
||||
}
|
||||
else if (value.includes('chatgpt-4o-latest') || value.includes('gpt-4-turbo') || value.includes('gpt-4o') || value.includes('gpt-4-1106') || value.includes('gpt-4-0125') || value.includes('gpt-4-vision')) {
|
||||
@ -4202,9 +4239,9 @@ async function onModelChange() {
|
||||
$('#openai_max_context').attr('max', max_2mil);
|
||||
} else if (value.includes('gemini-exp-1114') || value.includes('gemini-exp-1121') || value.includes('gemini-2.0-flash-thinking-exp-1219')) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
} else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206')) {
|
||||
} else if (value.includes('gemini-1.5-pro') || value.includes('gemini-exp-1206') || value.includes('gemini-2.0-pro')) {
|
||||
$('#openai_max_context').attr('max', max_2mil);
|
||||
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash-exp')) {
|
||||
} else if (value.includes('gemini-1.5-flash') || value.includes('gemini-2.0-flash')) {
|
||||
$('#openai_max_context').attr('max', max_1mil);
|
||||
} else if (value.includes('gemini-1.0-pro') || value === 'gemini-pro') {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
@ -4350,28 +4387,19 @@ async function onModelChange() {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
}
|
||||
else if (['sonar', 'sonar-reasoning'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', 127000);
|
||||
}
|
||||
else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', 200000);
|
||||
}
|
||||
else if (oai_settings.perplexity_model.includes('llama-3.1')) {
|
||||
const isOnline = oai_settings.perplexity_model.includes('online');
|
||||
const contextSize = isOnline ? 128 * 1024 - 4000 : 128 * 1024;
|
||||
$('#openai_max_context').attr('max', contextSize);
|
||||
}
|
||||
else if (['llama-3-sonar-small-32k-chat', 'llama-3-sonar-large-32k-chat'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
}
|
||||
else if (['llama-3-sonar-small-32k-online', 'llama-3-sonar-large-32k-online'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', 28000);
|
||||
}
|
||||
else if (['sonar-small-chat', 'sonar-medium-chat', 'codellama-70b-instruct', 'mistral-7b-instruct', 'mixtral-8x7b-instruct', 'mixtral-8x22b-instruct'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', max_16k);
|
||||
}
|
||||
else if (['llama-3-8b-instruct', 'llama-3-70b-instruct'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
}
|
||||
else if (['sonar-small-online', 'sonar-medium-online'].includes(oai_settings.perplexity_model)) {
|
||||
$('#openai_max_context').attr('max', 12000);
|
||||
}
|
||||
else {
|
||||
$('#openai_max_context').attr('max', max_4k);
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
@ -4382,24 +4410,30 @@ async function onModelChange() {
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
}
|
||||
else if (oai_settings.groq_model.includes('llama-3.2') && oai_settings.groq_model.includes('-preview')) {
|
||||
} else if (oai_settings.groq_model.includes('gemma2-9b-it')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
}
|
||||
else if (oai_settings.groq_model.includes('llama-3.3') || oai_settings.groq_model.includes('llama-3.2') || oai_settings.groq_model.includes('llama-3.1')) {
|
||||
} else if (oai_settings.groq_model.includes('llama-3.3-70b-versatile')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
else if (oai_settings.groq_model.includes('llama3-groq')) {
|
||||
} else if (oai_settings.groq_model.includes('llama-3.1-8b-instant')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama3-70b-8192')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
}
|
||||
else if (['llama3-8b-8192', 'llama3-70b-8192', 'gemma-7b-it', 'gemma2-9b-it'].includes(oai_settings.groq_model)) {
|
||||
} else if (oai_settings.groq_model.includes('llama3-8b-8192')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
}
|
||||
else if (['mixtral-8x7b-32768'].includes(oai_settings.groq_model)) {
|
||||
} else if (oai_settings.groq_model.includes('mixtral-8x7b-32768')) {
|
||||
$('#openai_max_context').attr('max', max_32k);
|
||||
}
|
||||
else {
|
||||
$('#openai_max_context').attr('max', max_4k);
|
||||
} else if (oai_settings.groq_model.includes('deepseek-r1-distill-llama-70b')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.3-70b-specdec')) {
|
||||
$('#openai_max_context').attr('max', max_8k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-1b-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-3b-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-11b-vision-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
} else if (oai_settings.groq_model.includes('llama-3.2-90b-vision-preview')) {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
@ -4488,7 +4522,7 @@ async function onModelChange() {
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.DEEPSEEK) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else if (oai_settings.deepseek_model == 'deepseek-chat') {
|
||||
} else if (['deepseek-reasoner', 'deepseek-chat'].includes(oai_settings.deepseek_model)) {
|
||||
$('#openai_max_context').attr('max', max_64k);
|
||||
} else if (oai_settings.deepseek_model == 'deepseek-coder') {
|
||||
$('#openai_max_context').attr('max', max_16k);
|
||||
@ -4725,7 +4759,7 @@ async function onConnectButtonClick(e) {
|
||||
await writeSecret(SECRET_KEYS.DEEPSEEK, api_key_deepseek);
|
||||
}
|
||||
|
||||
if (!secret_state[SECRET_KEYS.DEEPSEEK]) {
|
||||
if (!secret_state[SECRET_KEYS.DEEPSEEK] && !oai_settings.reverse_proxy) {
|
||||
console.log('No secret key saved for DeepSeek');
|
||||
return;
|
||||
}
|
||||
@ -4900,7 +4934,15 @@ export function isImageInliningSupported() {
|
||||
// gultra just isn't being offered as multimodal, thanks google.
|
||||
const visionSupportedModels = [
|
||||
'gpt-4-vision',
|
||||
'gemini-2.0-pro-exp',
|
||||
'gemini-2.0-pro-exp-02-05',
|
||||
'gemini-2.0-flash-lite-preview',
|
||||
'gemini-2.0-flash-lite-preview-02-05',
|
||||
'gemini-2.0-flash',
|
||||
'gemini-2.0-flash-001',
|
||||
'gemini-2.0-flash-thinking-exp-1219',
|
||||
'gemini-2.0-flash-thinking-exp-01-21',
|
||||
'gemini-2.0-flash-thinking-exp',
|
||||
'gemini-2.0-flash-exp',
|
||||
'gemini-1.5-flash',
|
||||
'gemini-1.5-flash-latest',
|
||||
@ -4925,6 +4967,8 @@ export function isImageInliningSupported() {
|
||||
'gpt-4-turbo',
|
||||
'gpt-4o',
|
||||
'gpt-4o-mini',
|
||||
'o1',
|
||||
'o1-2024-12-17',
|
||||
'chatgpt-4o-latest',
|
||||
'yi-vision',
|
||||
'pixtral-latest',
|
||||
@ -5483,6 +5527,11 @@ export function initOpenAI() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#openai_reasoning_effort').on('input', function () {
|
||||
oai_settings.reasoning_effort = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
if (!CSS.supports('field-sizing', 'content')) {
|
||||
$(document).on('input', '#openai_settings .autoSetHeight', function () {
|
||||
resetScrollHeight($(this));
|
||||
|
@ -25,6 +25,7 @@ import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { openWorldInfoEditor, world_names } from './world-info.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
let savePersonasPage = 0;
|
||||
const GRID_STORAGE_KEY = 'Personas_GridView';
|
||||
@ -34,7 +35,7 @@ export let user_avatar = '';
|
||||
export const personasFilter = new FilterHelper(debounce(getUserAvatars, debounce_timeout.quick));
|
||||
|
||||
function switchPersonaGridView() {
|
||||
const state = localStorage.getItem(GRID_STORAGE_KEY) === 'true';
|
||||
const state = accountStorage.getItem(GRID_STORAGE_KEY) === 'true';
|
||||
$('#user_avatar_block').toggleClass('gridView', state);
|
||||
}
|
||||
|
||||
@ -182,7 +183,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
|
||||
|
||||
const storageKey = 'Personas_PerPage';
|
||||
const listId = '#user_avatar_block';
|
||||
const perPage = Number(localStorage.getItem(storageKey)) || 5;
|
||||
const perPage = Number(accountStorage.getItem(storageKey)) || 5;
|
||||
|
||||
$('#persona_pagination_container').pagination({
|
||||
dataSource: entities,
|
||||
@ -205,7 +206,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
|
||||
highlightSelectedAvatar();
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
localStorage.setItem(storageKey, e.target.value);
|
||||
accountStorage.setItem(storageKey, e.target.value);
|
||||
},
|
||||
afterPaging: function (e) {
|
||||
savePersonasPage = e;
|
||||
@ -1132,8 +1133,8 @@ export function initPersonas() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#persona_grid_toggle').on('click', () => {
|
||||
const state = localStorage.getItem(GRID_STORAGE_KEY) === 'true';
|
||||
localStorage.setItem(GRID_STORAGE_KEY, String(!state));
|
||||
const state = accountStorage.getItem(GRID_STORAGE_KEY) === 'true';
|
||||
accountStorage.setItem(GRID_STORAGE_KEY, String(!state));
|
||||
switchPersonaGridView();
|
||||
});
|
||||
|
||||
|
@ -24,6 +24,15 @@ export const POPUP_RESULT = {
|
||||
AFFIRMATIVE: 1,
|
||||
NEGATIVE: 0,
|
||||
CANCELLED: null,
|
||||
CUSTOM1: 1001,
|
||||
CUSTOM2: 1002,
|
||||
CUSTOM3: 1003,
|
||||
CUSTOM4: 1004,
|
||||
CUSTOM5: 1005,
|
||||
CUSTOM6: 1006,
|
||||
CUSTOM7: 1007,
|
||||
CUSTOM8: 1008,
|
||||
CUSTOM9: 1009,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -37,6 +46,7 @@ export const POPUP_RESULT = {
|
||||
* @property {boolean?} [transparent=false] - Whether to display the popup in transparent mode (no background, border, shadow or anything, only its content)
|
||||
* @property {boolean?} [allowHorizontalScrolling=false] - Whether to allow horizontal scrolling in the popup
|
||||
* @property {boolean?} [allowVerticalScrolling=false] - Whether to allow vertical scrolling in the popup
|
||||
* @property {boolean?} [leftAlign=false] - Whether the popup content should be left-aligned by default
|
||||
* @property {'slow'|'fast'|'none'?} [animation='slow'] - Animation speed for the popup (opening, closing, ...)
|
||||
* @property {POPUP_RESULT|number?} [defaultResult=POPUP_RESULT.AFFIRMATIVE] - The default result of this popup when Enter is pressed. Can be changed from `POPUP_RESULT.AFFIRMATIVE`.
|
||||
* @property {CustomPopupButton[]|string[]?} [customButtons=null] - Custom buttons to add to the popup. If only strings are provided, the buttons will be added with default options, and their result will be in order from `2` onward.
|
||||
@ -164,7 +174,7 @@ export class Popup {
|
||||
* @param {string} [inputValue=''] - The initial value of the input field
|
||||
* @param {PopupOptions} [options={}] - Additional options for the popup
|
||||
*/
|
||||
constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {
|
||||
constructor(content, type, inputValue = '', { okButton = null, cancelButton = null, rows = 1, wide = false, wider = false, large = false, transparent = false, allowHorizontalScrolling = false, allowVerticalScrolling = false, leftAlign = false, animation = 'fast', defaultResult = POPUP_RESULT.AFFIRMATIVE, customButtons = null, customInputs = null, onClosing = null, onClose = null, cropAspect = null, cropImage = null } = {}) {
|
||||
Popup.util.popups.push(this);
|
||||
|
||||
// Make this popup uniquely identifiable
|
||||
@ -209,6 +219,7 @@ export class Popup {
|
||||
if (transparent) this.dlg.classList.add('transparent_dialogue_popup');
|
||||
if (allowHorizontalScrolling) this.dlg.classList.add('horizontal_scrolling_dialogue_popup');
|
||||
if (allowVerticalScrolling) this.dlg.classList.add('vertical_scrolling_dialogue_popup');
|
||||
if (leftAlign) this.dlg.classList.add('left_aligned_dialogue_popup');
|
||||
if (animation) this.dlg.classList.add('popup--animation-' + animation);
|
||||
|
||||
// If custom button captions are provided, we set them beforehand
|
||||
|
@ -54,6 +54,7 @@ import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCom
|
||||
import { POPUP_TYPE, callGenericPopup } from './popup.js';
|
||||
import { loadSystemPrompts } from './sysprompt.js';
|
||||
import { fuzzySearchCategories } from './filters.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
export {
|
||||
loadPowerUserSettings,
|
||||
@ -253,6 +254,17 @@ let power_user = {
|
||||
content: 'Write {{char}}\'s next reply in a fictional chat between {{char}} and {{user}}.',
|
||||
},
|
||||
|
||||
reasoning: {
|
||||
auto_parse: false,
|
||||
add_to_prompts: false,
|
||||
auto_expand: false,
|
||||
show_hidden: false,
|
||||
prefix: '<think>\n',
|
||||
suffix: '\n</think>',
|
||||
separator: '\n\n',
|
||||
max_additions: 1,
|
||||
},
|
||||
|
||||
personas: {},
|
||||
default_persona: null,
|
||||
persona_descriptions: {},
|
||||
@ -2009,7 +2021,7 @@ export function renderStoryString(params) {
|
||||
*/
|
||||
function validateStoryString(storyString, params) {
|
||||
/** @type {{hashCache: {[hash: string]: {fieldsWarned: {[key: string]: boolean}}}}} */
|
||||
const cache = JSON.parse(localStorage.getItem(storage_keys.storyStringValidationCache)) ?? { hashCache: {} };
|
||||
const cache = JSON.parse(accountStorage.getItem(storage_keys.storyStringValidationCache)) ?? { hashCache: {} };
|
||||
|
||||
const hash = getStringHash(storyString);
|
||||
|
||||
@ -2046,7 +2058,7 @@ function validateStoryString(storyString, params) {
|
||||
toastr.warning(`The story string does not contain the following fields, but they would contain content: ${fieldsList}`, 'Story String Validation');
|
||||
}
|
||||
|
||||
localStorage.setItem(storage_keys.storyStringValidationCache, JSON.stringify(cache));
|
||||
accountStorage.setItem(storage_keys.storyStringValidationCache, JSON.stringify(cache));
|
||||
}
|
||||
|
||||
|
||||
@ -2441,7 +2453,7 @@ async function resetMovablePanels(type) {
|
||||
}
|
||||
|
||||
saveSettingsDebounced();
|
||||
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
|
||||
await eventSource.emit(event_types.MOVABLE_PANELS_RESET);
|
||||
|
||||
eventSource.once(event_types.SETTINGS_UPDATED, () => {
|
||||
$('.resizing').removeClass('resizing');
|
||||
@ -2534,7 +2546,7 @@ async function loadUntilMesId(mesId) {
|
||||
let target;
|
||||
|
||||
while (getFirstDisplayedMessageId() > mesId && getFirstDisplayedMessageId() !== 0) {
|
||||
showMoreMessages();
|
||||
await showMoreMessages();
|
||||
await delay(1);
|
||||
target = $('#chat').find(`.mes[mesid=${mesId}]`);
|
||||
|
||||
@ -2908,6 +2920,46 @@ export function flushEphemeralStoppingStrings() {
|
||||
EPHEMERAL_STOPPING_STRINGS.splice(0, EPHEMERAL_STOPPING_STRINGS.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the generated text should be filtered based on the auto-swipe settings.
|
||||
* @param {string} text The text to check
|
||||
* @returns {boolean} If the generated text should be filtered
|
||||
*/
|
||||
export function generatedTextFiltered(text) {
|
||||
/**
|
||||
* Checks if the given text contains any of the blacklisted words.
|
||||
* @param {string} text The text to check
|
||||
* @param {string[]} blacklist The list of blacklisted words
|
||||
* @param {number} threshold The number of blacklisted words that need to be present to trigger the check
|
||||
* @returns {boolean} Whether the text contains blacklisted words
|
||||
*/
|
||||
function containsBlacklistedWords(text, blacklist, threshold) {
|
||||
const regex = new RegExp(`\\b(${blacklist.join('|')})\\b`, 'gi');
|
||||
const matches = text.match(regex) || [];
|
||||
return matches.length >= threshold;
|
||||
}
|
||||
|
||||
// Make sure a generated text is non-empty
|
||||
// Otherwise we might get in a loop with a broken API
|
||||
text = text.trim();
|
||||
if (text.length > 0) {
|
||||
if (power_user.auto_swipe_minimum_length) {
|
||||
if (text.length < power_user.auto_swipe_minimum_length) {
|
||||
console.log('Generated text size too small');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (power_user.auto_swipe_blacklist.length && power_user.auto_swipe_blacklist_threshold) {
|
||||
if (containsBlacklistedWords(text, power_user.auto_swipe_blacklist, power_user.auto_swipe_blacklist_threshold)) {
|
||||
console.log('Generated text has blacklisted words');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom stopping strings from the power user settings.
|
||||
* @param {number | undefined} limit Number of strings to return. If 0 or undefined, returns all strings.
|
||||
@ -3879,9 +3931,9 @@ $(document).ready(() => {
|
||||
helpString: 'Start a new chat with a random character. If an argument is provided, only considers characters that have the specified tag.',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'delmode',
|
||||
name: 'del',
|
||||
callback: doDelMode,
|
||||
aliases: ['del'],
|
||||
aliases: ['delete', 'delmode'],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'optional number', [ARGUMENT_TYPE.NUMBER], false,
|
||||
@ -4064,4 +4116,45 @@ $(document).ready(() => {
|
||||
],
|
||||
helpString: 'activates a movingUI preset by name',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'stop-strings',
|
||||
aliases: ['stopping-strings', 'custom-stopping-strings', 'custom-stop-strings'],
|
||||
helpString: `
|
||||
<div>
|
||||
Sets a list of custom stopping strings. Gets the list if no value is provided.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Examples:</strong>
|
||||
</div>
|
||||
<ul>
|
||||
<li>Value must be a JSON-serialized array: <pre><code class="language-stscript">/stop-strings ["goodbye", "farewell"]</code></pre></li>
|
||||
<li>Pipe characters must be escaped with a backslash: <pre><code class="language-stscript">/stop-strings ["left\\|right"]</code></pre></li>
|
||||
</ul>
|
||||
`,
|
||||
returns: ARGUMENT_TYPE.LIST,
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'list of strings',
|
||||
typeList: [ARGUMENT_TYPE.LIST],
|
||||
acceptsMultiple: false,
|
||||
isRequired: false,
|
||||
}),
|
||||
],
|
||||
callback: (_, value) => {
|
||||
if (String(value ?? '').trim()) {
|
||||
const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value);
|
||||
if (!parsedValue || !Array.isArray(parsedValue)) {
|
||||
throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.');
|
||||
}
|
||||
parsedValue.forEach((item, index) => {
|
||||
parsedValue[index] = String(item);
|
||||
});
|
||||
power_user.custom_stopping_strings = JSON.stringify(parsedValue);
|
||||
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
return power_user.custom_stopping_strings;
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
@ -586,6 +586,9 @@ class PresetManager {
|
||||
'tabby_model',
|
||||
'derived',
|
||||
'generic_model',
|
||||
'include_reasoning',
|
||||
'global_banned_tokens',
|
||||
'send_banned_tokens',
|
||||
];
|
||||
const settings = Object.assign({}, getSettingsByApiId(this.apiId));
|
||||
|
||||
|
913
public/scripts/reasoning.js
Normal file
913
public/scripts/reasoning.js
Normal file
@ -0,0 +1,913 @@
|
||||
import {
|
||||
moment,
|
||||
} from '../lib.js';
|
||||
import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFormatting, saveChatConditional, saveSettingsDebounced, substituteParams, updateMessageBlock } from '../script.js';
|
||||
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
|
||||
import { getCurrentLocale, t } from './i18n.js';
|
||||
import { MacrosParser } from './macros.js';
|
||||
import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';
|
||||
import { Popup } from './popup.js';
|
||||
import { power_user } from './power-user.js';
|
||||
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
|
||||
import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js';
|
||||
import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
|
||||
import { textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
|
||||
import { copyText, escapeRegex, isFalseBoolean, setDatasetProperty } from './utils.js';
|
||||
|
||||
/**
|
||||
* Gets a message from a jQuery element.
|
||||
* @param {Element} element
|
||||
* @returns {{messageId: number, message: object, messageBlock: JQuery<HTMLElement>}}
|
||||
*/
|
||||
function getMessageFromJquery(element) {
|
||||
const messageBlock = $(element).closest('.mes');
|
||||
const messageId = Number(messageBlock.attr('mesid'));
|
||||
const message = chat[messageId];
|
||||
return { messageId: messageId, message, messageBlock };
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the auto-expand state of reasoning blocks.
|
||||
*/
|
||||
function toggleReasoningAutoExpand() {
|
||||
const reasoningBlocks = document.querySelectorAll('details.mes_reasoning_details');
|
||||
reasoningBlocks.forEach((block) => {
|
||||
if (block instanceof HTMLDetailsElement) {
|
||||
block.open = power_user.reasoning.auto_expand;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the reasoning from the response data.
|
||||
* @param {object} data Response data
|
||||
* @returns {string} Extracted reasoning
|
||||
*/
|
||||
export function extractReasoningFromData(data) {
|
||||
switch (main_api) {
|
||||
case 'textgenerationwebui':
|
||||
switch (textgenerationwebui_settings.type) {
|
||||
case textgen_types.OPENROUTER:
|
||||
return data?.choices?.[0]?.reasoning ?? '';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'openai':
|
||||
if (!oai_settings.show_thoughts) break;
|
||||
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
case chat_completion_sources.DEEPSEEK:
|
||||
return data?.choices?.[0]?.message?.reasoning_content ?? '';
|
||||
case chat_completion_sources.OPENROUTER:
|
||||
return data?.choices?.[0]?.message?.reasoning ?? '';
|
||||
case chat_completion_sources.MAKERSUITE:
|
||||
return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the model supports reasoning, but does not send back the reasoning
|
||||
* @returns {boolean} True if the model supports reasoning
|
||||
*/
|
||||
export function isHiddenReasoningModel() {
|
||||
if (main_api !== 'openai') {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @typedef {{ (currentModel: string, supportedModel: string): boolean }} MatchingFunc */
|
||||
/** @type {Record.<string, MatchingFunc>} */
|
||||
const FUNCS = {
|
||||
equals: (currentModel, supportedModel) => currentModel === supportedModel,
|
||||
startsWith: (currentModel, supportedModel) => currentModel.startsWith(supportedModel),
|
||||
};
|
||||
|
||||
/** @type {{ name: string; func: MatchingFunc; }[]} */
|
||||
const hiddenReasoningModels = [
|
||||
{ name: 'o1', func: FUNCS.startsWith },
|
||||
{ name: 'o3', func: FUNCS.startsWith },
|
||||
{ name: 'gemini-2.0-flash-thinking-exp', func: FUNCS.startsWith },
|
||||
{ name: 'gemini-2.0-pro-exp', func: FUNCS.startsWith },
|
||||
];
|
||||
|
||||
const model = getChatCompletionModel() || '';
|
||||
|
||||
const isHidden = hiddenReasoningModels.some(({ name, func }) => func(model, name));
|
||||
return isHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the Reasoning UI for a specific message
|
||||
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement The message ID or the message element
|
||||
* @param {Object} [options={}] - Optional arguments
|
||||
* @param {boolean} [options.reset=false] - Whether to reset state, and not take the current mess properties (for example when swiping)
|
||||
*/
|
||||
export function updateReasoningUI(messageIdOrElement, { reset = false } = {}) {
|
||||
const handler = new ReasoningHandler();
|
||||
handler.initHandleMessage(messageIdOrElement, { reset });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enum for representing the state of reasoning
|
||||
* @enum {string}
|
||||
* @readonly
|
||||
*/
|
||||
export const ReasoningState = {
|
||||
None: 'none',
|
||||
Thinking: 'thinking',
|
||||
Done: 'done',
|
||||
Hidden: 'hidden',
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles reasoning-specific logic and DOM updates for messages.
|
||||
* This class is used inside the {@link StreamingProcessor} to manage reasoning states and UI updates.
|
||||
*/
|
||||
export class ReasoningHandler {
|
||||
#isHiddenReasoningModel;
|
||||
|
||||
/**
|
||||
* @param {Date?} [timeStarted=null] - When the generation started
|
||||
*/
|
||||
constructor(timeStarted = null) {
|
||||
/** @type {ReasoningState} The current state of the reasoning process */
|
||||
this.state = ReasoningState.None;
|
||||
/** @type {string} The reasoning output */
|
||||
this.reasoning = '';
|
||||
/** @type {Date} When the reasoning started */
|
||||
this.startTime = null;
|
||||
/** @type {Date} When the reasoning ended */
|
||||
this.endTime = null;
|
||||
|
||||
/** @type {Date} Initial starting time of the generation */
|
||||
this.initialTime = timeStarted ?? new Date();
|
||||
|
||||
/** @type {boolean} True if the model supports reasoning, but hides the reasoning output */
|
||||
this.#isHiddenReasoningModel = isHiddenReasoningModel();
|
||||
|
||||
// Cached DOM elements for reasoning
|
||||
/** @type {HTMLElement} Main message DOM element `.mes` */
|
||||
this.messageDom = null;
|
||||
/** @type {HTMLDetailsElement} Reasoning details DOM element `.mes_reasoning_details` */
|
||||
this.messageReasoningDetailsDom = null;
|
||||
/** @type {HTMLElement} Reasoning content DOM element `.mes_reasoning` */
|
||||
this.messageReasoningContentDom = null;
|
||||
/** @type {HTMLElement} Reasoning header DOM element `.mes_reasoning_header_title` */
|
||||
this.messageReasoningHeaderDom = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the reasoning handler for a specific message.
|
||||
*
|
||||
* Can be used to update the DOM elements or read other reasoning states.
|
||||
* It will internally take the message-saved data and write the states back into the handler, as if during streaming of the message.
|
||||
* The state will always be either done/hidden or none.
|
||||
*
|
||||
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement - The message ID or the message element
|
||||
* @param {Object} [options={}] - Optional arguments
|
||||
* @param {boolean} [options.reset=false] - Whether to reset state of the handler, and not take the current mess properties (for example when swiping)
|
||||
*/
|
||||
initHandleMessage(messageIdOrElement, { reset = false } = {}) {
|
||||
/** @type {HTMLElement} */
|
||||
const messageElement = typeof messageIdOrElement === 'number'
|
||||
? document.querySelector(`#chat [mesid="${messageIdOrElement}"]`)
|
||||
: messageIdOrElement instanceof HTMLElement
|
||||
? messageIdOrElement
|
||||
: $(messageIdOrElement)[0];
|
||||
const messageId = Number(messageElement.getAttribute('mesid'));
|
||||
|
||||
if (isNaN(messageId) || !chat[messageId]) return;
|
||||
|
||||
if (!chat[messageId].extra) {
|
||||
chat[messageId].extra = {};
|
||||
}
|
||||
const extra = chat[messageId].extra;
|
||||
|
||||
if (extra.reasoning) {
|
||||
this.state = ReasoningState.Done;
|
||||
} else if (extra.reasoning_duration) {
|
||||
this.state = ReasoningState.Hidden;
|
||||
}
|
||||
|
||||
this.reasoning = extra?.reasoning ?? '';
|
||||
|
||||
if (this.state !== ReasoningState.None) {
|
||||
this.initialTime = new Date(chat[messageId].gen_started);
|
||||
this.startTime = this.initialTime;
|
||||
this.endTime = new Date(this.startTime.getTime() + (extra?.reasoning_duration ?? 0));
|
||||
}
|
||||
|
||||
// Prefill main dom element, as message might not have been rendered yet
|
||||
this.messageDom = messageElement;
|
||||
|
||||
// Make sure reset correctly clears all relevant states
|
||||
if (reset) {
|
||||
this.state = this.#isHiddenReasoningModel ? ReasoningState.Thinking : ReasoningState.None;
|
||||
this.reasoning = '';
|
||||
this.initialTime = new Date();
|
||||
this.startTime = null;
|
||||
this.endTime = null;
|
||||
}
|
||||
|
||||
this.updateDom(messageId);
|
||||
|
||||
if (power_user.reasoning.auto_expand && this.state !== ReasoningState.Hidden) {
|
||||
this.messageReasoningDetailsDom.open = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration of the reasoning in milliseconds.
|
||||
*
|
||||
* @returns {number?} The duration in milliseconds, or null if the start or end time is not set
|
||||
*/
|
||||
getDuration() {
|
||||
if (this.startTime && this.endTime) {
|
||||
return this.endTime.getTime() - this.startTime.getTime();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the reasoning text/string for a message.
|
||||
*
|
||||
* @param {number} messageId - The ID of the message to update
|
||||
* @param {string?} [reasoning=null] - The reasoning text to update - If null, uses the current reasoning
|
||||
* @param {Object} [options={}] - Optional arguments
|
||||
* @param {boolean} [options.persist=false] - Whether to persist the reasoning to the message object
|
||||
* @returns {boolean} - Returns true if the reasoning was changed, otherwise false
|
||||
*/
|
||||
updateReasoning(messageId, reasoning = null, { persist = false } = {}) {
|
||||
if (messageId == -1 || !chat[messageId]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reasoning = reasoning ?? this.reasoning;
|
||||
reasoning = power_user.trim_spaces ? reasoning.trim() : reasoning;
|
||||
|
||||
// Ensure the chat extra exists
|
||||
if (!chat[messageId].extra) {
|
||||
chat[messageId].extra = {};
|
||||
}
|
||||
const extra = chat[messageId].extra;
|
||||
|
||||
const reasoningChanged = extra.reasoning !== reasoning;
|
||||
this.reasoning = getRegexedString(reasoning ?? '', regex_placement.REASONING);
|
||||
|
||||
if (persist) {
|
||||
// Build and save the reasoning data to message extras
|
||||
extra.reasoning = this.reasoning;
|
||||
extra.reasoning_duration = this.getDuration();
|
||||
}
|
||||
|
||||
return reasoningChanged;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles processing of reasoning for a message.
|
||||
*
|
||||
* This is usually called by the message processor when a message is changed.
|
||||
*
|
||||
* @param {number} messageId - The ID of the message to process
|
||||
* @param {boolean} mesChanged - Whether the message has changed
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async process(messageId, mesChanged) {
|
||||
if (!this.reasoning && !this.#isHiddenReasoningModel) return;
|
||||
|
||||
// Ensure reasoning string is updated and regexes are applied correctly
|
||||
const reasoningChanged = this.updateReasoning(messageId, null, { persist: true });
|
||||
|
||||
if ((this.#isHiddenReasoningModel || reasoningChanged) && this.state === ReasoningState.None) {
|
||||
this.state = ReasoningState.Thinking;
|
||||
this.startTime = this.initialTime;
|
||||
}
|
||||
if ((this.#isHiddenReasoningModel || !reasoningChanged) && mesChanged && this.state === ReasoningState.Thinking) {
|
||||
this.endTime = new Date();
|
||||
await this.finish(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes the reasoning process for a message.
|
||||
*
|
||||
* Records the finish time if it was not set during streaming and updates the reasoning state.
|
||||
* Emits an event to signal the completion of reasoning and updates the DOM elements accordingly.
|
||||
*
|
||||
* @param {number} messageId - The ID of the message to complete reasoning for
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async finish(messageId) {
|
||||
if (this.state === ReasoningState.None) return;
|
||||
|
||||
// Make sure the finish time is recorded if a reasoning was in process and it wasn't ended correctly during streaming
|
||||
if (this.startTime !== null && this.endTime === null) {
|
||||
this.endTime = new Date();
|
||||
}
|
||||
|
||||
if (this.state === ReasoningState.Thinking) {
|
||||
this.state = this.#isHiddenReasoningModel ? ReasoningState.Hidden : ReasoningState.Done;
|
||||
this.updateReasoning(messageId, null, { persist: true });
|
||||
await eventSource.emit(event_types.STREAM_REASONING_DONE, this.reasoning, this.getDuration(), messageId, this.state);
|
||||
}
|
||||
|
||||
this.updateDom(messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the reasoning UI elements for a message.
|
||||
*
|
||||
* Toggles the CSS class, updates states, reasoning message, and duration.
|
||||
*
|
||||
* @param {number} messageId - The ID of the message to update
|
||||
*/
|
||||
updateDom(messageId) {
|
||||
this.#checkDomElements(messageId);
|
||||
|
||||
// Main CSS class to show this message includes reasoning
|
||||
this.messageDom.classList.toggle('reasoning', this.state !== ReasoningState.None);
|
||||
|
||||
// Update states to the relevant DOM elements
|
||||
setDatasetProperty(this.messageDom, 'reasoningState', this.state !== ReasoningState.None ? this.state : null);
|
||||
setDatasetProperty(this.messageReasoningDetailsDom, 'state', this.state);
|
||||
|
||||
// Update the reasoning message
|
||||
const reasoning = power_user.trim_spaces ? this.reasoning.trim() : this.reasoning;
|
||||
const displayReasoning = messageFormatting(reasoning, '', false, false, messageId, {}, true);
|
||||
this.messageReasoningContentDom.innerHTML = displayReasoning;
|
||||
|
||||
// Update tooltip for hidden reasoning edit
|
||||
/** @type {HTMLElement} */
|
||||
const button = this.messageDom.querySelector('.mes_edit_add_reasoning');
|
||||
button.title = this.state === ReasoningState.Hidden ? t`Hidden reasoning - Add reasoning block` : t`Add reasoning block`;
|
||||
|
||||
// Make sure that hidden reasoning headers are collapsed by default, to not show a useless edit button
|
||||
if (this.state === ReasoningState.Hidden) {
|
||||
this.messageReasoningDetailsDom.open = false;
|
||||
}
|
||||
|
||||
// Update the reasoning duration in the UI
|
||||
this.#updateReasoningTimeUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and caches reasoning-related DOM elements for the given message.
|
||||
*
|
||||
* @param {number} messageId - The ID of the message to cache the DOM elements for
|
||||
*/
|
||||
#checkDomElements(messageId) {
|
||||
// Make sure we reset dom elements if we are checking for a different message (shouldn't happen, but be sure)
|
||||
if (this.messageDom !== null && this.messageDom.getAttribute('mesid') !== messageId.toString()) {
|
||||
this.messageDom = null;
|
||||
}
|
||||
|
||||
// Cache the DOM elements once
|
||||
if (this.messageDom === null) {
|
||||
this.messageDom = document.querySelector(`#chat .mes[mesid="${messageId}"]`);
|
||||
if (this.messageDom === null) throw new Error('message dom does not exist');
|
||||
}
|
||||
if (this.messageReasoningDetailsDom === null) {
|
||||
this.messageReasoningDetailsDom = this.messageDom.querySelector('.mes_reasoning_details');
|
||||
}
|
||||
if (this.messageReasoningContentDom === null) {
|
||||
this.messageReasoningContentDom = this.messageDom.querySelector('.mes_reasoning');
|
||||
}
|
||||
if (this.messageReasoningHeaderDom === null) {
|
||||
this.messageReasoningHeaderDom = this.messageDom.querySelector('.mes_reasoning_header_title');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the reasoning time display in the UI.
|
||||
*
|
||||
* Shows the duration in a human-readable format with a tooltip for exact seconds.
|
||||
* Displays "Thinking..." if still processing, or a generic message otherwise.
|
||||
*/
|
||||
#updateReasoningTimeUI() {
|
||||
const element = this.messageReasoningHeaderDom;
|
||||
const duration = this.getDuration();
|
||||
let data = null;
|
||||
if (duration) {
|
||||
const durationStr = moment.duration(duration).locale(getCurrentLocale()).humanize({ s: 50, ss: 3 });
|
||||
const secondsStr = moment.duration(duration).asSeconds();
|
||||
|
||||
const span = document.createElement('span');
|
||||
span.title = t`${secondsStr} seconds`;
|
||||
span.textContent = durationStr;
|
||||
|
||||
element.textContent = t`Thought for `;
|
||||
element.appendChild(span);
|
||||
data = String(secondsStr);
|
||||
} else if ([ReasoningState.Done, ReasoningState.Hidden].includes(this.state)) {
|
||||
element.textContent = t`Thought for some time`;
|
||||
data = 'unknown';
|
||||
} else {
|
||||
element.textContent = t`Thinking...`;
|
||||
data = null;
|
||||
}
|
||||
|
||||
setDatasetProperty(this.messageReasoningDetailsDom, 'duration', data);
|
||||
setDatasetProperty(element, 'duration', data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class for adding reasoning to messages.
|
||||
* Keeps track of the number of reasoning additions.
|
||||
*/
|
||||
export class PromptReasoning {
|
||||
static REASONING_PLACEHOLDER = '\u200B';
|
||||
|
||||
constructor() {
|
||||
this.counter = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the limit of reasoning additions has been reached.
|
||||
* @returns {boolean} True if the limit of reasoning additions has been reached, false otherwise.
|
||||
*/
|
||||
isLimitReached() {
|
||||
if (!power_user.reasoning.add_to_prompts) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.counter >= power_user.reasoning.max_additions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add reasoning to a message according to the power user settings.
|
||||
* @param {string} content Message content
|
||||
* @param {string} reasoning Message reasoning
|
||||
* @param {boolean} isPrefix Whether this is the last message prefix
|
||||
* @returns {string} Message content with reasoning
|
||||
*/
|
||||
addToMessage(content, reasoning, isPrefix) {
|
||||
// Disabled or reached limit of additions
|
||||
if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
|
||||
return content;
|
||||
}
|
||||
|
||||
// No reasoning provided or a legacy placeholder
|
||||
if (!reasoning || reasoning === PromptReasoning.REASONING_PLACEHOLDER) {
|
||||
return content;
|
||||
}
|
||||
|
||||
// Increment the counter
|
||||
this.counter++;
|
||||
|
||||
// Substitute macros in variable parts
|
||||
const prefix = substituteParams(power_user.reasoning.prefix || '');
|
||||
const separator = substituteParams(power_user.reasoning.separator || '');
|
||||
const suffix = substituteParams(power_user.reasoning.suffix || '');
|
||||
|
||||
// Combine parts with reasoning only
|
||||
if (isPrefix && !content) {
|
||||
return `${prefix}${reasoning}`;
|
||||
}
|
||||
|
||||
// Combine parts with reasoning and content
|
||||
return `${prefix}${reasoning}${suffix}${separator}${content}`;
|
||||
}
|
||||
}
|
||||
|
||||
function loadReasoningSettings() {
|
||||
$('#reasoning_add_to_prompts').prop('checked', power_user.reasoning.add_to_prompts);
|
||||
$('#reasoning_add_to_prompts').on('change', function () {
|
||||
power_user.reasoning.add_to_prompts = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_prefix').val(power_user.reasoning.prefix);
|
||||
$('#reasoning_prefix').on('input', function () {
|
||||
power_user.reasoning.prefix = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_suffix').val(power_user.reasoning.suffix);
|
||||
$('#reasoning_suffix').on('input', function () {
|
||||
power_user.reasoning.suffix = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_separator').val(power_user.reasoning.separator);
|
||||
$('#reasoning_separator').on('input', function () {
|
||||
power_user.reasoning.separator = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_max_additions').val(power_user.reasoning.max_additions);
|
||||
$('#reasoning_max_additions').on('input', function () {
|
||||
power_user.reasoning.max_additions = Number($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_auto_parse').prop('checked', power_user.reasoning.auto_parse);
|
||||
$('#reasoning_auto_parse').on('change', function () {
|
||||
power_user.reasoning.auto_parse = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#reasoning_auto_expand').prop('checked', power_user.reasoning.auto_expand);
|
||||
$('#reasoning_auto_expand').on('change', function () {
|
||||
power_user.reasoning.auto_expand = !!$(this).prop('checked');
|
||||
toggleReasoningAutoExpand();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
toggleReasoningAutoExpand();
|
||||
|
||||
$('#reasoning_show_hidden').prop('checked', power_user.reasoning.show_hidden);
|
||||
$('#reasoning_show_hidden').on('change', function () {
|
||||
power_user.reasoning.show_hidden = !!$(this).prop('checked');
|
||||
$('#chat').attr('data-show-hidden-reasoning', power_user.reasoning.show_hidden ? 'true' : null);
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#chat').attr('data-show-hidden-reasoning', power_user.reasoning.show_hidden ? 'true' : null);
|
||||
}
|
||||
|
||||
function registerReasoningSlashCommands() {
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'reasoning-get',
|
||||
aliases: ['get-reasoning'],
|
||||
returns: ARGUMENT_TYPE.STRING,
|
||||
helpString: t`Get the contents of a reasoning block of a message. Returns an empty string if the message does not have a reasoning block.`,
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'Message ID. If not provided, the message ID of the last message is used.',
|
||||
typeList: ARGUMENT_TYPE.NUMBER,
|
||||
enumProvider: commonEnumProviders.messages(),
|
||||
}),
|
||||
],
|
||||
callback: (_args, value) => {
|
||||
const messageId = !isNaN(parseInt(value.toString())) ? parseInt(value.toString()) : chat.length - 1;
|
||||
const message = chat[messageId];
|
||||
const reasoning = String(message?.extra?.reasoning ?? '');
|
||||
return reasoning;
|
||||
},
|
||||
}));
|
||||
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'reasoning-set',
|
||||
aliases: ['set-reasoning'],
|
||||
returns: ARGUMENT_TYPE.STRING,
|
||||
helpString: t`Set the reasoning block of a message. Returns the reasoning block content.`,
|
||||
namedArgumentList: [
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'at',
|
||||
description: 'Message ID. If not provided, the message ID of the last message is used.',
|
||||
typeList: ARGUMENT_TYPE.NUMBER,
|
||||
enumProvider: commonEnumProviders.messages(),
|
||||
}),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'Reasoning block content.',
|
||||
typeList: ARGUMENT_TYPE.STRING,
|
||||
}),
|
||||
],
|
||||
callback: async (args, value) => {
|
||||
const messageId = !isNaN(Number(args.at)) ? Number(args.at) : chat.length - 1;
|
||||
const message = chat[messageId];
|
||||
if (!message?.extra) {
|
||||
return '';
|
||||
}
|
||||
|
||||
message.extra.reasoning = String(value ?? '');
|
||||
await saveChatConditional();
|
||||
|
||||
closeMessageEditor('reasoning');
|
||||
updateMessageBlock(messageId, message);
|
||||
return message.extra.reasoning;
|
||||
},
|
||||
}));
|
||||
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'reasoning-parse',
|
||||
aliases: ['parse-reasoning'],
|
||||
returns: 'reasoning string',
|
||||
helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`,
|
||||
namedArgumentList: [
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'regex',
|
||||
description: 'Whether to apply regex scripts to the reasoning content.',
|
||||
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||
defaultValue: 'true',
|
||||
isRequired: false,
|
||||
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||
}),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'input string',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
}),
|
||||
],
|
||||
callback: (args, value) => {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!power_user.reasoning.prefix || !power_user.reasoning.suffix) {
|
||||
toastr.warning(t`Both prefix and suffix must be set in the Reasoning Formatting settings.`);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
const parsedReasoning = parseReasoningFromString(String(value));
|
||||
|
||||
if (!parsedReasoning) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const applyRegex = !isFalseBoolean(String(args.regex ?? ''));
|
||||
return applyRegex
|
||||
? getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING)
|
||||
: parsedReasoning.reasoning;
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
function registerReasoningMacros() {
|
||||
MacrosParser.registerMacro('reasoningPrefix', () => power_user.reasoning.prefix, t`Reasoning Prefix`);
|
||||
MacrosParser.registerMacro('reasoningSuffix', () => power_user.reasoning.suffix, t`Reasoning Suffix`);
|
||||
MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);
|
||||
}
|
||||
|
||||
function setReasoningEventHandlers() {
|
||||
$(document).on('click', '.mes_reasoning_details', function (e) {
|
||||
if (!e.target.closest('.mes_reasoning_actions') && !e.target.closest('.mes_reasoning_header')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_header', function (e) {
|
||||
const details = $(this).closest('.mes_reasoning_details');
|
||||
// Along with the CSS rules to mark blocks not toggle-able when they are empty, prevent them from actually being toggled, or being edited
|
||||
if (details.find('.mes_reasoning').is(':empty')) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are in message edit mode and reasoning area is closed, a click opens and edits it
|
||||
const mes = $(this).closest('.mes');
|
||||
const mesEditArea = mes.find('#curEditTextarea');
|
||||
if (mesEditArea.length) {
|
||||
const summary = $(mes).find('.mes_reasoning_summary');
|
||||
if (!summary.attr('open')) {
|
||||
summary.find('.mes_reasoning_edit').trigger('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_copy', (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_edit', function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
const { message, messageBlock } = getMessageFromJquery(this);
|
||||
if (!message?.extra) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reasoning = String(message?.extra?.reasoning ?? '');
|
||||
const chatElement = document.getElementById('chat');
|
||||
const textarea = document.createElement('textarea');
|
||||
const reasoningBlock = messageBlock.find('.mes_reasoning');
|
||||
textarea.classList.add('reasoning_edit_textarea');
|
||||
textarea.value = reasoning;
|
||||
$(textarea).insertBefore(reasoningBlock);
|
||||
|
||||
if (!CSS.supports('field-sizing', 'content')) {
|
||||
const resetHeight = function () {
|
||||
const scrollTop = chatElement.scrollTop;
|
||||
textarea.style.height = '0px';
|
||||
textarea.style.height = `${textarea.scrollHeight}px`;
|
||||
chatElement.scrollTop = scrollTop;
|
||||
};
|
||||
|
||||
textarea.addEventListener('input', resetHeight);
|
||||
resetHeight();
|
||||
}
|
||||
|
||||
textarea.focus();
|
||||
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
|
||||
|
||||
const textareaRect = textarea.getBoundingClientRect();
|
||||
const chatRect = chatElement.getBoundingClientRect();
|
||||
|
||||
// Scroll if textarea bottom is below visible area
|
||||
if (textareaRect.bottom > chatRect.bottom) {
|
||||
const scrollOffset = textareaRect.bottom - chatRect.bottom;
|
||||
chatElement.scrollTop += scrollOffset;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_edit_done', async function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
const { message, messageId, messageBlock } = getMessageFromJquery(this);
|
||||
if (!message?.extra) {
|
||||
return;
|
||||
}
|
||||
|
||||
const textarea = messageBlock.find('.reasoning_edit_textarea');
|
||||
const reasoning = getRegexedString(String(textarea.val()), regex_placement.REASONING, { isEdit: true });
|
||||
message.extra.reasoning = reasoning;
|
||||
await saveChatConditional();
|
||||
updateMessageBlock(messageId, message);
|
||||
textarea.remove();
|
||||
|
||||
messageBlock.find('.mes_edit_done:visible').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_edit_cancel', function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
const { messageBlock } = getMessageFromJquery(this);
|
||||
const textarea = messageBlock.find('.reasoning_edit_textarea');
|
||||
textarea.remove();
|
||||
|
||||
messageBlock.find('.mes_reasoning_edit_cancel:visible').trigger('click');
|
||||
|
||||
updateReasoningUI(messageBlock);
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_edit_add_reasoning', async function () {
|
||||
const { message, messageBlock } = getMessageFromJquery(this);
|
||||
if (!message?.extra) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.extra.reasoning) {
|
||||
toastr.info(t`Reasoning already exists.`, t`Edit Message`);
|
||||
return;
|
||||
}
|
||||
|
||||
messageBlock.addClass('reasoning');
|
||||
|
||||
// To make hidden reasoning blocks editable, we just set them to "Done" here already.
|
||||
// They will be done on save anyway - and on cancel the reasoning block gets rerendered too.
|
||||
if (messageBlock.attr('data-reasoning-state') === ReasoningState.Hidden) {
|
||||
messageBlock.attr('data-reasoning-state', ReasoningState.Done);
|
||||
}
|
||||
|
||||
// Open the reasoning area so we can actually edit it
|
||||
messageBlock.find('.mes_reasoning_details').attr('open', '');
|
||||
messageBlock.find('.mes_reasoning_edit').trigger('click');
|
||||
await saveChatConditional();
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_reasoning_delete', async function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
const confirm = await Popup.show.confirm(t`Remove Reasoning`, t`Are you sure you want to clear the reasoning?<br />Visible message contents will stay intact.`);
|
||||
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { message, messageId, messageBlock } = getMessageFromJquery(this);
|
||||
if (!message?.extra) {
|
||||
return;
|
||||
}
|
||||
message.extra.reasoning = '';
|
||||
await saveChatConditional();
|
||||
updateMessageBlock(messageId, message);
|
||||
const textarea = messageBlock.find('.reasoning_edit_textarea');
|
||||
textarea.remove();
|
||||
});
|
||||
|
||||
$(document).on('pointerup', '.mes_reasoning_copy', async function () {
|
||||
const { message } = getMessageFromJquery(this);
|
||||
const reasoning = String(message?.extra?.reasoning ?? '');
|
||||
|
||||
if (!reasoning) {
|
||||
return;
|
||||
}
|
||||
|
||||
await copyText(reasoning);
|
||||
toastr.info(t`Copied!`, '', { timeOut: 2000 });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes reasoning from a string if auto-parsing is enabled.
|
||||
* @param {string} str Input string
|
||||
* @returns {string} Output string
|
||||
*/
|
||||
export function removeReasoningFromString(str) {
|
||||
if (!power_user.reasoning.auto_parse) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const parsedReasoning = parseReasoningFromString(str);
|
||||
return parsedReasoning?.content ?? str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses reasoning from a string using the power user reasoning settings.
|
||||
* @typedef {Object} ParsedReasoning
|
||||
* @property {string} reasoning Reasoning block
|
||||
* @property {string} content Message content
|
||||
* @param {string} str Content of the message
|
||||
* @returns {ParsedReasoning|null} Parsed reasoning block and message content
|
||||
*/
|
||||
function parseReasoningFromString(str) {
|
||||
// Both prefix and suffix must be defined
|
||||
if (!power_user.reasoning.prefix || !power_user.reasoning.suffix) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const regex = new RegExp(`${escapeRegex(power_user.reasoning.prefix)}(.*?)${escapeRegex(power_user.reasoning.suffix)}`, 's');
|
||||
|
||||
let didReplace = false;
|
||||
let reasoning = '';
|
||||
let content = String(str).replace(regex, (_match, captureGroup) => {
|
||||
didReplace = true;
|
||||
reasoning = captureGroup;
|
||||
return '';
|
||||
});
|
||||
|
||||
if (didReplace && power_user.trim_spaces) {
|
||||
reasoning = reasoning.trim();
|
||||
content = content.trim();
|
||||
}
|
||||
|
||||
return { reasoning, content };
|
||||
} catch (error) {
|
||||
console.error('[Reasoning] Error parsing reasoning block', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function registerReasoningAppEvents() {
|
||||
eventSource.makeFirst(event_types.MESSAGE_RECEIVED, (/** @type {number} */ idx) => {
|
||||
if (!power_user.reasoning.auto_parse) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.debug('[Reasoning] Auto-parsing reasoning block for message', idx);
|
||||
const message = chat[idx];
|
||||
|
||||
if (!message) {
|
||||
console.warn('[Reasoning] Message not found', idx);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!message.mes || message.mes === '...') {
|
||||
console.debug('[Reasoning] Message content is empty or a placeholder', idx);
|
||||
return null;
|
||||
}
|
||||
|
||||
const parsedReasoning = parseReasoningFromString(message.mes);
|
||||
|
||||
// No reasoning block found
|
||||
if (!parsedReasoning) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the message has an extra object
|
||||
if (!message.extra || typeof message.extra !== 'object') {
|
||||
message.extra = {};
|
||||
}
|
||||
|
||||
const contentUpdated = !!parsedReasoning.reasoning || parsedReasoning.content !== message.mes;
|
||||
|
||||
// If reasoning was found, add it to the message
|
||||
if (parsedReasoning.reasoning) {
|
||||
message.extra.reasoning = getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING);
|
||||
}
|
||||
|
||||
// Update the message text if it was changed
|
||||
if (parsedReasoning.content !== message.mes) {
|
||||
message.mes = parsedReasoning.content;
|
||||
}
|
||||
|
||||
// Find if a message already exists in DOM and must be updated
|
||||
if (contentUpdated) {
|
||||
const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;
|
||||
if (messageRendered) {
|
||||
console.debug('[Reasoning] Updating message block', idx);
|
||||
updateMessageBlock(idx, message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function initReasoning() {
|
||||
loadReasoningSettings();
|
||||
setReasoningEventHandlers();
|
||||
registerReasoningSlashCommands();
|
||||
registerReasoningMacros();
|
||||
registerReasoningAppEvents();
|
||||
}
|
@ -40,6 +40,8 @@ export const SECRET_KEYS = {
|
||||
BFL: 'api_key_bfl',
|
||||
GENERIC: 'api_key_generic',
|
||||
DEEPSEEK: 'api_key_deepseek',
|
||||
SERPER: 'api_key_serper',
|
||||
FALAI: 'api_key_falai',
|
||||
};
|
||||
|
||||
const INPUT_MAP = {
|
||||
|
@ -42,6 +42,7 @@ import {
|
||||
showMoreMessages,
|
||||
stopGeneration,
|
||||
substituteParams,
|
||||
syncCurrentSwipeInfoExtras,
|
||||
system_avatar,
|
||||
system_message_types,
|
||||
this_chid,
|
||||
@ -58,7 +59,7 @@ import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockStat
|
||||
import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';
|
||||
import { SERVER_INPUTS, textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
|
||||
import { decodeTextTokens, getAvailableTokenizers, getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, selectTokenizer } from './tokenizers.js';
|
||||
import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
|
||||
import { debounce, delay, equalsIgnoreCaseAndAccents, findChar, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, regexFromString, showFontAwesomePicker, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
|
||||
import { registerVariableCommands, resolveVariable } from './variables.js';
|
||||
import { background_settings } from './backgrounds.js';
|
||||
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
|
||||
@ -74,6 +75,7 @@ import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCom
|
||||
import { SlashCommandBreakController } from './slash-commands/SlashCommandBreakController.js';
|
||||
import { SlashCommandExecutionError } from './slash-commands/SlashCommandExecutionError.js';
|
||||
import { slashCommandReturnHelper } from './slash-commands/SlashCommandReturnHelper.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
export {
|
||||
executeSlashCommands, executeSlashCommandsWithOptions, getSlashCommandsHelp, registerSlashCommand,
|
||||
};
|
||||
@ -234,7 +236,6 @@ export function initDefaultSlashCommands() {
|
||||
description: 'Character name - or unique character identifier (avatar key)',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
enumProvider: commonEnumProviders.characters('character'),
|
||||
forceEnum: false,
|
||||
}),
|
||||
],
|
||||
helpString: `
|
||||
@ -273,7 +274,6 @@ export function initDefaultSlashCommands() {
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
isRequired: true,
|
||||
enumProvider: commonEnumProviders.characters('character'),
|
||||
forceEnum: false,
|
||||
}),
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'avatar',
|
||||
@ -517,7 +517,6 @@ export function initDefaultSlashCommands() {
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
isRequired: true,
|
||||
enumProvider: commonEnumProviders.characters('all'),
|
||||
forceEnum: true,
|
||||
}),
|
||||
],
|
||||
helpString: 'Opens up a chat with the character or group by its name',
|
||||
@ -732,6 +731,57 @@ export function initDefaultSlashCommands() {
|
||||
],
|
||||
helpString: 'Unhides a message from the prompt.',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'member-get',
|
||||
aliases: ['getmember', 'memberget'],
|
||||
callback: (async ({ field = 'name' }, arg) => {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /member-get command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
if (field === '') {
|
||||
toastr.warning('\'/member-get field=\' argument required!');
|
||||
return '';
|
||||
}
|
||||
field = field.toString();
|
||||
arg = arg.toString();
|
||||
if (!['name', 'index', 'id', 'avatar'].includes(field)) {
|
||||
toastr.warning('\'/member-get field=\' argument required!');
|
||||
return '';
|
||||
}
|
||||
const isId = !isNaN(parseInt(arg));
|
||||
const groupMember = findGroupMemberId(arg, true);
|
||||
if (!groupMember) {
|
||||
toastr.warn(`No group member found using ${isId ? 'id' : 'string'} ${arg}`);
|
||||
return '';
|
||||
}
|
||||
return groupMember[field];
|
||||
}),
|
||||
namedArgumentList: [
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'field',
|
||||
description: 'Whether to retrieve the name, index, id, or avatar.',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
isRequired: true,
|
||||
defaultValue: 'name',
|
||||
enumList: [
|
||||
new SlashCommandEnumValue('name', 'Character name'),
|
||||
new SlashCommandEnumValue('index', 'Group member index'),
|
||||
new SlashCommandEnumValue('avatar', 'Character avatar'),
|
||||
new SlashCommandEnumValue('id', 'Character index'),
|
||||
],
|
||||
}),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
description: 'member index (starts with 0), name, or avatar',
|
||||
typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING],
|
||||
isRequired: true,
|
||||
enumProvider: commonEnumProviders.groupMembers(),
|
||||
}),
|
||||
],
|
||||
helpString: 'Retrieves a group member\'s name, index, id, or avatar.',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'member-disable',
|
||||
callback: disableGroupMemberCallback,
|
||||
@ -842,7 +892,8 @@ export function initDefaultSlashCommands() {
|
||||
helpString: 'Moves a group member down in the group chat list.',
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'peek',
|
||||
name: 'member-peek',
|
||||
aliases: ['peek', 'memberpeek', 'peekmember'],
|
||||
callback: peekCallback,
|
||||
unnamedArgumentList: [
|
||||
SlashCommandArgument.fromProps({
|
||||
@ -1008,7 +1059,6 @@ export function initDefaultSlashCommands() {
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
defaultValue: 'System',
|
||||
enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)],
|
||||
forceEnum: false,
|
||||
}),
|
||||
new SlashCommandNamedArgument(
|
||||
'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false,
|
||||
@ -1902,7 +1952,7 @@ export function initDefaultSlashCommands() {
|
||||
returns: 'uppercase string',
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'string', [ARGUMENT_TYPE.STRING], true, false,
|
||||
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
|
||||
),
|
||||
],
|
||||
helpString: 'Converts the provided string to uppercase.',
|
||||
@ -1914,7 +1964,7 @@ export function initDefaultSlashCommands() {
|
||||
returns: 'lowercase string',
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'string', [ARGUMENT_TYPE.STRING], true, false,
|
||||
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
|
||||
),
|
||||
],
|
||||
helpString: 'Converts the provided string to lowercase.',
|
||||
@ -1934,7 +1984,7 @@ export function initDefaultSlashCommands() {
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'string', [ARGUMENT_TYPE.STRING], true, false,
|
||||
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
|
||||
),
|
||||
],
|
||||
helpString: `
|
||||
@ -1968,8 +2018,8 @@ export function initDefaultSlashCommands() {
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'chat-render',
|
||||
helpString: 'Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.',
|
||||
callback: (args, number) => {
|
||||
showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER);
|
||||
callback: async (args, number) => {
|
||||
await showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER);
|
||||
if (isTrueBoolean(String(args?.scroll ?? ''))) {
|
||||
$('#chat').scrollTop(0);
|
||||
}
|
||||
@ -1998,6 +2048,62 @@ export function initDefaultSlashCommands() {
|
||||
return '';
|
||||
},
|
||||
}));
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'replace',
|
||||
aliases: ['re'],
|
||||
callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
|
||||
if (pattern === '')
|
||||
throw new Error('Argument of \'pattern=\' cannot be empty');
|
||||
switch (mode) {
|
||||
case 'literal':
|
||||
return text.replaceAll(pattern, replacer);
|
||||
case 'regex':
|
||||
return text.replace(regexFromString(pattern), replacer);
|
||||
default:
|
||||
throw new Error('Invalid \'/replace mode=\' argument specified!');
|
||||
}
|
||||
}),
|
||||
returns: 'replaced text',
|
||||
namedArgumentList: [
|
||||
SlashCommandNamedArgument.fromProps({
|
||||
name: 'mode',
|
||||
description: 'Replaces occurrence(s) of a pattern',
|
||||
typeList: [ARGUMENT_TYPE.STRING],
|
||||
defaultValue: 'literal',
|
||||
enumList: ['literal', 'regex'],
|
||||
}),
|
||||
new SlashCommandNamedArgument(
|
||||
'pattern', 'pattern to search with', [ARGUMENT_TYPE.STRING], true, false,
|
||||
),
|
||||
new SlashCommandNamedArgument(
|
||||
'replacer', 'replacement text for matches', [ARGUMENT_TYPE.STRING], false, false, '',
|
||||
),
|
||||
],
|
||||
unnamedArgumentList: [
|
||||
new SlashCommandArgument(
|
||||
'text to affect', [ARGUMENT_TYPE.STRING], true, false,
|
||||
),
|
||||
],
|
||||
helpString: `
|
||||
<div>
|
||||
Replaces text within the provided string based on the pattern.
|
||||
</div>
|
||||
<div>
|
||||
If <code>mode</code> is <code>literal</code> (or omitted), <code>pattern</code> is a literal search string (case-sensitive).<br />
|
||||
If <code>mode</code> is <code>regex</code>, <code>pattern</code> is parsed as an ECMAScript Regular Expression.<br />
|
||||
The <code>replacer</code> replaces based on the <code>pattern</code> in the input text.<br />
|
||||
If <code>replacer</code> is omitted, the replacement(s) will be an empty string.<br />
|
||||
</div>
|
||||
<div>
|
||||
<strong>Example:</strong>
|
||||
<pre>/let x Blue house and blue car || </pre>
|
||||
<pre>/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</pre>
|
||||
<pre>/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</pre>
|
||||
<pre>/replace mode=regex pattern="/blue/i" replacer="red" {{var::x}} | /echo |/# red house and blue car ||</pre>
|
||||
<pre>/replace mode=regex pattern="/blue/gi" replacer="red" {{var::x}} | /echo |/# red house and red car ||</pre>
|
||||
</div>
|
||||
`,
|
||||
}));
|
||||
|
||||
registerVariableCommands();
|
||||
}
|
||||
@ -2814,8 +2920,11 @@ async function addSwipeCallback(args, value) {
|
||||
const newSwipeId = lastMessage.swipes.length - 1;
|
||||
|
||||
if (isTrueBoolean(args.switch)) {
|
||||
// Make sure ad-hoc changes to extras are saved before swiping away
|
||||
syncCurrentSwipeInfoExtras();
|
||||
lastMessage.swipe_id = newSwipeId;
|
||||
lastMessage.mes = lastMessage.swipes[newSwipeId];
|
||||
lastMessage.extra = structuredClone(lastMessage.swipe_info?.[newSwipeId]?.extra ?? lastMessage.extra ?? {});
|
||||
}
|
||||
|
||||
await saveChatConditional();
|
||||
@ -2987,7 +3096,7 @@ function performGroupMemberAction(chid, action) {
|
||||
|
||||
async function disableGroupMemberCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /disable command outside of a group chat.');
|
||||
toastr.warning('Cannot run /member-disable command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3004,7 +3113,7 @@ async function disableGroupMemberCallback(_, arg) {
|
||||
|
||||
async function enableGroupMemberCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /enable command outside of a group chat.');
|
||||
toastr.warning('Cannot run /member-enable command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3021,7 +3130,7 @@ async function enableGroupMemberCallback(_, arg) {
|
||||
|
||||
async function moveGroupMemberUpCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /memberup command outside of a group chat.');
|
||||
toastr.warning('Cannot run /member-up command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3038,7 +3147,7 @@ async function moveGroupMemberUpCallback(_, arg) {
|
||||
|
||||
async function moveGroupMemberDownCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /memberdown command outside of a group chat.');
|
||||
toastr.warning('Cannot run /member-down command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3055,12 +3164,12 @@ async function moveGroupMemberDownCallback(_, arg) {
|
||||
|
||||
async function peekCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /peek command outside of a group chat.');
|
||||
toastr.warning('Cannot run /member-peek command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_group_generating) {
|
||||
toastr.warning('Cannot run /peek command while the group reply is generating.');
|
||||
toastr.warning('Cannot run /member-peek command while the group reply is generating.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3077,12 +3186,7 @@ async function peekCallback(_, arg) {
|
||||
|
||||
async function removeGroupMemberCallback(_, arg) {
|
||||
if (!selected_group) {
|
||||
toastr.warning('Cannot run /memberremove command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_group_generating) {
|
||||
toastr.warning('Cannot run /memberremove command while the group reply is generating.');
|
||||
toastr.warning('Cannot run /member-remove command outside of a group chat.');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -3190,12 +3294,7 @@ function findPersonaByName(name) {
|
||||
}
|
||||
|
||||
async function sendUserMessageCallback(args, text) {
|
||||
if (!text) {
|
||||
toastr.warning('You must specify text to send');
|
||||
return;
|
||||
}
|
||||
|
||||
text = text.trim();
|
||||
text = String(text ?? '').trim();
|
||||
const compact = isTrueBoolean(args?.compact);
|
||||
const bias = extractMessageBias(text);
|
||||
|
||||
@ -3504,24 +3603,18 @@ export function getNameAndAvatarForMessage(character, name = null) {
|
||||
}
|
||||
|
||||
export async function sendMessageAs(args, text) {
|
||||
if (!text) {
|
||||
toastr.warning('You must specify text to send as');
|
||||
return '';
|
||||
}
|
||||
|
||||
let name = args.name?.trim();
|
||||
let mesText;
|
||||
|
||||
if (!name) {
|
||||
const namelessWarningKey = 'sendAsNamelessWarningShown';
|
||||
if (localStorage.getItem(namelessWarningKey) !== 'true') {
|
||||
if (accountStorage.getItem(namelessWarningKey) !== 'true') {
|
||||
toastr.warning('To avoid confusion, please use /sendas name="Character Name"', 'Name defaulted to {{char}}', { timeOut: 10000 });
|
||||
localStorage.setItem(namelessWarningKey, 'true');
|
||||
accountStorage.setItem(namelessWarningKey, 'true');
|
||||
}
|
||||
name = name2;
|
||||
}
|
||||
|
||||
mesText = text.trim();
|
||||
let mesText = String(text ?? '').trim();
|
||||
|
||||
// Requires a regex check after the slash command is pushed to output
|
||||
mesText = getRegexedString(mesText, regex_placement.SLASH_COMMAND, { characterOverride: name });
|
||||
@ -3599,11 +3692,7 @@ export async function sendMessageAs(args, text) {
|
||||
}
|
||||
|
||||
export async function sendNarratorMessage(args, text) {
|
||||
if (!text) {
|
||||
toastr.warning('You must specify text to send');
|
||||
return '';
|
||||
}
|
||||
|
||||
text = String(text ?? '');
|
||||
const name = chat_metadata[NARRATOR_NAME_KEY] || NARRATOR_NAME_DEFAULT;
|
||||
// Messages that do nothing but set bias will be hidden from the context
|
||||
const bias = extractMessageBias(text);
|
||||
@ -3694,18 +3783,13 @@ export async function promptQuietForLoudResponse(who, text) {
|
||||
}
|
||||
|
||||
async function sendCommentMessage(args, text) {
|
||||
if (!text) {
|
||||
toastr.warning('You must specify text to send');
|
||||
return '';
|
||||
}
|
||||
|
||||
const compact = isTrueBoolean(args?.compact);
|
||||
const message = {
|
||||
name: COMMENT_NAME_DEFAULT,
|
||||
is_user: false,
|
||||
is_system: true,
|
||||
send_date: getMessageTimeStamp(),
|
||||
mes: substituteParams(text.trim()),
|
||||
mes: substituteParams(String(text ?? '').trim()),
|
||||
force_avatar: comment_avatar,
|
||||
extra: {
|
||||
type: system_message_types.COMMENT,
|
||||
|
@ -220,6 +220,36 @@ async function* parseStreamData(json) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (typeof json.choices[0].delta.reasoning_content === 'string' && json.choices[0].delta.reasoning_content.length > 0) {
|
||||
for (let j = 0; j < json.choices[0].delta.reasoning_content.length; j++) {
|
||||
const str = json.choices[0].delta.reasoning_content[j];
|
||||
const isLastSymbol = j === json.choices[0].delta.reasoning_content.length - 1;
|
||||
const choiceClone = structuredClone(json.choices[0]);
|
||||
choiceClone.delta.reasoning_content = str;
|
||||
choiceClone.delta.content = isLastSymbol ? choiceClone.delta.content : '';
|
||||
const choices = [choiceClone];
|
||||
yield {
|
||||
data: { ...json, choices },
|
||||
chunk: str,
|
||||
};
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (typeof json.choices[0].delta.reasoning === 'string' && json.choices[0].delta.reasoning.length > 0) {
|
||||
for (let j = 0; j < json.choices[0].delta.reasoning.length; j++) {
|
||||
const str = json.choices[0].delta.reasoning[j];
|
||||
const isLastSymbol = j === json.choices[0].delta.reasoning.length - 1;
|
||||
const choiceClone = structuredClone(json.choices[0]);
|
||||
choiceClone.delta.reasoning = str;
|
||||
choiceClone.delta.content = isLastSymbol ? choiceClone.delta.content : '';
|
||||
const choices = [choiceClone];
|
||||
yield {
|
||||
data: { ...json, choices },
|
||||
chunk: str,
|
||||
};
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (typeof json.choices[0].delta.content === 'string' && json.choices[0].delta.content.length > 0) {
|
||||
for (let j = 0; j < json.choices[0].delta.content.length; j++) {
|
||||
const str = json.choices[0].delta.content[j];
|
||||
|
@ -1,6 +1,7 @@
|
||||
import {
|
||||
activateSendButtons,
|
||||
addOneMessage,
|
||||
appendMediaToMessage,
|
||||
callPopup,
|
||||
characters,
|
||||
chat,
|
||||
@ -12,6 +13,7 @@ import {
|
||||
extension_prompts,
|
||||
Generate,
|
||||
generateQuietPrompt,
|
||||
getCharacters,
|
||||
getCurrentChatId,
|
||||
getRequestHeaders,
|
||||
getThumbnailUrl,
|
||||
@ -40,6 +42,7 @@ import {
|
||||
substituteParamsExtended,
|
||||
this_chid,
|
||||
updateChatMetadata,
|
||||
updateMessageBlock,
|
||||
} from '../script.js';
|
||||
import {
|
||||
extension_settings,
|
||||
@ -55,7 +58,7 @@ import { MacrosParser } from './macros.js';
|
||||
import { oai_settings } from './openai.js';
|
||||
import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
|
||||
import { power_user, registerDebugFunction } from './power-user.js';
|
||||
import { isMobile, shouldSendOnEnter } from './RossAscends-mods.js';
|
||||
import { humanizedDateTime, isMobile, shouldSendOnEnter } from './RossAscends-mods.js';
|
||||
import { ScraperManager } from './scrapers.js';
|
||||
import { executeSlashCommands, executeSlashCommandsWithOptions, registerSlashCommand } from './slash-commands.js';
|
||||
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||
@ -65,10 +68,14 @@ import { tag_map, tags } from './tags.js';
|
||||
import { textgenerationwebui_settings } from './textgen-settings.js';
|
||||
import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';
|
||||
import { ToolManager } from './tool-calling.js';
|
||||
import { timestampToMoment } from './utils.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
import { timestampToMoment, uuidv4 } from './utils.js';
|
||||
import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
|
||||
import { convertCharacterBook, loadWorldInfo, saveWorldInfo, updateWorldInfoList } from './world-info.js';
|
||||
|
||||
export function getContext() {
|
||||
return {
|
||||
accountStorage,
|
||||
chat,
|
||||
characters,
|
||||
groups,
|
||||
@ -167,6 +174,25 @@ export function getContext() {
|
||||
chatCompletionSettings: oai_settings,
|
||||
textCompletionSettings: textgenerationwebui_settings,
|
||||
powerUserSettings: power_user,
|
||||
getCharacters,
|
||||
uuidv4,
|
||||
humanizedDateTime,
|
||||
updateMessageBlock,
|
||||
appendMediaToMessage,
|
||||
variables: {
|
||||
local: {
|
||||
get: getLocalVariable,
|
||||
set: setLocalVariable,
|
||||
},
|
||||
global: {
|
||||
get: getGlobalVariable,
|
||||
set: setGlobalVariable,
|
||||
},
|
||||
},
|
||||
loadWorldInfo,
|
||||
saveWorldInfo,
|
||||
updateWorldInfoList,
|
||||
convertCharacterBook,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
<div>
|
||||
<b data-i18n="Note:">Note:</b> <span data-i18n="this chat is temporary and will be deleted as soon as you leave it.">this chat is temporary and will be deleted as soon as you leave it.</span>
|
||||
<div data-type="assistant_note">
|
||||
<div>
|
||||
<b data-i18n="Note:">Note:</b> <span data-i18n="this chat is temporary and will be deleted as soon as you leave it.">this chat is temporary and will be deleted as soon as you leave it.</span>
|
||||
<span>Click the button to save it as a file.</span>
|
||||
</div>
|
||||
<div class="assistant_note_export menu_button menu_button_icon" title="Export as JSONL">
|
||||
<i class="fa-solid fa-file-export"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<li><span data-i18n="char_import_2">Chub Lorebook (Direct Link or ID)</span><br><span data-i18n="char_import_example">Example:</span> <tt>lorebooks/bartleby/example-lorebook</tt></li>
|
||||
<li><span data-i18n="char_import_3">JanitorAI Character (Direct Link or UUID)</span><br><span data-i18n="char_import_example">Example:</span> <tt>ddd1498a-a370-4136-b138-a8cd9461fdfe_character-aqua-the-useless-goddess</tt></li>
|
||||
<li><span data-i18n="char_import_4">Pygmalion.chat Character (Direct Link or UUID)</span><br><span data-i18n="char_import_example">Example:</span> <tt>a7ca95a1-0c88-4e23-91b3-149db1e78ab9</tt></li>
|
||||
<li><span data-i18n="char_import_5">AICharacterCard.com Character (Direct Link or ID)</span><br><span data-i18n="char_import_example">Example:</span> <tt>AICC/aicharcards/the-game-master</tt></li>
|
||||
<li><span data-i18n="char_import_5">AICharacterCards.com Character (Direct Link or ID)</span><br><span data-i18n="char_import_example">Example:</span> <tt>AICC/aicharcards/the-game-master</tt></li>
|
||||
<li><span data-i18n="char_import_6">Direct PNG Link (refer to</span> <code>config.yaml</code><span data-i18n="char_import_7"> for allowed hosts)</span><br><span data-i18n="char_import_example">Example:</span> <tt>https://files.catbox.moe/notarealfile.png</tt></li>
|
||||
<li><span data-i18n="char_import_8">RisuRealm Character (Direct Link)</span><br><span data-i18n="char_import_example">Example:</span> <tt>https://realm.risuai.net/character/3ca54c71-6efe-46a2-b9d0-4f62df23d712</tt></li>
|
||||
</ul>
|
||||
|
@ -146,5 +146,5 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div id="rawPromptPopup" class="list-group">
|
||||
<div id="rawPromptWrapper" class="tokenItemizingSubclass"></div>
|
||||
<div id="rawPromptWrapper" class="tokenItemizingMaintext"></div>
|
||||
</div>
|
||||
|
@ -6,6 +6,7 @@ import { tokenizers } from './tokenizers.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { POPUP_TYPE, callGenericPopup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
let mancerModels = [];
|
||||
let togetherModels = [];
|
||||
@ -54,6 +55,17 @@ const OPENROUTER_PROVIDERS = [
|
||||
'xAI',
|
||||
'Cloudflare',
|
||||
'SF Compute',
|
||||
'Minimax',
|
||||
'Nineteen',
|
||||
'Liquid',
|
||||
'InferenceNet',
|
||||
'Friendli',
|
||||
'AionLabs',
|
||||
'Alibaba',
|
||||
'Nebius',
|
||||
'Chutes',
|
||||
'Kluster',
|
||||
'Targon',
|
||||
'01.AI',
|
||||
'HuggingFace',
|
||||
'Mancer',
|
||||
@ -330,7 +342,7 @@ export async function loadFeatherlessModels(data) {
|
||||
populateClassSelection(data);
|
||||
|
||||
// Retrieve the stored number of items per page or default to 10
|
||||
const perPage = Number(localStorage.getItem(storageKey)) || 10;
|
||||
const perPage = Number(accountStorage.getItem(storageKey)) || 10;
|
||||
|
||||
// Initialize pagination
|
||||
applyFiltersAndSort();
|
||||
@ -406,7 +418,7 @@ export async function loadFeatherlessModels(data) {
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
const newPerPage = e.target.value;
|
||||
localStorage.setItem('Models_PerPage', newPerPage);
|
||||
accountStorage.setItem(storageKey, newPerPage);
|
||||
setupPagination(models, Number(newPerPage), featherlessCurrentPage); // Use the stored current page number
|
||||
},
|
||||
});
|
||||
@ -507,7 +519,7 @@ export async function loadFeatherlessModels(data) {
|
||||
const currentModelIndex = filteredModels.findIndex(x => x.id === textgen_settings.featherless_model);
|
||||
featherlessCurrentPage = currentModelIndex >= 0 ? (currentModelIndex / perPage) + 1 : 1;
|
||||
|
||||
setupPagination(filteredModels, Number(localStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
|
||||
setupPagination(filteredModels, Number(accountStorage.getItem(storageKey)) || perPage, featherlessCurrentPage);
|
||||
}
|
||||
|
||||
// Required to keep the /model command function
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
setOnlineStatus,
|
||||
substituteParams,
|
||||
} from '../script.js';
|
||||
import { t } from './i18n.js';
|
||||
import { BIAS_CACHE, createNewLogitBiasEntry, displayLogitBias, getLogitBiasListResult } from './logit-bias.js';
|
||||
|
||||
import { power_user, registerDebugFunction } from './power-user.js';
|
||||
@ -172,6 +173,7 @@ const settings = {
|
||||
//truncation_length: 2048,
|
||||
ban_eos_token: false,
|
||||
skip_special_tokens: true,
|
||||
include_reasoning: true,
|
||||
streaming: false,
|
||||
mirostat_mode: 0,
|
||||
mirostat_tau: 5,
|
||||
@ -181,6 +183,8 @@ const settings = {
|
||||
grammar_string: '',
|
||||
json_schema: {},
|
||||
banned_tokens: '',
|
||||
global_banned_tokens: '',
|
||||
send_banned_tokens: true,
|
||||
sampler_priority: OOBA_DEFAULT_ORDER,
|
||||
samplers: LLAMACPP_DEFAULT_ORDER,
|
||||
samplers_priorities: APHRODITE_DEFAULT_ORDER,
|
||||
@ -263,6 +267,7 @@ export const setting_names = [
|
||||
'add_bos_token',
|
||||
'ban_eos_token',
|
||||
'skip_special_tokens',
|
||||
'include_reasoning',
|
||||
'streaming',
|
||||
'mirostat_mode',
|
||||
'mirostat_tau',
|
||||
@ -272,6 +277,8 @@ export const setting_names = [
|
||||
'grammar_string',
|
||||
'json_schema',
|
||||
'banned_tokens',
|
||||
'global_banned_tokens',
|
||||
'send_banned_tokens',
|
||||
'ignore_eos_token',
|
||||
'spaces_between_special_tokens',
|
||||
'speculative_ngram',
|
||||
@ -392,7 +399,7 @@ function getTokenizerForTokenIds() {
|
||||
* @returns {TokenBanResult} String with comma-separated banned token IDs
|
||||
*/
|
||||
function getCustomTokenBans() {
|
||||
if (!settings.banned_tokens && !textgenerationwebui_banned_in_macros.length) {
|
||||
if (!settings.send_banned_tokens || (!settings.banned_tokens && !settings.global_banned_tokens && !textgenerationwebui_banned_in_macros.length)) {
|
||||
return {
|
||||
banned_tokens: '',
|
||||
banned_strings: [],
|
||||
@ -402,8 +409,9 @@ function getCustomTokenBans() {
|
||||
const tokenizer = getTokenizerForTokenIds();
|
||||
const banned_tokens = [];
|
||||
const banned_strings = [];
|
||||
const sequences = settings.banned_tokens
|
||||
.split('\n')
|
||||
const sequences = []
|
||||
.concat(settings.banned_tokens.split('\n'))
|
||||
.concat(settings.global_banned_tokens.split('\n'))
|
||||
.concat(textgenerationwebui_banned_in_macros)
|
||||
.filter(x => x.length > 0)
|
||||
.filter(onlyUnique);
|
||||
@ -450,6 +458,18 @@ function getCustomTokenBans() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the banned strings kill switch toggle.
|
||||
* @param {boolean} isEnabled Kill switch state
|
||||
* @param {string} title Label title
|
||||
*/
|
||||
function toggleBannedStringsKillSwitch(isEnabled, title) {
|
||||
$('#send_banned_tokens_textgenerationwebui').prop('checked', isEnabled);
|
||||
$('#send_banned_tokens_label').find('.menu_button').toggleClass('toggleEnabled', isEnabled).prop('title', title);
|
||||
settings.send_banned_tokens = isEnabled;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates logit bias object from the logit bias list.
|
||||
* @returns {object} Logit bias object
|
||||
@ -501,7 +521,7 @@ export function loadTextGenSettings(data, loadedSettings) {
|
||||
for (const [type, selector] of Object.entries(SERVER_INPUTS)) {
|
||||
const control = $(selector);
|
||||
control.val(settings.server_urls[type] ?? '').on('input', function () {
|
||||
settings.server_urls[type] = String($(this).val());
|
||||
settings.server_urls[type] = String($(this).val()).trim();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
}
|
||||
@ -592,6 +612,14 @@ function sortAphroditeItemsByOrder(orderArray) {
|
||||
}
|
||||
|
||||
jQuery(function () {
|
||||
$('#send_banned_tokens_textgenerationwebui').on('change', function () {
|
||||
const checked = !!$(this).prop('checked');
|
||||
toggleBannedStringsKillSwitch(checked,
|
||||
checked
|
||||
? t`Banned tokens/strings are being sent in the request.`
|
||||
: t`Banned tokens/strings are NOT being sent in the request.`);
|
||||
});
|
||||
|
||||
$('#koboldcpp_order').sortable({
|
||||
delay: getSortableDelay(),
|
||||
stop: function () {
|
||||
@ -740,6 +768,7 @@ jQuery(function () {
|
||||
'add_bos_token_textgenerationwebui': true,
|
||||
'temperature_last_textgenerationwebui': true,
|
||||
'skip_special_tokens_textgenerationwebui': true,
|
||||
'include_reasoning_textgenerationwebui': true,
|
||||
'top_a_textgenerationwebui': 0,
|
||||
'top_a_counter_textgenerationwebui': 0,
|
||||
'mirostat_mode_textgenerationwebui': 0,
|
||||
@ -929,6 +958,10 @@ function setSettingByName(setting, value, trigger) {
|
||||
if (isCheckbox) {
|
||||
const val = Boolean(value);
|
||||
$(`#${setting}_textgenerationwebui`).prop('checked', val);
|
||||
|
||||
if ('send_banned_tokens' === setting) {
|
||||
$(`#${setting}_textgenerationwebui`).trigger('change');
|
||||
}
|
||||
}
|
||||
else if (isText) {
|
||||
$(`#${setting}_textgenerationwebui`).val(value);
|
||||
@ -986,6 +1019,7 @@ export async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
let logprobs = null;
|
||||
const swipes = [];
|
||||
const toolCalls = [];
|
||||
const state = { reasoning: '' };
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) return;
|
||||
@ -1002,9 +1036,10 @@ export async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
const newText = data?.choices?.[0]?.text || data?.content || '';
|
||||
text += newText;
|
||||
logprobs = parseTextgenLogprobs(newText, data.choices?.[0]?.logprobs || data?.completion_probabilities);
|
||||
state.reasoning += data?.choices?.[0]?.reasoning ?? '';
|
||||
}
|
||||
|
||||
yield { text, swipes, logprobs, toolCalls };
|
||||
yield { text, swipes, logprobs, toolCalls, state };
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -1216,7 +1251,7 @@ function replaceMacrosInList(str) {
|
||||
}
|
||||
}
|
||||
|
||||
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
|
||||
export async function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
|
||||
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
|
||||
const dynatemp = isDynamicTemperatureSupported();
|
||||
const { banned_tokens, banned_strings } = getCustomTokenBans();
|
||||
@ -1231,7 +1266,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'top_p': settings.top_p,
|
||||
'typical_p': settings.typical_p,
|
||||
'typical': settings.typical_p,
|
||||
'sampler_seed': settings.seed,
|
||||
'sampler_seed': settings.seed >= 0 ? settings.seed : undefined,
|
||||
'min_p': settings.min_p,
|
||||
'repetition_penalty': settings.rep_pen,
|
||||
'frequency_penalty': settings.freq_pen,
|
||||
@ -1265,6 +1300,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'truncation_length': max_context,
|
||||
'ban_eos_token': settings.ban_eos_token,
|
||||
'skip_special_tokens': settings.skip_special_tokens,
|
||||
'include_reasoning': settings.include_reasoning,
|
||||
'top_a': settings.top_a,
|
||||
'tfs': settings.tfs,
|
||||
'epsilon_cutoff': [OOBA, MANCER].includes(settings.type) ? settings.epsilon_cutoff : undefined,
|
||||
@ -1294,7 +1330,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'temperature_last': (settings.type === OOBA || settings.type === APHRODITE || settings.type == TABBY) ? settings.temperature_last : undefined,
|
||||
'speculative_ngram': settings.type === TABBY ? settings.speculative_ngram : undefined,
|
||||
'do_sample': settings.type === OOBA ? settings.do_sample : undefined,
|
||||
'seed': settings.seed,
|
||||
'seed': settings.seed >= 0 ? settings.seed : undefined,
|
||||
'guidance_scale': cfgValues?.guidanceScale?.value ?? settings.guidance_scale ?? 1,
|
||||
'negative_prompt': cfgValues?.negativePrompt ?? substituteParams(settings.negative_prompt) ?? '',
|
||||
'grammar_string': settings.grammar_string,
|
||||
@ -1443,7 +1479,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
}
|
||||
}
|
||||
|
||||
eventSource.emitAndWait(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
|
||||
await eventSource.emit(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
|
||||
|
||||
// Grammar conflicts with with json_schema
|
||||
if (settings.type === LLAMACPP) {
|
||||
|
@ -679,6 +679,9 @@ export function getTokenizerModel() {
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {
|
||||
if (oai_settings.perplexity_model.includes('sonar-reasoning')) {
|
||||
return deepseekTokenizer;
|
||||
}
|
||||
if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {
|
||||
return llama3Tokenizer;
|
||||
}
|
||||
|
@ -563,6 +563,7 @@ export class ToolManager {
|
||||
chat_completion_sources.OPENROUTER,
|
||||
chat_completion_sources.GROQ,
|
||||
chat_completion_sources.COHERE,
|
||||
chat_completion_sources.DEEPSEEK,
|
||||
];
|
||||
return supportedSources.includes(oai_settings.chat_completion_source);
|
||||
}
|
||||
|
@ -43,6 +43,14 @@ export function isAdmin() {
|
||||
return Boolean(currentUser.admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handle string of the current user.
|
||||
* @returns {string} User handle
|
||||
*/
|
||||
export function getCurrentUserHandle() {
|
||||
return currentUser?.handle || 'default-user';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current user.
|
||||
* @returns {Promise<void>}
|
||||
|
139
public/scripts/util/AccountStorage.js
Normal file
139
public/scripts/util/AccountStorage.js
Normal file
@ -0,0 +1,139 @@
|
||||
import { saveSettingsDebounced } from '../../script.js';
|
||||
|
||||
const MIGRATED_MARKER = '__migrated';
|
||||
const MIGRATABLE_KEYS = [
|
||||
/^AlertRegex_/,
|
||||
/^AlertWI_/,
|
||||
/^Assets_SkipConfirm_/,
|
||||
/^Characters_PerPage$/,
|
||||
/^DataBank_sortField$/,
|
||||
/^DataBank_sortOrder$/,
|
||||
/^extension_update_nag$/,
|
||||
/^extensions_sortByName$/,
|
||||
/^FeatherlessModels_PerPage$/,
|
||||
/^GroupMembers_PerPage$/,
|
||||
/^GroupCandidates_PerPage$/,
|
||||
/^LNavLockOn$/,
|
||||
/^LNavOpened$/,
|
||||
/^mediaWarningShown:/,
|
||||
/^NavLockOn$/,
|
||||
/^NavOpened$/,
|
||||
/^Personas_PerPage$/,
|
||||
/^Personas_GridView$/,
|
||||
/^Proxy_SkipConfirm_/,
|
||||
/^qr--executeShortcut$/,
|
||||
/^qr--syntax$/,
|
||||
/^qr--tabSize$/,
|
||||
/^qr--wrap$/,
|
||||
/^RegenerateWithCtrlEnter$/,
|
||||
/^SelectedNavTab$/,
|
||||
/^sendAsNamelessWarningShown$/,
|
||||
/^StoryStringValidationCache$/,
|
||||
/^WINavOpened$/,
|
||||
/^WI_PerPage$/,
|
||||
/^world_info_sort_order$/,
|
||||
];
|
||||
|
||||
/**
|
||||
* Provides access to account storage of arbitrary key-value pairs.
|
||||
*/
|
||||
class AccountStorage {
|
||||
/**
|
||||
* @type {Record<string, string>} Storage state
|
||||
*/
|
||||
#state = {};
|
||||
|
||||
/**
|
||||
* @type {boolean} If the storage was initialized
|
||||
*/
|
||||
#ready = false;
|
||||
|
||||
#migrateLocalStorage() {
|
||||
const localStorageKeys = [];
|
||||
for (let i = 0; i < globalThis.localStorage.length; i++) {
|
||||
localStorageKeys.push(globalThis.localStorage.key(i));
|
||||
}
|
||||
for (const key of localStorageKeys) {
|
||||
if (MIGRATABLE_KEYS.some(k => k.test(key))) {
|
||||
const value = globalThis.localStorage.getItem(key);
|
||||
this.#state[key] = value;
|
||||
globalThis.localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the account storage.
|
||||
* @param {Object} state Initial state
|
||||
*/
|
||||
init(state) {
|
||||
if (state && typeof state === 'object') {
|
||||
this.#state = Object.assign(this.#state, state);
|
||||
}
|
||||
|
||||
if (!Object.hasOwn(this.#state, MIGRATED_MARKER)) {
|
||||
this.#migrateLocalStorage();
|
||||
this.#state[MIGRATED_MARKER] = '1';
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
this.#ready = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a key in account storage.
|
||||
* @param {string} key Key to get
|
||||
* @returns {string|null} Value of the key
|
||||
*/
|
||||
getItem(key) {
|
||||
if (!this.#ready) {
|
||||
console.warn(`AccountStorage not ready (trying to read from ${key})`);
|
||||
}
|
||||
|
||||
return Object.hasOwn(this.#state, key) ? String(this.#state[key]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a key in account storage.
|
||||
* @param {string} key Key to set
|
||||
* @param {string} value Value to set
|
||||
*/
|
||||
setItem(key, value) {
|
||||
if (!this.#ready) {
|
||||
console.warn(`AccountStorage not ready (trying to write to ${key})`);
|
||||
}
|
||||
|
||||
this.#state[key] = String(value);
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a key from account storage.
|
||||
* @param {string} key Key to remove
|
||||
*/
|
||||
removeItem(key) {
|
||||
if (!this.#ready) {
|
||||
console.warn(`AccountStorage not ready (trying to remove ${key})`);
|
||||
}
|
||||
|
||||
if (!Object.hasOwn(this.#state, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete this.#state[key];
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a snapshot of the storage state.
|
||||
* @returns {Record<string, string>} A deep clone of the storage state
|
||||
*/
|
||||
getState() {
|
||||
return structuredClone(this.#state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account storage instance.
|
||||
*/
|
||||
export const accountStorage = new AccountStorage();
|
@ -1733,17 +1733,17 @@ export function hasAnimation(control) {
|
||||
|
||||
/**
|
||||
* Run an action once an animation on a control ends. If the control has no animation, the action will be executed immediately.
|
||||
*
|
||||
* The action will be executed after the animation ends or after the timeout, whichever comes first.
|
||||
* @param {HTMLElement} control - The control element to listen for animation end event
|
||||
* @param {(control:*?) => void} callback - The callback function to be executed when the animation ends
|
||||
* @param {number} [timeout=500] - The timeout in milliseconds to wait for the animation to end before executing the callback
|
||||
*/
|
||||
export function runAfterAnimation(control, callback) {
|
||||
export function runAfterAnimation(control, callback, timeout = 500) {
|
||||
if (hasAnimation(control)) {
|
||||
const onAnimationEnd = () => {
|
||||
control.removeEventListener('animationend', onAnimationEnd);
|
||||
callback(control);
|
||||
};
|
||||
control.addEventListener('animationend', onAnimationEnd);
|
||||
Promise.race([
|
||||
new Promise((r) => setTimeout(r, timeout)), // Fallback timeout
|
||||
new Promise((r) => control.addEventListener('animationend', r, { once: true })),
|
||||
]).finally(() => callback(control));
|
||||
} else {
|
||||
callback(control);
|
||||
}
|
||||
@ -2059,6 +2059,23 @@ export function toggleDrawer(drawer, expand = true) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or removes a dataset property on an HTMLElement
|
||||
*
|
||||
* Utility function to make it easier to reset dataset properties on null, without them being "null" as value.
|
||||
*
|
||||
* @param {HTMLElement} element - The element to modify
|
||||
* @param {string} name - The name of the dataset property
|
||||
* @param {string|null} value - The value to set - If null, the dataset property will be removed
|
||||
*/
|
||||
export function setDatasetProperty(element, name, value) {
|
||||
if (value === null) {
|
||||
delete element.dataset[name];
|
||||
} else {
|
||||
element.dataset[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchFaFile(name) {
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = await (await fetch(`/css/${name}`)).text();
|
||||
|
@ -19,7 +19,7 @@ import { isFalseBoolean, convertValueType, isTrueBoolean } from './utils.js';
|
||||
|
||||
const MAX_LOOPS = 100;
|
||||
|
||||
function getLocalVariable(name, args = {}) {
|
||||
export function getLocalVariable(name, args = {}) {
|
||||
if (!chat_metadata.variables) {
|
||||
chat_metadata.variables = {};
|
||||
}
|
||||
@ -45,7 +45,7 @@ function getLocalVariable(name, args = {}) {
|
||||
return (localVariable?.trim?.() === '' || isNaN(Number(localVariable))) ? (localVariable || '') : Number(localVariable);
|
||||
}
|
||||
|
||||
function setLocalVariable(name, value, args = {}) {
|
||||
export function setLocalVariable(name, value, args = {}) {
|
||||
if (!name) {
|
||||
throw new Error('Variable name cannot be empty or undefined.');
|
||||
}
|
||||
@ -80,7 +80,7 @@ function setLocalVariable(name, value, args = {}) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function getGlobalVariable(name, args = {}) {
|
||||
export function getGlobalVariable(name, args = {}) {
|
||||
let globalVariable = extension_settings.variables.global[args.key ?? name];
|
||||
if (args.index !== undefined) {
|
||||
try {
|
||||
@ -102,7 +102,7 @@ function getGlobalVariable(name, args = {}) {
|
||||
return (globalVariable?.trim?.() === '' || isNaN(Number(globalVariable))) ? (globalVariable || '') : Number(globalVariable);
|
||||
}
|
||||
|
||||
function setGlobalVariable(name, value, args = {}) {
|
||||
export function setGlobalVariable(name, value, args = {}) {
|
||||
if (!name) {
|
||||
throw new Error('Variable name cannot be empty or undefined.');
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import { callGenericPopup, Popup, POPUP_TYPE } from './popup.js';
|
||||
import { StructuredCloneMap } from './util/StructuredCloneMap.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { t } from './i18n.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
|
||||
export const world_info_insertion_strategy = {
|
||||
evenly: 0,
|
||||
@ -399,6 +400,12 @@ class WorldInfoTimedEffects {
|
||||
*/
|
||||
#entries = [];
|
||||
|
||||
/**
|
||||
* Is this a dry run?
|
||||
* @type {boolean}
|
||||
*/
|
||||
#isDryRun = false;
|
||||
|
||||
/**
|
||||
* Buffer for active timed effects.
|
||||
* @type {Record<TimedEffectType, WIScanEntry[]>}
|
||||
@ -448,10 +455,12 @@ class WorldInfoTimedEffects {
|
||||
* Initialize the timed effects with the given messages.
|
||||
* @param {string[]} chat Array of chat messages
|
||||
* @param {WIScanEntry[]} entries Array of entries
|
||||
* @param {boolean} isDryRun Whether the operation is a dry run
|
||||
*/
|
||||
constructor(chat, entries) {
|
||||
constructor(chat, entries, isDryRun = false) {
|
||||
this.#chat = chat;
|
||||
this.#entries = entries;
|
||||
this.#isDryRun = isDryRun;
|
||||
this.#ensureChatMetadata();
|
||||
}
|
||||
|
||||
@ -583,8 +592,10 @@ class WorldInfoTimedEffects {
|
||||
* Checks for timed effects on chat messages.
|
||||
*/
|
||||
checkTimedEffects() {
|
||||
this.#checkTimedEffectOfType('sticky', this.#buffer.sticky, this.#onEnded.sticky.bind(this));
|
||||
this.#checkTimedEffectOfType('cooldown', this.#buffer.cooldown, this.#onEnded.cooldown.bind(this));
|
||||
if (!this.#isDryRun) {
|
||||
this.#checkTimedEffectOfType('sticky', this.#buffer.sticky, this.#onEnded.sticky.bind(this));
|
||||
this.#checkTimedEffectOfType('cooldown', this.#buffer.cooldown, this.#onEnded.cooldown.bind(this));
|
||||
}
|
||||
this.#checkDelayEffect(this.#buffer.delay);
|
||||
}
|
||||
|
||||
@ -629,6 +640,7 @@ class WorldInfoTimedEffects {
|
||||
* @param {WIScanEntry[]} activatedEntries Entries that were activated
|
||||
*/
|
||||
setTimedEffects(activatedEntries) {
|
||||
if (this.#isDryRun) return;
|
||||
for (const entry of activatedEntries) {
|
||||
this.#setTimedEffectOfType('sticky', entry);
|
||||
this.#setTimedEffectOfType('cooldown', entry);
|
||||
@ -645,6 +657,9 @@ class WorldInfoTimedEffects {
|
||||
if (!this.isValidEffectType(type)) {
|
||||
return;
|
||||
}
|
||||
if (this.#isDryRun && type !== 'delay') {
|
||||
return;
|
||||
}
|
||||
|
||||
const key = this.#getEntryKey(entry);
|
||||
delete chat_metadata.timedWorldInfo[type][key];
|
||||
@ -858,7 +873,7 @@ export function setWorldInfoSettings(settings, data) {
|
||||
$('#world_editor_select').append(`<option value='${i}'>${item}</option>`);
|
||||
});
|
||||
|
||||
$('#world_info_sort_order').val(localStorage.getItem(SORT_ORDER_KEY) || '0');
|
||||
$('#world_info_sort_order').val(accountStorage.getItem(SORT_ORDER_KEY) || '0');
|
||||
$('#world_info').trigger('change');
|
||||
$('#world_editor_select').trigger('change');
|
||||
|
||||
@ -1708,7 +1723,7 @@ export async function loadWorldInfo(name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function updateWorldInfoList() {
|
||||
export async function updateWorldInfoList() {
|
||||
const result = await fetch('/api/settings/get', {
|
||||
method: 'POST',
|
||||
headers: getRequestHeaders(),
|
||||
@ -1933,13 +1948,13 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
|
||||
if (typeof navigation === 'number' && Number(navigation) >= 0) {
|
||||
const data = getDataArray();
|
||||
const uidIndex = data.findIndex(x => x.uid === navigation);
|
||||
const perPage = Number(localStorage.getItem(storageKey)) || perPageDefault;
|
||||
const perPage = Number(accountStorage.getItem(storageKey)) || perPageDefault;
|
||||
startPage = Math.floor(uidIndex / perPage) + 1;
|
||||
}
|
||||
|
||||
$('#world_info_pagination').pagination({
|
||||
dataSource: getDataArray,
|
||||
pageSize: Number(localStorage.getItem(storageKey)) || perPageDefault,
|
||||
pageSize: Number(accountStorage.getItem(storageKey)) || perPageDefault,
|
||||
sizeChangerOptions: [10, 25, 50, 100, 500, 1000],
|
||||
showSizeChanger: true,
|
||||
pageRange: 1,
|
||||
@ -1969,7 +1984,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl
|
||||
worldEntriesList.append(blocks);
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
localStorage.setItem(storageKey, e.target.value);
|
||||
accountStorage.setItem(storageKey, e.target.value);
|
||||
},
|
||||
afterPaging: function () {
|
||||
$('#world_popup_entries_list textarea[name="comment"]').each(function () {
|
||||
@ -2174,7 +2189,7 @@ function verifyWorldInfoSearchSortRule() {
|
||||
// If search got cleared, we make sure to hide the option and go back to the one before
|
||||
if (!searchTerm && !isHidden) {
|
||||
searchOption.attr('hidden', '');
|
||||
selector.val(localStorage.getItem(SORT_ORDER_KEY) || '0');
|
||||
selector.val(accountStorage.getItem(SORT_ORDER_KEY) || '0');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2423,7 +2438,9 @@ export async function getWorldEntry(name, data, entry) {
|
||||
setWIOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]);
|
||||
await saveWorldInfo(name, data);
|
||||
}
|
||||
$(this).toggleClass('empty', !data.entries[uid][entryPropName].length);
|
||||
});
|
||||
input.toggleClass('empty', !entry[entryPropName].length);
|
||||
input.on('select2:select', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data]));
|
||||
input.on('select2:unselect', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data], { remove: true }));
|
||||
|
||||
@ -2458,6 +2475,7 @@ export async function getWorldEntry(name, data, entry) {
|
||||
data.entries[uid][entryPropName] = splitKeywordsAndRegexes(value);
|
||||
setWIOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]);
|
||||
await saveWorldInfo(name, data);
|
||||
$(this).toggleClass('empty', !data.entries[uid][entryPropName].length);
|
||||
}
|
||||
});
|
||||
input.val(entry[entryPropName].join(', ')).trigger('input', { skipReset: true });
|
||||
@ -3435,7 +3453,7 @@ async function _save(name, data) {
|
||||
headers: getRequestHeaders(),
|
||||
body: JSON.stringify({ name: name, data: data }),
|
||||
});
|
||||
eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
|
||||
await eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
|
||||
}
|
||||
|
||||
|
||||
@ -3847,7 +3865,7 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||
const context = getContext();
|
||||
const buffer = new WorldInfoBuffer(chat);
|
||||
|
||||
console.debug(`[WI] --- START WI SCAN (on ${chat.length} messages) ---`);
|
||||
console.debug(`[WI] --- START WI SCAN (on ${chat.length} messages)${isDryRun ? ' (DRY RUN)' : ''} ---`);
|
||||
|
||||
// Combine the chat
|
||||
|
||||
@ -3879,9 +3897,9 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||
|
||||
console.debug(`[WI] Context size: ${maxContext}; WI budget: ${budget} (max% = ${world_info_budget}%, cap = ${world_info_budget_cap})`);
|
||||
const sortedEntries = await getSortedEntries();
|
||||
const timedEffects = new WorldInfoTimedEffects(chat, sortedEntries);
|
||||
const timedEffects = new WorldInfoTimedEffects(chat, sortedEntries, isDryRun);
|
||||
|
||||
!isDryRun && timedEffects.checkTimedEffects();
|
||||
timedEffects.checkTimedEffects();
|
||||
|
||||
if (sortedEntries.length === 0) {
|
||||
return { worldInfoBefore: '', worldInfoAfter: '', WIDepthEntries: [], EMEntries: [], allActivatedEntries: new Set() };
|
||||
@ -4324,12 +4342,12 @@ export async function checkWorldInfo(chat, maxContext, isDryRun) {
|
||||
context.setExtensionPrompt(NOTE_MODULE_NAME, ANWithWI, chat_metadata[metadata_keys.position], chat_metadata[metadata_keys.depth], extension_settings.note.allowWIScan, chat_metadata[metadata_keys.role]);
|
||||
}
|
||||
|
||||
!isDryRun && timedEffects.setTimedEffects(Array.from(allActivatedEntries.values()));
|
||||
timedEffects.setTimedEffects(Array.from(allActivatedEntries.values()));
|
||||
buffer.resetExternalEffects();
|
||||
timedEffects.cleanUp();
|
||||
|
||||
console.log(`[WI] Adding ${allActivatedEntries.size} entries to prompt`, Array.from(allActivatedEntries.values()));
|
||||
console.debug('[WI] --- DONE ---');
|
||||
console.log(`[WI] ${isDryRun ? 'Hypothetically adding' : 'Adding'} ${allActivatedEntries.size} entries to prompt`, Array.from(allActivatedEntries.values()));
|
||||
console.debug(`[WI] --- DONE${isDryRun ? ' (DRY RUN)' : ''} ---`);
|
||||
|
||||
return { worldInfoBefore, worldInfoAfter, EMEntries, WIDepthEntries, allActivatedEntries: new Set(allActivatedEntries.values()) };
|
||||
}
|
||||
@ -4658,7 +4676,7 @@ function convertNovelLorebook(inputObj) {
|
||||
return outputObj;
|
||||
}
|
||||
|
||||
function convertCharacterBook(characterBook) {
|
||||
export function convertCharacterBook(characterBook) {
|
||||
const result = { entries: {}, originalData: characterBook };
|
||||
|
||||
characterBook.entries.forEach((entry, index) => {
|
||||
@ -4736,8 +4754,8 @@ export function checkEmbeddedWorld(chid) {
|
||||
// Only show the alert once per character
|
||||
const checkKey = `AlertWI_${characters[chid].avatar}`;
|
||||
const worldName = characters[chid]?.data?.extensions?.world;
|
||||
if (!localStorage.getItem(checkKey) && (!worldName || !world_names.includes(worldName))) {
|
||||
localStorage.setItem(checkKey, 'true');
|
||||
if (!accountStorage.getItem(checkKey) && (!worldName || !world_names.includes(worldName))) {
|
||||
accountStorage.setItem(checkKey, 'true');
|
||||
|
||||
if (power_user.world_import_dialog) {
|
||||
const html = `<h3>This character has an embedded World/Lorebook.</h3>
|
||||
@ -5181,7 +5199,7 @@ jQuery(() => {
|
||||
$('#world_info_sort_order').on('change', function () {
|
||||
const value = String($(this).find(':selected').val());
|
||||
// Save sort order, but do not save search sorting, as this is a temporary sorting option
|
||||
if (value !== 'search') localStorage.setItem(SORT_ORDER_KEY, value);
|
||||
if (value !== 'search') accountStorage.setItem(SORT_ORDER_KEY, value);
|
||||
updateEditor(navigation_option.none);
|
||||
});
|
||||
|
||||
|
289
public/style.css
289
public/style.css
@ -106,6 +106,8 @@
|
||||
--tool-cool-color-picker-btn-bg: transparent;
|
||||
--tool-cool-color-picker-btn-border-color: transparent;
|
||||
|
||||
--mes-right-spacing: 30px;
|
||||
|
||||
--avatar-base-height: 50px;
|
||||
--avatar-base-width: 50px;
|
||||
--avatar-base-border-radius: 2px;
|
||||
@ -260,6 +262,10 @@ input[type='checkbox']:focus-visible {
|
||||
color: var(--SmartThemeEmColor);
|
||||
}
|
||||
|
||||
.tokenItemizingMaintext {
|
||||
font-size: calc(var(--mainFontSize) * 0.8);
|
||||
}
|
||||
|
||||
.tokenGraph {
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--SmartThemeBorderColor);
|
||||
@ -292,36 +298,44 @@ input[type='checkbox']:focus-visible {
|
||||
filter: grayscale(25%);
|
||||
}
|
||||
|
||||
.mes_text table {
|
||||
.mes_text table,
|
||||
.mes_reasoning table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mes_text td,
|
||||
.mes_text th {
|
||||
.mes_text th,
|
||||
.mes_reasoning td,
|
||||
.mes_reasoning th {
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
.mes_text p {
|
||||
.mes_text p,
|
||||
.mes_reasoning p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mes_text li tt {
|
||||
.mes_text li tt,
|
||||
.mes_reasoning li tt {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.mes_text ol,
|
||||
.mes_text ul {
|
||||
.mes_text ul,
|
||||
.mes_reasoning ol,
|
||||
.mes_reasoning ul {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.mes_text br,
|
||||
.mes_bias br {
|
||||
.mes_bias br,
|
||||
.mes_reasoning br {
|
||||
content: ' ';
|
||||
}
|
||||
|
||||
@ -332,25 +346,150 @@ input[type='checkbox']:focus-visible {
|
||||
color: var(--SmartThemeQuoteColor);
|
||||
}
|
||||
|
||||
.mes_text i,
|
||||
.mes_text em {
|
||||
.mes_reasoning {
|
||||
display: block;
|
||||
border-left: 2px solid var(--SmartThemeEmColor);
|
||||
border-radius: 2px;
|
||||
padding: 5px;
|
||||
padding-left: 14px;
|
||||
margin-bottom: 0.5em;
|
||||
overflow-y: auto;
|
||||
color: var(--SmartThemeEmColor);
|
||||
}
|
||||
|
||||
.mes_text u {
|
||||
.mes_reasoning_details {
|
||||
margin-right: var(--mes-right-spacing);
|
||||
}
|
||||
|
||||
.mes_reasoning_details .mes_reasoning_summary {
|
||||
list-style: none;
|
||||
margin-right: calc(var(--mes-right-spacing) * -1);
|
||||
}
|
||||
|
||||
.mes_reasoning_details summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mes_reasoning *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.mes_reasoning em,
|
||||
.mes_reasoning i,
|
||||
.mes_reasoning u,
|
||||
.mes_reasoning q,
|
||||
.mes_reasoning blockquote {
|
||||
filter: saturate(0.5);
|
||||
}
|
||||
|
||||
.mes_reasoning_details .mes_reasoning em {
|
||||
color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
|
||||
}
|
||||
|
||||
.mes_reasoning_header_block {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.mes_reasoning_header {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
user-select: none;
|
||||
margin: 0.5em 2px;
|
||||
padding: 7px 14px;
|
||||
padding-right: calc(0.7em + 14px);
|
||||
border-radius: 5px;
|
||||
background-color: var(--grey30);
|
||||
font-size: calc(var(--mainFontSize) * 0.9);
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.mes:has(.mes_reasoning:empty) .mes_reasoning_header {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* TWIMC: Remove with custom CSS to show the icon */
|
||||
.mes_reasoning_header>.icon-svg {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@supports not selector(:has(*)) {
|
||||
.mes_reasoning_details {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.mes_bias:empty,
|
||||
.mes:not(.reasoning) .mes_reasoning_details,
|
||||
.mes_reasoning_details:not([open]) .mes_reasoning_actions,
|
||||
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning,
|
||||
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning_header,
|
||||
.mes_reasoning_details:has(.reasoning_edit_textarea) .mes_reasoning_actions .mes_button:not(.edit_button),
|
||||
.mes_reasoning_details:not(:has(.reasoning_edit_textarea)) .mes_reasoning_actions .edit_button,
|
||||
.mes_block:has(.edit_textarea):has(.reasoning_edit_textarea) .mes_reasoning_actions,
|
||||
.mes.reasoning:not([data-reasoning-state="hidden"]) .mes_edit_add_reasoning,
|
||||
.mes:has(.mes_reasoning:empty) .mes_reasoning_arrow,
|
||||
.mes:has(.mes_reasoning:empty) .mes_reasoning,
|
||||
.mes:has(.mes_reasoning:empty) .mes_reasoning_copy {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mes[data-reasoning-state="hidden"] .mes_edit_add_reasoning {
|
||||
background-color: color-mix(in srgb, var(--SmartThemeQuoteColor) 33%, var(--SmartThemeBlurTintColor) 66%);
|
||||
}
|
||||
|
||||
/** If hidden reasoning should not be shown, we hide all blocks that don't have content */
|
||||
#chat:not([data-show-hidden-reasoning="true"]):not(:has(.reasoning_edit_textarea)) .mes:has(.mes_reasoning:empty) .mes_reasoning_details {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mes_reasoning_details .mes_reasoning_arrow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 7px;
|
||||
transform: translateY(-50%);
|
||||
font-size: calc(var(--mainFontSize) * 0.7);
|
||||
width: calc(var(--mainFontSize) * 0.7);
|
||||
height: calc(var(--mainFontSize) * 0.7);
|
||||
}
|
||||
|
||||
.mes_reasoning_details:not([open]) .mes_reasoning_arrow {
|
||||
transform: translateY(-50%) rotate(180deg);
|
||||
}
|
||||
|
||||
.mes_reasoning_summary>span {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.mes_text i,
|
||||
.mes_text em,
|
||||
.mes_reasoning i,
|
||||
.mes_reasoning em {
|
||||
color: var(--SmartThemeEmColor);
|
||||
}
|
||||
|
||||
.mes_text q i,
|
||||
.mes_text q em {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.mes_text u,
|
||||
.mes_reasoning u {
|
||||
color: var(--SmartThemeUnderlineColor);
|
||||
}
|
||||
|
||||
.mes_text q {
|
||||
.mes_text q,
|
||||
.mes_reasoning q {
|
||||
color: var(--SmartThemeQuoteColor);
|
||||
}
|
||||
|
||||
.mes_text font[color] em,
|
||||
.mes_text font[color] i {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.mes_text font[color] q {
|
||||
.mes_text font[color] i,
|
||||
.mes_text font[color] u,
|
||||
.mes_text font[color] q,
|
||||
.mes_reasoning font[color] em,
|
||||
.mes_reasoning font[color] i,
|
||||
.mes_reasoning font[color] u,
|
||||
.mes_reasoning font[color] q {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
@ -358,7 +497,8 @@ input[type='checkbox']:focus-visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.mes_text blockquote {
|
||||
.mes_text blockquote,
|
||||
.mes_reasoning blockquote {
|
||||
border-left: 3px solid var(--SmartThemeQuoteColor);
|
||||
padding-left: 10px;
|
||||
background-color: var(--black30a);
|
||||
@ -368,18 +508,24 @@ input[type='checkbox']:focus-visible {
|
||||
.mes_text strong em,
|
||||
.mes_text strong,
|
||||
.mes_text h2,
|
||||
.mes_text h1 {
|
||||
.mes_text h1,
|
||||
.mes_reasoning strong em,
|
||||
.mes_reasoning strong,
|
||||
.mes_reasoning h2,
|
||||
.mes_reasoning h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.mes_text pre code {
|
||||
.mes_text pre code,
|
||||
.mes_reasoning pre code {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.mes_text img:not(.mes_img) {
|
||||
.mes_text img:not(.mes_img),
|
||||
.mes_reasoning img:not(.mes_img) {
|
||||
max-width: 100%;
|
||||
max-height: var(--doc-height);
|
||||
}
|
||||
@ -1022,8 +1168,8 @@ body .panelControlBar {
|
||||
/*only affects bubblechat to make it sit nicely at the bottom*/
|
||||
}
|
||||
|
||||
.last_mes .mes_text {
|
||||
padding-right: 30px;
|
||||
.last_mes:has(.mes_text:empty):has(.mes_reasoning_details) .mes_reasoning:not(:empty) {
|
||||
margin-bottom: var(--mes-right-spacing);
|
||||
}
|
||||
|
||||
/* SWIPE RELATED STYLES*/
|
||||
@ -1235,14 +1381,19 @@ body.swipeAllMessages .mes:not(.last_mes) .swipes-counter {
|
||||
overflow-y: clip;
|
||||
}
|
||||
|
||||
.mes_text {
|
||||
.mes_text,
|
||||
.mes_reasoning {
|
||||
font-weight: 500;
|
||||
line-height: calc(var(--mainFontSize) + .5rem);
|
||||
max-width: 100%;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.mes_text {
|
||||
padding-left: 0;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
max-width: 100%;
|
||||
overflow-wrap: anywhere;
|
||||
padding-right: var(--mes-right-spacing);
|
||||
}
|
||||
|
||||
br {
|
||||
@ -2728,9 +2879,8 @@ select option:not(:checked) {
|
||||
color: var(--active) !important;
|
||||
}
|
||||
|
||||
#instruct_enabled_label .menu_button:not(.toggleEnabled),
|
||||
#sysprompt_enabled_label .menu_button:not(.toggleEnabled) {
|
||||
color: Red;
|
||||
.menu_button.togglable:not(.toggleEnabled) {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.displayBlock {
|
||||
@ -2913,6 +3063,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
||||
.mes_block .ch_name {
|
||||
max-width: 100%;
|
||||
min-height: 22px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/*applies to both groups and solos chars in the char list*/
|
||||
@ -2921,7 +3072,7 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#rm_print_characters_block .ch_name,
|
||||
.character_name_block .ch_name,
|
||||
.avatar-container .ch_name {
|
||||
flex: 1 1 auto;
|
||||
white-space: nowrap;
|
||||
@ -2931,6 +3082,13 @@ input[type=search]:focus::-webkit-search-cancel-button {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.character_name_block .character_version {
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
text-wrap: nowrap;
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
#rm_print_characters_block .character_name_block> :last-child {
|
||||
flex: 0 100000 auto;
|
||||
/* Force shrinking first */
|
||||
@ -4130,7 +4288,13 @@ input[type="range"]::-webkit-slider-thumb {
|
||||
transition: 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.mes_edit_buttons .menu_button {
|
||||
.mes_reasoning_actions {
|
||||
margin: 0;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.mes_edit_buttons .menu_button,
|
||||
.mes_reasoning_actions .edit_button {
|
||||
opacity: 0.5;
|
||||
padding: 0px;
|
||||
font-size: 1rem;
|
||||
@ -4143,10 +4307,18 @@ input[type="range"]::-webkit-slider-thumb {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mes_reasoning_actions .edit_button {
|
||||
margin-bottom: 0.5em;
|
||||
opacity: 1;
|
||||
filter: brightness(0.7);
|
||||
}
|
||||
|
||||
.mes_reasoning_edit_cancel,
|
||||
.mes_edit_cancel.menu_button {
|
||||
background-color: var(--crimson70a);
|
||||
}
|
||||
|
||||
.mes_reasoning_edit_done,
|
||||
.mes_edit_done.menu_button {
|
||||
background-color: var(--okGreen70a);
|
||||
}
|
||||
@ -4155,6 +4327,7 @@ input[type="range"]::-webkit-slider-thumb {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.reasoning_edit_textarea,
|
||||
.edit_textarea {
|
||||
padding: 5px;
|
||||
margin: 0;
|
||||
@ -4166,6 +4339,14 @@ input[type="range"]::-webkit-slider-thumb {
|
||||
field-sizing: content;
|
||||
}
|
||||
|
||||
body[data-generating="true"] #send_but,
|
||||
body[data-generating="true"] #mes_continue,
|
||||
body[data-generating="true"] #mes_impersonate,
|
||||
body[data-generating="true"] #chat .last_mes .mes_buttons,
|
||||
body[data-generating="true"] #chat .last_mes .mes_reasoning_actions {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#anchor_order {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
@ -4505,23 +4686,6 @@ body .ui-widget-content li:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.typing_indicator {
|
||||
position: sticky;
|
||||
bottom: 10px;
|
||||
margin: 10px;
|
||||
opacity: 0.85;
|
||||
text-shadow: 0px 0px calc(var(--shadowWidth) * 1px) var(--SmartThemeShadowColor);
|
||||
order: 9999;
|
||||
}
|
||||
|
||||
.typing_indicator:after {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
animation: ellipsis steps(4, end) 1500ms infinite;
|
||||
content: "";
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
#group_avatar_preview .missing-avatar {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
@ -5610,11 +5774,13 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#SystemPromptColumn summary,
|
||||
#InstructSequencesColumn summary {
|
||||
font-size: 0.95em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#SystemPromptColumn details,
|
||||
#InstructSequencesColumn details:not(:last-of-type) {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
@ -5643,6 +5809,7 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
|
||||
.model-card .details-container {
|
||||
text-align: right;
|
||||
line-height: 0.9;
|
||||
}
|
||||
|
||||
.model-card:hover {
|
||||
@ -5665,7 +5832,7 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
}
|
||||
|
||||
.model-title {
|
||||
font-size: 13px;
|
||||
font-size: calc(var(--mainFontSize) * 0.95);
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
}
|
||||
@ -5681,7 +5848,7 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
.model-class,
|
||||
.model-context-length,
|
||||
.model-date-added {
|
||||
font-size: 10px;
|
||||
font-size: calc(var(--mainFontSize) * 0.75);
|
||||
}
|
||||
|
||||
.model-class,
|
||||
@ -5763,3 +5930,29 @@ body:not(.movingUI) .drawer-content.maximized {
|
||||
.alternate_greetings_list {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.mes_text div[data-type="assistant_note"]:has(.assistant_note_export) {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.mes_text div[data-type="assistant_note"]:has(.assistant_note_export)>div:not(.assistant_note_export) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.oneline-dropdown label {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 5px;
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.oneline-dropdown select {
|
||||
min-width: fit-content;
|
||||
width: 40%;
|
||||
}
|
||||
|
329
server.js
329
server.js
@ -4,6 +4,7 @@
|
||||
import fs from 'node:fs';
|
||||
import http from 'node:http';
|
||||
import https from 'node:https';
|
||||
import os from 'os';
|
||||
import path from 'node:path';
|
||||
import util from 'node:util';
|
||||
import net from 'node:net';
|
||||
@ -18,10 +19,9 @@ import { hideBin } from 'yargs/helpers';
|
||||
|
||||
// express/server related library imports
|
||||
import cors from 'cors';
|
||||
import { doubleCsrf } from 'csrf-csrf';
|
||||
import { csrfSync } from 'csrf-sync';
|
||||
import express from 'express';
|
||||
import compression from 'compression';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import cookieSession from 'cookie-session';
|
||||
import multer from 'multer';
|
||||
import responseTime from 'response-time';
|
||||
@ -30,6 +30,7 @@ import bodyParser from 'body-parser';
|
||||
|
||||
// net related library imports
|
||||
import fetch from 'node-fetch';
|
||||
import ipRegex from 'ip-regex';
|
||||
|
||||
// Unrestrict console logs display limit
|
||||
util.inspect.defaultOptions.maxArrayLength = null;
|
||||
@ -40,7 +41,6 @@ util.inspect.defaultOptions.depth = 4;
|
||||
import { loadPlugins } from './src/plugin-loader.js';
|
||||
import {
|
||||
initUserStorage,
|
||||
getCsrfSecret,
|
||||
getCookieSecret,
|
||||
getCookieSessionName,
|
||||
getAllEnabledUsers,
|
||||
@ -60,6 +60,7 @@ import basicAuthMiddleware from './src/middleware/basicAuth.js';
|
||||
import whitelistMiddleware from './src/middleware/whitelist.js';
|
||||
import multerMonkeyPatch from './src/middleware/multerMonkeyPatch.js';
|
||||
import initRequestProxy from './src/request-proxy.js';
|
||||
import getCacheBusterMiddleware from './src/middleware/cacheBuster.js';
|
||||
import {
|
||||
getVersion,
|
||||
getConfigValue,
|
||||
@ -67,6 +68,11 @@ import {
|
||||
forwardFetchResponse,
|
||||
removeColorFormatting,
|
||||
getSeparator,
|
||||
stringToBool,
|
||||
urlHostnameToIPv6,
|
||||
canResolve,
|
||||
safeReadFileSync,
|
||||
setupLogLevel,
|
||||
} from './src/util.js';
|
||||
import { UPLOADS_DIRECTORY } from './src/constants.js';
|
||||
import { ensureThumbnailCache } from './src/endpoints/thumbnails.js';
|
||||
@ -126,6 +132,8 @@ if (process.versions && process.versions.node && process.versions.node.match(/20
|
||||
const DEFAULT_PORT = 8000;
|
||||
const DEFAULT_AUTORUN = false;
|
||||
const DEFAULT_LISTEN = false;
|
||||
const DEFAULT_LISTEN_ADDRESS_IPV6 = '[::]';
|
||||
const DEFAULT_LISTEN_ADDRESS_IPV4 = '0.0.0.0';
|
||||
const DEFAULT_CORS_PROXY = false;
|
||||
const DEFAULT_WHITELIST = true;
|
||||
const DEFAULT_ACCOUNTS = false;
|
||||
@ -150,11 +158,11 @@ const DEFAULT_PROXY_BYPASS = [];
|
||||
const cliArguments = yargs(hideBin(process.argv))
|
||||
.usage('Usage: <your-start-script> <command> [options]')
|
||||
.option('enableIPv6', {
|
||||
type: 'boolean',
|
||||
type: 'string',
|
||||
default: null,
|
||||
describe: `Enables IPv6.\n[config default: ${DEFAULT_ENABLE_IPV6}]`,
|
||||
}).option('enableIPv4', {
|
||||
type: 'boolean',
|
||||
type: 'string',
|
||||
default: null,
|
||||
describe: `Enables IPv4.\n[config default: ${DEFAULT_ENABLE_IPV4}]`,
|
||||
}).option('port', {
|
||||
@ -181,6 +189,14 @@ const cliArguments = yargs(hideBin(process.argv))
|
||||
type: 'boolean',
|
||||
default: null,
|
||||
describe: `SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If false, will limit it only to internal localhost (127.0.0.1).\nIf not provided falls back to yaml config 'listen'.\n[config default: ${DEFAULT_LISTEN}]`,
|
||||
}).option('listenAddressIPv6', {
|
||||
type: 'string',
|
||||
default: null,
|
||||
describe: 'Set SillyTavern to listen to a specific IPv6 address. If not set, it will fallback to listen to all.\n[config default: [::] ]',
|
||||
}).option('listenAddressIPv4', {
|
||||
type: 'string',
|
||||
default: null,
|
||||
describe: 'Set SillyTavern to listen to a specific IPv4 address. If not set, it will fallback to listen to all.\n[config default: 0.0.0.0 ]',
|
||||
}).option('corsProxy', {
|
||||
type: 'boolean',
|
||||
default: null,
|
||||
@ -243,27 +259,46 @@ app.use(helmet({
|
||||
app.use(compression());
|
||||
app.use(responseTime());
|
||||
|
||||
|
||||
/** @type {number} */
|
||||
const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT);
|
||||
/** @type {boolean} */
|
||||
const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl;
|
||||
/** @type {boolean} */
|
||||
const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN);
|
||||
/** @type {string} */
|
||||
const listenAddressIPv6 = cliArguments.listenAddressIPv6 ?? getConfigValue('listenAddress.ipv6', DEFAULT_LISTEN_ADDRESS_IPV6);
|
||||
/** @type {string} */
|
||||
const listenAddressIPv4 = cliArguments.listenAddressIPv4 ?? getConfigValue('listenAddress.ipv4', DEFAULT_LISTEN_ADDRESS_IPV4);
|
||||
/** @type {boolean} */
|
||||
const enableCorsProxy = cliArguments.corsProxy ?? getConfigValue('enableCorsProxy', DEFAULT_CORS_PROXY);
|
||||
const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode', DEFAULT_WHITELIST);
|
||||
/** @type {string} */
|
||||
const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data');
|
||||
/** @type {boolean} */
|
||||
const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED);
|
||||
const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH);
|
||||
const perUserBasicAuth = getConfigValue('perUserBasicAuth', DEFAULT_PER_USER_BASIC_AUTH);
|
||||
/** @type {boolean} */
|
||||
const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS);
|
||||
|
||||
const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY);
|
||||
|
||||
const enableIPv6 = cliArguments.enableIPv6 ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);
|
||||
const enableIPv4 = cliArguments.enableIPv4 ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);
|
||||
|
||||
/** @type {boolean | "auto"} */
|
||||
let enableIPv6 = stringToBool(cliArguments.enableIPv6) ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);
|
||||
/** @type {boolean | "auto"} */
|
||||
let enableIPv4 = stringToBool(cliArguments.enableIPv4) ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);
|
||||
|
||||
/** @type {string} */
|
||||
const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME);
|
||||
/** @type {number} */
|
||||
const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT);
|
||||
|
||||
/** @type {boolean} */
|
||||
const dnsPreferIPv6 = cliArguments.dnsPreferIPv6 ?? getConfigValue('dnsPreferIPv6', DEFAULT_PREFER_IPV6);
|
||||
|
||||
/** @type {boolean} */
|
||||
const avoidLocalhost = cliArguments.avoidLocalhost ?? getConfigValue('avoidLocalhost', DEFAULT_AVOID_LOCALHOST);
|
||||
|
||||
const proxyEnabled = cliArguments.requestProxyEnabled ?? getConfigValue('requestProxy.enabled', DEFAULT_PROXY_ENABLED);
|
||||
@ -280,7 +315,19 @@ if (dnsPreferIPv6) {
|
||||
console.log('Preferring IPv4 for DNS resolution');
|
||||
}
|
||||
|
||||
if (!enableIPv6 && !enableIPv4) {
|
||||
|
||||
const ipOptions = [true, 'auto', false];
|
||||
|
||||
if (!ipOptions.includes(enableIPv6)) {
|
||||
console.warn(color.red('`protocol: ipv6` option invalid'), '\n use:', ipOptions, '\n setting to:', DEFAULT_ENABLE_IPV6);
|
||||
enableIPv6 = DEFAULT_ENABLE_IPV6;
|
||||
}
|
||||
if (!ipOptions.includes(enableIPv4)) {
|
||||
console.warn(color.red('`protocol: ipv4` option invalid'), '\n use:', ipOptions, '\n setting to:', DEFAULT_ENABLE_IPV4);
|
||||
enableIPv4 = DEFAULT_ENABLE_IPV4;
|
||||
}
|
||||
|
||||
if (enableIPv6 === false && enableIPv4 === false) {
|
||||
console.error('error: You can\'t disable all internet protocols: at least IPv6 or IPv4 must be enabled.');
|
||||
process.exit(1);
|
||||
}
|
||||
@ -347,8 +394,8 @@ if (enableCorsProxy) {
|
||||
}
|
||||
|
||||
function getSessionCookieAge() {
|
||||
// Defaults to 24 hours in seconds if not set
|
||||
const configValue = getConfigValue('sessionTimeout', 24 * 60 * 60);
|
||||
// Defaults to "no expiration" if not set
|
||||
const configValue = getConfigValue('sessionTimeout', -1);
|
||||
|
||||
// Convert to milliseconds
|
||||
if (configValue > 0) {
|
||||
@ -365,6 +412,55 @@ function getSessionCookieAge() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the network interfaces to determine the presence of IPv6 and IPv4 addresses.
|
||||
*
|
||||
* @returns {Promise<[boolean, boolean, boolean, boolean]>} A promise that resolves to an array containing:
|
||||
* - [0]: `hasIPv6` (boolean) - Whether the computer has any IPv6 address, including (`::1`).
|
||||
* - [1]: `hasIPv4` (boolean) - Whether the computer has any IPv4 address, including (`127.0.0.1`).
|
||||
* - [2]: `hasIPv6Local` (boolean) - Whether the computer has local IPv6 address (`::1`).
|
||||
* - [3]: `hasIPv4Local` (boolean) - Whether the computer has local IPv4 address (`127.0.0.1`).
|
||||
*/
|
||||
async function getHasIP() {
|
||||
let hasIPv6 = false;
|
||||
let hasIPv6Local = false;
|
||||
|
||||
let hasIPv4 = false;
|
||||
let hasIPv4Local = false;
|
||||
|
||||
const interfaces = os.networkInterfaces();
|
||||
|
||||
for (const iface of Object.values(interfaces)) {
|
||||
if (iface === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const info of iface) {
|
||||
if (info.family === 'IPv6') {
|
||||
hasIPv6 = true;
|
||||
if (info.address === '::1') {
|
||||
hasIPv6Local = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (info.family === 'IPv4') {
|
||||
hasIPv4 = true;
|
||||
if (info.address === '127.0.0.1') {
|
||||
hasIPv4Local = true;
|
||||
}
|
||||
}
|
||||
if (hasIPv6 && hasIPv4 && hasIPv6Local && hasIPv4Local) break;
|
||||
}
|
||||
if (hasIPv6 && hasIPv4 && hasIPv6Local && hasIPv4Local) break;
|
||||
}
|
||||
return [
|
||||
hasIPv6,
|
||||
hasIPv4,
|
||||
hasIPv6Local,
|
||||
hasIPv4Local,
|
||||
];
|
||||
}
|
||||
|
||||
app.use(cookieSession({
|
||||
name: getCookieSessionName(),
|
||||
sameSite: 'strict',
|
||||
@ -377,27 +473,38 @@ app.use(setUserDataMiddleware);
|
||||
|
||||
// CSRF Protection //
|
||||
if (!disableCsrf) {
|
||||
const COOKIES_SECRET = getCookieSecret();
|
||||
|
||||
const { generateToken, doubleCsrfProtection } = doubleCsrf({
|
||||
getSecret: getCsrfSecret,
|
||||
cookieName: 'X-CSRF-Token',
|
||||
cookieOptions: {
|
||||
sameSite: 'strict',
|
||||
secure: false,
|
||||
const csrfSyncProtection = csrfSync({
|
||||
getTokenFromState: (req) => {
|
||||
if (!req.session) {
|
||||
console.error('(CSRF error) getTokenFromState: Session object not initialized');
|
||||
return;
|
||||
}
|
||||
return req.session.csrfToken;
|
||||
},
|
||||
size: 64,
|
||||
getTokenFromRequest: (req) => req.headers['x-csrf-token'],
|
||||
getTokenFromRequest: (req) => {
|
||||
return req.headers['x-csrf-token']?.toString();
|
||||
},
|
||||
storeTokenInState: (req, token) => {
|
||||
if (!req.session) {
|
||||
console.error('(CSRF error) storeTokenInState: Session object not initialized');
|
||||
return;
|
||||
}
|
||||
req.session.csrfToken = token;
|
||||
},
|
||||
size: 32,
|
||||
});
|
||||
|
||||
app.get('/csrf-token', (req, res) => {
|
||||
res.json({
|
||||
'token': generateToken(res, req),
|
||||
'token': csrfSyncProtection.generateToken(req),
|
||||
});
|
||||
});
|
||||
|
||||
app.use(cookieParser(COOKIES_SECRET));
|
||||
app.use(doubleCsrfProtection);
|
||||
// Customize the error message
|
||||
csrfSyncProtection.invalidCsrfTokenError.message = color.red('Invalid CSRF token. Please refresh the page and try again.');
|
||||
csrfSyncProtection.invalidCsrfTokenError.stack = undefined;
|
||||
|
||||
app.use(csrfSyncProtection.csrfSynchronisedProtection);
|
||||
} else {
|
||||
console.warn('\nCSRF protection is disabled. This will make your server vulnerable to CSRF attacks.\n');
|
||||
app.get('/csrf-token', (req, res) => {
|
||||
@ -409,7 +516,7 @@ if (!disableCsrf) {
|
||||
|
||||
// Static files
|
||||
// Host index page
|
||||
app.get('/', (request, response) => {
|
||||
app.get('/', getCacheBusterMiddleware(), (request, response) => {
|
||||
if (shouldRedirectToLogin(request)) {
|
||||
const query = request.url.split('?')[1];
|
||||
const redirectUrl = query ? `/login?${query}` : '/login';
|
||||
@ -617,13 +724,13 @@ app.use('/api/azure', azureRouter);
|
||||
|
||||
const tavernUrlV6 = new URL(
|
||||
(cliArguments.ssl ? 'https://' : 'http://') +
|
||||
(listen ? '[::]' : '[::1]') +
|
||||
(listen ? (ipRegex.v6({ exact: true }).test(listenAddressIPv6) ? listenAddressIPv6 : '[::]') : '[::1]') +
|
||||
(':' + server_port),
|
||||
);
|
||||
|
||||
const tavernUrl = new URL(
|
||||
(cliArguments.ssl ? 'https://' : 'http://') +
|
||||
(listen ? '0.0.0.0' : '127.0.0.1') +
|
||||
(listen ? (ipRegex.v4({ exact: true }).test(listenAddressIPv4) ? listenAddressIPv4 : '0.0.0.0') : '127.0.0.1') +
|
||||
(':' + server_port),
|
||||
);
|
||||
|
||||
@ -683,20 +790,23 @@ const preSetupTasks = async function () {
|
||||
|
||||
/**
|
||||
* Gets the hostname to use for autorun in the browser.
|
||||
* @returns {string} The hostname to use for autorun
|
||||
* @param {boolean} useIPv6 If use IPv6
|
||||
* @param {boolean} useIPv4 If use IPv4
|
||||
* @returns Promise<string> The hostname to use for autorun
|
||||
*/
|
||||
function getAutorunHostname() {
|
||||
async function getAutorunHostname(useIPv6, useIPv4) {
|
||||
if (autorunHostname === 'auto') {
|
||||
if (enableIPv6 && enableIPv4) {
|
||||
if (avoidLocalhost) return '[::1]';
|
||||
return 'localhost';
|
||||
let localhostResolve = await canResolve('localhost', useIPv6, useIPv4);
|
||||
|
||||
if (useIPv6 && useIPv4) {
|
||||
return (avoidLocalhost || !localhostResolve) ? '[::1]' : 'localhost';
|
||||
}
|
||||
|
||||
if (enableIPv6) {
|
||||
if (useIPv6) {
|
||||
return '[::1]';
|
||||
}
|
||||
|
||||
if (enableIPv4) {
|
||||
if (useIPv4) {
|
||||
return '127.0.0.1';
|
||||
}
|
||||
}
|
||||
@ -708,11 +818,13 @@ function getAutorunHostname() {
|
||||
* Tasks that need to be run after the server starts listening.
|
||||
* @param {boolean} v6Failed If the server failed to start on IPv6
|
||||
* @param {boolean} v4Failed If the server failed to start on IPv4
|
||||
* @param {boolean} useIPv6 If the server is using IPv6
|
||||
* @param {boolean} useIPv4 If the server is using IPv4
|
||||
*/
|
||||
const postSetupTasks = async function (v6Failed, v4Failed) {
|
||||
const postSetupTasks = async function (v6Failed, v4Failed, useIPv6, useIPv4) {
|
||||
const autorunUrl = new URL(
|
||||
(cliArguments.ssl ? 'https://' : 'http://') +
|
||||
(getAutorunHostname()) +
|
||||
(await getAutorunHostname(useIPv6, useIPv4)) +
|
||||
(':') +
|
||||
((autorunPortOverride >= 0) ? autorunPortOverride : server_port),
|
||||
);
|
||||
@ -725,36 +837,48 @@ const postSetupTasks = async function (v6Failed, v4Failed) {
|
||||
|
||||
let logListen = 'SillyTavern is listening on';
|
||||
|
||||
if (enableIPv6 && !v6Failed) {
|
||||
logListen += color.green(' IPv6: ' + tavernUrlV6.host);
|
||||
if (useIPv6 && !v6Failed) {
|
||||
logListen += color.green(
|
||||
' IPv6: ' + tavernUrlV6.host,
|
||||
);
|
||||
}
|
||||
|
||||
if (enableIPv4 && !v4Failed) {
|
||||
logListen += color.green(' IPv4: ' + tavernUrl.host);
|
||||
if (useIPv4 && !v4Failed) {
|
||||
logListen += color.green(
|
||||
' IPv4: ' + tavernUrl.host,
|
||||
);
|
||||
}
|
||||
|
||||
const goToLog = 'Go to: ' + color.blue(autorunUrl) + ' to open SillyTavern';
|
||||
const plainGoToLog = removeColorFormatting(goToLog);
|
||||
|
||||
console.log(logListen);
|
||||
if (listen) {
|
||||
console.log();
|
||||
console.log('To limit connections to internal localhost only ([::1] or 127.0.0.1), change the setting in config.yaml to "listen: false".');
|
||||
console.log('Check the "access.log" file in the SillyTavern directory to inspect incoming connections.');
|
||||
}
|
||||
console.log('\n' + getSeparator(plainGoToLog.length) + '\n');
|
||||
console.log(goToLog);
|
||||
console.log('\n' + getSeparator(plainGoToLog.length) + '\n');
|
||||
|
||||
if (listen) {
|
||||
console.log('[::] or 0.0.0.0 means SillyTavern is listening on all network interfaces (Wi-Fi, LAN, localhost). If you want to limit it only to internal localhost ([::1] or 127.0.0.1), change the setting in config.yaml to "listen: false". Check "access.log" file in the SillyTavern directory if you want to inspect incoming connections.\n');
|
||||
}
|
||||
|
||||
if (basicAuthMode) {
|
||||
if (perUserBasicAuth && !enableAccounts) {
|
||||
console.error(color.red('Per-user basic authentication is enabled, but user accounts are disabled. This configuration may be insecure.'));
|
||||
console.error(color.red(
|
||||
'Per-user basic authentication is enabled, but user accounts are disabled. This configuration may be insecure.',
|
||||
));
|
||||
} else if (!perUserBasicAuth) {
|
||||
const basicAuthUser = getConfigValue('basicAuthUser', {});
|
||||
if (!basicAuthUser?.username || !basicAuthUser?.password) {
|
||||
console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!'));
|
||||
console.warn(color.yellow(
|
||||
'Basic Authentication is enabled, but username or password is not set or empty!',
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupLogLevel();
|
||||
};
|
||||
|
||||
/**
|
||||
@ -804,14 +928,16 @@ function logSecurityAlert(message) {
|
||||
* Handles the case where the server failed to start on one or both protocols.
|
||||
* @param {boolean} v6Failed If the server failed to start on IPv6
|
||||
* @param {boolean} v4Failed If the server failed to start on IPv4
|
||||
* @param {boolean} useIPv6 If use IPv6
|
||||
* @param {boolean} useIPv4 If use IPv4
|
||||
*/
|
||||
function handleServerListenFail(v6Failed, v4Failed) {
|
||||
if (v6Failed && !enableIPv4) {
|
||||
function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
|
||||
if (v6Failed && !useIPv4) {
|
||||
console.error(color.red('fatal error: Failed to start server on IPv6 and IPv4 disabled'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (v4Failed && !enableIPv6) {
|
||||
if (v4Failed && !useIPv6) {
|
||||
console.error(color.red('fatal error: Failed to start server on IPv4 and IPv6 disabled'));
|
||||
process.exit(1);
|
||||
}
|
||||
@ -825,10 +951,11 @@ function handleServerListenFail(v6Failed, v4Failed) {
|
||||
/**
|
||||
* Creates an HTTPS server.
|
||||
* @param {URL} url The URL to listen on
|
||||
* @param {number} ipVersion the ip version to use
|
||||
* @returns {Promise<void>} A promise that resolves when the server is listening
|
||||
* @throws {Error} If the server fails to start
|
||||
*/
|
||||
function createHttpsServer(url) {
|
||||
function createHttpsServer(url, ipVersion) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = https.createServer(
|
||||
{
|
||||
@ -837,34 +964,56 @@ function createHttpsServer(url) {
|
||||
}, app);
|
||||
server.on('error', reject);
|
||||
server.on('listening', resolve);
|
||||
server.listen(Number(url.port || 443), url.hostname);
|
||||
|
||||
let host = url.hostname;
|
||||
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
|
||||
server.listen({
|
||||
host: host,
|
||||
port: Number(url.port || 443),
|
||||
// see https://nodejs.org/api/net.html#serverlisten for why ipv6Only is used
|
||||
ipv6Only: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an HTTP server.
|
||||
* @param {URL} url The URL to listen on
|
||||
* @param {number} ipVersion the ip version to use
|
||||
* @returns {Promise<void>} A promise that resolves when the server is listening
|
||||
* @throws {Error} If the server fails to start
|
||||
*/
|
||||
function createHttpServer(url) {
|
||||
function createHttpServer(url, ipVersion) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = http.createServer(app);
|
||||
server.on('error', reject);
|
||||
server.on('listening', resolve);
|
||||
server.listen(Number(url.port || 80), url.hostname);
|
||||
|
||||
let host = url.hostname;
|
||||
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
|
||||
server.listen({
|
||||
host: host,
|
||||
port: Number(url.port || 80),
|
||||
// see https://nodejs.org/api/net.html#serverlisten for why ipv6Only is used
|
||||
ipv6Only: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function startHTTPorHTTPS() {
|
||||
/**
|
||||
* Starts the server using http or https depending on config
|
||||
* @param {boolean} useIPv6 If use IPv6
|
||||
* @param {boolean} useIPv4 If use IPv4
|
||||
*/
|
||||
async function startHTTPorHTTPS(useIPv6, useIPv4) {
|
||||
let v6Failed = false;
|
||||
let v4Failed = false;
|
||||
|
||||
const createFunc = cliArguments.ssl ? createHttpsServer : createHttpServer;
|
||||
|
||||
if (enableIPv6) {
|
||||
if (useIPv6) {
|
||||
try {
|
||||
await createFunc(tavernUrlV6);
|
||||
await createFunc(tavernUrlV6, 6);
|
||||
} catch (error) {
|
||||
console.error('non-fatal error: failed to start server on IPv6');
|
||||
console.error(error);
|
||||
@ -873,9 +1022,9 @@ async function startHTTPorHTTPS() {
|
||||
}
|
||||
}
|
||||
|
||||
if (enableIPv4) {
|
||||
if (useIPv4) {
|
||||
try {
|
||||
await createFunc(tavernUrl);
|
||||
await createFunc(tavernUrl, 4);
|
||||
} catch (error) {
|
||||
console.error('non-fatal error: failed to start server on IPv4');
|
||||
console.error(error);
|
||||
@ -888,10 +1037,59 @@ async function startHTTPorHTTPS() {
|
||||
}
|
||||
|
||||
async function startServer() {
|
||||
const [v6Failed, v4Failed] = await startHTTPorHTTPS();
|
||||
let useIPv6 = (enableIPv6 === true);
|
||||
let useIPv4 = (enableIPv4 === true);
|
||||
|
||||
handleServerListenFail(v6Failed, v4Failed);
|
||||
postSetupTasks(v6Failed, v4Failed);
|
||||
let hasIPv6 = false,
|
||||
hasIPv4 = false,
|
||||
hasIPv6Local = false,
|
||||
hasIPv4Local = false,
|
||||
hasIPv6Any = false,
|
||||
hasIPv4Any = false;
|
||||
|
||||
if (enableIPv6 === 'auto' || enableIPv4 === 'auto') {
|
||||
[hasIPv6Any, hasIPv4Any, hasIPv6Local, hasIPv4Local] = await getHasIP();
|
||||
|
||||
hasIPv6 = listen ? hasIPv6Any : hasIPv6Local;
|
||||
if (enableIPv6 === 'auto') {
|
||||
useIPv6 = hasIPv6;
|
||||
}
|
||||
if (hasIPv6) {
|
||||
if (useIPv6) {
|
||||
console.log(color.green('IPv6 support detected'));
|
||||
} else {
|
||||
console.log('IPv6 support detected (but disabled)');
|
||||
}
|
||||
}
|
||||
|
||||
hasIPv4 = listen ? hasIPv4Any : hasIPv4Local;
|
||||
if (enableIPv4 === 'auto') {
|
||||
useIPv4 = hasIPv4;
|
||||
}
|
||||
if (hasIPv4) {
|
||||
if (useIPv4) {
|
||||
console.log(color.green('IPv4 support detected'));
|
||||
} else {
|
||||
console.log('IPv4 support detected (but disabled)');
|
||||
}
|
||||
}
|
||||
|
||||
if (enableIPv6 === 'auto' && enableIPv4 === 'auto') {
|
||||
if (!hasIPv6 && !hasIPv4) {
|
||||
console.error('Both IPv6 and IPv4 are not detected');
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!useIPv6 && !useIPv4) {
|
||||
console.error('Both IPv6 and IPv4 are disabled,\nP.S. you should never see this error, at least at one point it was checked for before this, with the rest of the config options');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [v6Failed, v4Failed] = await startHTTPorHTTPS(useIPv6, useIPv4);
|
||||
handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4);
|
||||
postSetupTasks(v6Failed, v4Failed, useIPv6, useIPv4);
|
||||
}
|
||||
|
||||
async function verifySecuritySettings() {
|
||||
@ -901,7 +1099,7 @@ async function verifySecuritySettings() {
|
||||
}
|
||||
|
||||
if (!enableAccounts) {
|
||||
logSecurityAlert('Your SillyTavern is currently insecurely open to the public. Enable whitelisting, basic authentication or user accounts.');
|
||||
logSecurityAlert('Your current SillyTavern configuration is insecure (listening to non-localhost). Enable whitelisting, basic authentication or user accounts.');
|
||||
}
|
||||
|
||||
const users = await getAllEnabledUsers();
|
||||
@ -921,6 +1119,16 @@ async function verifySecuritySettings() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a not-found error response if a not-found error page exists. Should only be called after all other middlewares have been registered.
|
||||
*/
|
||||
function apply404Middleware() {
|
||||
const notFoundWebpage = safeReadFileSync('./public/error/url-not-found.html') ?? '';
|
||||
app.use((req, res) => {
|
||||
res.status(404).send(notFoundWebpage);
|
||||
});
|
||||
}
|
||||
|
||||
// User storage module needs to be initialized before starting the server
|
||||
initUserStorage(dataRoot)
|
||||
.then(ensurePublicDirectoriesExist)
|
||||
@ -928,4 +1136,5 @@ initUserStorage(dataRoot)
|
||||
.then(migrateSystemPrompts)
|
||||
.then(verifySecuritySettings)
|
||||
.then(preSetupTasks)
|
||||
.then(apply404Middleware)
|
||||
.finally(startServer);
|
||||
|
@ -139,19 +139,19 @@ export const UNSAFE_EXTENSIONS = [
|
||||
export const GEMINI_SAFETY = [
|
||||
{
|
||||
category: 'HARM_CATEGORY_HARASSMENT',
|
||||
threshold: 'BLOCK_NONE',
|
||||
threshold: 'OFF',
|
||||
},
|
||||
{
|
||||
category: 'HARM_CATEGORY_HATE_SPEECH',
|
||||
threshold: 'BLOCK_NONE',
|
||||
threshold: 'OFF',
|
||||
},
|
||||
{
|
||||
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
||||
threshold: 'BLOCK_NONE',
|
||||
threshold: 'OFF',
|
||||
},
|
||||
{
|
||||
category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
||||
threshold: 'BLOCK_NONE',
|
||||
threshold: 'OFF',
|
||||
},
|
||||
{
|
||||
category: 'HARM_CATEGORY_CIVIC_INTEGRITY',
|
||||
@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [
|
||||
export const OLLAMA_KEYS = [
|
||||
'num_predict',
|
||||
'num_ctx',
|
||||
'num_batch',
|
||||
'stop',
|
||||
'temperature',
|
||||
'repeat_penalty',
|
||||
@ -369,6 +370,7 @@ export const OPENROUTER_KEYS = [
|
||||
'prompt',
|
||||
'stop',
|
||||
'provider',
|
||||
'include_reasoning',
|
||||
];
|
||||
|
||||
// https://github.com/vllm-project/vllm/blob/0f8a91401c89ac0a8018def3756829611b57727f/vllm/entrypoints/openai/protocol.py#L220
|
||||
@ -413,3 +415,10 @@ export const VLLM_KEYS = [
|
||||
'guided_decoding_backend',
|
||||
'guided_whitespace_pattern',
|
||||
];
|
||||
|
||||
export const LOG_LEVELS = {
|
||||
DEBUG: 0,
|
||||
INFO: 1,
|
||||
WARN: 2,
|
||||
ERROR: 3,
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ router.post('/caption-image', jsonParser, async (request, response) => {
|
||||
max_tokens: 4096,
|
||||
};
|
||||
|
||||
console.log('Multimodal captioning request', body);
|
||||
console.debug('Multimodal captioning request', body);
|
||||
|
||||
const result = await fetch(url, {
|
||||
body: JSON.stringify(body),
|
||||
@ -46,14 +46,14 @@ router.post('/caption-image', jsonParser, async (request, response) => {
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log(`Claude API returned error: ${result.status} ${result.statusText}`, text);
|
||||
console.warn(`Claude API returned error: ${result.status} ${result.statusText}`, text);
|
||||
return response.status(result.status).send({ error: true });
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const generateResponseJson = await result.json();
|
||||
const caption = generateResponseJson.content[0].text;
|
||||
console.log('Claude response:', generateResponseJson);
|
||||
console.debug('Claude response:', generateResponseJson);
|
||||
|
||||
if (!caption) {
|
||||
return response.status(500).send('No caption found');
|
||||
|
@ -176,7 +176,7 @@ router.post('/get', jsonParser, async (request, response) => {
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
}
|
||||
return response.send(output);
|
||||
});
|
||||
@ -200,7 +200,7 @@ router.post('/download', jsonParser, async (request, response) => {
|
||||
category = i;
|
||||
|
||||
if (category === null) {
|
||||
console.debug('Bad request: unsupported asset category.');
|
||||
console.error('Bad request: unsupported asset category.');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ router.post('/download', jsonParser, async (request, response) => {
|
||||
|
||||
const temp_path = path.join(request.user.directories.assets, 'temp', request.body.filename);
|
||||
const file_path = path.join(request.user.directories.assets, category, request.body.filename);
|
||||
console.debug('Request received to download', url, 'to', file_path);
|
||||
console.info('Request received to download', url, 'to', file_path);
|
||||
|
||||
try {
|
||||
// Download to temp
|
||||
@ -241,13 +241,13 @@ router.post('/download', jsonParser, async (request, response) => {
|
||||
}
|
||||
|
||||
// Move into asset place
|
||||
console.debug('Download finished, moving file from', temp_path, 'to', file_path);
|
||||
console.info('Download finished, moving file from', temp_path, 'to', file_path);
|
||||
fs.copyFileSync(temp_path, file_path);
|
||||
fs.rmSync(temp_path);
|
||||
response.sendStatus(200);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
@ -270,7 +270,7 @@ router.post('/delete', jsonParser, async (request, response) => {
|
||||
category = i;
|
||||
|
||||
if (category === null) {
|
||||
console.debug('Bad request: unsupported asset category.');
|
||||
console.error('Bad request: unsupported asset category.');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ router.post('/delete', jsonParser, async (request, response) => {
|
||||
return response.status(400).send(validation.message);
|
||||
|
||||
const file_path = path.join(request.user.directories.assets, category, request.body.filename);
|
||||
console.debug('Request received to delete', category, file_path);
|
||||
console.info('Request received to delete', category, file_path);
|
||||
|
||||
try {
|
||||
// Delete if previous download failed
|
||||
@ -288,17 +288,17 @@ router.post('/delete', jsonParser, async (request, response) => {
|
||||
fs.unlink(file_path, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
console.debug('Asset deleted.');
|
||||
console.info('Asset deleted.');
|
||||
}
|
||||
else {
|
||||
console.debug('Asset not found.');
|
||||
console.error('Asset not found.');
|
||||
response.sendStatus(400);
|
||||
}
|
||||
// Move into asset place
|
||||
response.sendStatus(200);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
@ -314,6 +314,7 @@ router.post('/delete', jsonParser, async (request, response) => {
|
||||
*/
|
||||
router.post('/character', jsonParser, async (request, response) => {
|
||||
if (request.query.name === undefined) return response.sendStatus(400);
|
||||
|
||||
// For backwards compatibility, don't reject invalid character names, just sanitize them
|
||||
const name = sanitize(request.query.name.toString());
|
||||
const inputCategory = request.query.category;
|
||||
@ -325,7 +326,7 @@ router.post('/character', jsonParser, async (request, response) => {
|
||||
category = i;
|
||||
|
||||
if (category === null) {
|
||||
console.debug('Bad request: unsupported asset category.');
|
||||
console.error('Bad request: unsupported asset category.');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
@ -364,7 +365,7 @@ router.post('/character', jsonParser, async (request, response) => {
|
||||
return response.send(output);
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
console.error(err);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
@ -9,6 +9,7 @@ import { sync as writeFileAtomicSync } from 'write-file-atomic';
|
||||
import { jsonParser, urlencodedParser } from '../express-common.js';
|
||||
import { AVATAR_WIDTH, AVATAR_HEIGHT } from '../constants.js';
|
||||
import { getImages, tryParse } from '../util.js';
|
||||
import { getFileNameValidationFunction } from '../middleware/validateFileName.js';
|
||||
|
||||
export const router = express.Router();
|
||||
|
||||
@ -17,7 +18,7 @@ router.post('/get', jsonParser, function (request, response) {
|
||||
response.send(JSON.stringify(images));
|
||||
});
|
||||
|
||||
router.post('/delete', jsonParser, function (request, response) {
|
||||
router.post('/delete', jsonParser, getFileNameValidationFunction('avatar'), function (request, response) {
|
||||
if (!request.body) return response.sendStatus(400);
|
||||
|
||||
if (request.body.avatar !== sanitize(request.body.avatar)) {
|
||||
|
@ -11,14 +11,14 @@ router.post('/list', jsonParser, async (req, res) => {
|
||||
const key = readSecret(req.user.directories, SECRET_KEYS.AZURE_TTS);
|
||||
|
||||
if (!key) {
|
||||
console.error('Azure TTS API Key not set');
|
||||
console.warn('Azure TTS API Key not set');
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
||||
const region = req.body.region;
|
||||
|
||||
if (!region) {
|
||||
console.error('Azure TTS region not set');
|
||||
console.warn('Azure TTS region not set');
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ router.post('/list', jsonParser, async (req, res) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Azure Request failed', response.status, response.statusText);
|
||||
console.warn('Azure Request failed', response.status, response.statusText);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
@ -49,13 +49,13 @@ router.post('/generate', jsonParser, async (req, res) => {
|
||||
const key = readSecret(req.user.directories, SECRET_KEYS.AZURE_TTS);
|
||||
|
||||
if (!key) {
|
||||
console.error('Azure TTS API Key not set');
|
||||
console.warn('Azure TTS API Key not set');
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
||||
const { text, voice, region } = req.body;
|
||||
if (!text || !voice || !region) {
|
||||
console.error('Missing required parameters');
|
||||
console.warn('Missing required parameters');
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ router.post('/generate', jsonParser, async (req, res) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Azure Request failed', response.status, response.statusText);
|
||||
console.warn('Azure Request failed', response.status, response.statusText);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ import {
|
||||
getTiktokenTokenizer,
|
||||
sentencepieceTokenizers,
|
||||
TEXT_COMPLETION_MODELS,
|
||||
webTokenizers,
|
||||
getWebTokenizer,
|
||||
} from '../tokenizers.js';
|
||||
|
||||
const API_OPENAI = 'https://api.openai.com/v1';
|
||||
@ -61,6 +63,7 @@ const API_DEEPSEEK = 'https://api.deepseek.com/beta';
|
||||
* @returns
|
||||
*/
|
||||
function postProcessPrompt(messages, type, names) {
|
||||
const addAssistantPrefix = x => x.length && (x[x.length - 1].role !== 'assistant' || (x[x.length - 1].prefix = true)) ? x : x;
|
||||
switch (type) {
|
||||
case 'merge':
|
||||
case 'claude':
|
||||
@ -70,7 +73,9 @@ function postProcessPrompt(messages, type, names) {
|
||||
case 'strict':
|
||||
return mergeMessages(messages, names, true, true);
|
||||
case 'deepseek':
|
||||
return (x => x.length && (x[x.length - 1].role !== 'assistant' || (x[x.length - 1].prefix = true)) ? x : x)(mergeMessages(messages, names, true, false));
|
||||
return addAssistantPrefix(mergeMessages(messages, names, true, false));
|
||||
case 'deepseek-reasoner':
|
||||
return addAssistantPrefix(mergeMessages(messages, names, true, true));
|
||||
default:
|
||||
return messages;
|
||||
}
|
||||
@ -109,7 +114,7 @@ async function sendClaudeRequest(request, response) {
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
console.log(color.red(`Claude API key is missing.\n${divider}`));
|
||||
console.warn(color.red(`Claude API key is missing.\n${divider}`));
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
@ -174,7 +179,7 @@ async function sendClaudeRequest(request, response) {
|
||||
additionalHeaders['anthropic-beta'] = 'prompt-caching-2024-07-31';
|
||||
}
|
||||
|
||||
console.log('Claude request:', requestBody);
|
||||
console.debug('Claude request:', requestBody);
|
||||
|
||||
const generateResponse = await fetch(apiUrl + '/messages', {
|
||||
method: 'POST',
|
||||
@ -194,21 +199,21 @@ async function sendClaudeRequest(request, response) {
|
||||
} else {
|
||||
if (!generateResponse.ok) {
|
||||
const generateResponseText = await generateResponse.text();
|
||||
console.log(color.red(`Claude API returned error: ${generateResponse.status} ${generateResponse.statusText}\n${generateResponseText}\n${divider}`));
|
||||
console.warn(color.red(`Claude API returned error: ${generateResponse.status} ${generateResponse.statusText}\n${generateResponseText}\n${divider}`));
|
||||
return response.status(generateResponse.status).send({ error: true });
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
const responseText = generateResponseJson?.content?.[0]?.text || '';
|
||||
console.log('Claude response:', generateResponseJson);
|
||||
console.debug('Claude response:', generateResponseJson);
|
||||
|
||||
// Wrap it back to OAI format + save the original content
|
||||
const reply = { choices: [{ 'message': { 'content': responseText } }], content: generateResponseJson.content };
|
||||
return response.send(reply);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(color.red(`Error communicating with Claude: ${error}\n${divider}`));
|
||||
console.error(color.red(`Error communicating with Claude: ${error}\n${divider}`));
|
||||
if (!response.headersSent) {
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
@ -225,12 +230,12 @@ async function sendScaleRequest(request, response) {
|
||||
const apiKey = readSecret(request.user.directories, SECRET_KEYS.SCALE);
|
||||
|
||||
if (!apiKey) {
|
||||
console.log('Scale API key is missing.');
|
||||
console.warn('Scale API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
const requestPrompt = convertTextCompletionPrompt(request.body.messages);
|
||||
console.log('Scale request:', requestPrompt);
|
||||
console.debug('Scale request:', requestPrompt);
|
||||
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
@ -249,18 +254,18 @@ async function sendScaleRequest(request, response) {
|
||||
});
|
||||
|
||||
if (!generateResponse.ok) {
|
||||
console.log(`Scale API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
|
||||
console.warn(`Scale API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.log('Scale response:', generateResponseJson);
|
||||
console.debug('Scale response:', generateResponseJson);
|
||||
|
||||
const reply = { choices: [{ 'message': { 'content': generateResponseJson.output } }] };
|
||||
return response.send(reply);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
if (!response.headersSent) {
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
@ -277,13 +282,13 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MAKERSUITE);
|
||||
|
||||
if (!request.body.reverse_proxy && !apiKey) {
|
||||
console.log('Google AI Studio API key is missing.');
|
||||
console.warn('Google AI Studio API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
const model = String(request.body.model);
|
||||
const stream = Boolean(request.body.stream);
|
||||
const showThoughts = Boolean(request.body.show_thoughts);
|
||||
const isThinking = model.includes('thinking');
|
||||
|
||||
const generationConfig = {
|
||||
stopSequences: request.body.stop,
|
||||
@ -300,8 +305,9 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
}
|
||||
|
||||
const should_use_system_prompt = (
|
||||
model.includes('gemini-2.0-pro') ||
|
||||
model.includes('gemini-2.0-flash') ||
|
||||
model.includes('gemini-2.0-flash-thinking-exp') ||
|
||||
model.includes('gemini-2.0-flash-exp') ||
|
||||
model.includes('gemini-1.5-flash') ||
|
||||
model.includes('gemini-1.5-pro') ||
|
||||
model.startsWith('gemini-exp')
|
||||
@ -310,9 +316,15 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
const prompt = convertGooglePrompt(request.body.messages, model, should_use_system_prompt, getPromptNames(request));
|
||||
let safetySettings = GEMINI_SAFETY;
|
||||
|
||||
if (model.includes('gemini-2.0-flash-exp')) {
|
||||
// These old models do not support setting the threshold to OFF at all.
|
||||
if (['gemini-1.5-pro-001', 'gemini-1.5-flash-001', 'gemini-1.5-flash-8b-exp-0827', 'gemini-1.5-flash-8b-exp-0924', 'gemini-pro', 'gemini-1.0-pro', 'gemini-1.0-pro-001'].includes(model)) {
|
||||
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'BLOCK_NONE' }));
|
||||
}
|
||||
// Interestingly, Gemini 2.0 Flash does support setting the threshold for HARM_CATEGORY_CIVIC_INTEGRITY to OFF.
|
||||
else if (['gemini-2.0-flash', 'gemini-2.0-flash-001', 'gemini-2.0-flash-exp'].includes(model)) {
|
||||
safetySettings = GEMINI_SAFETY.map(setting => ({ ...setting, threshold: 'OFF' }));
|
||||
}
|
||||
// Most of the other models allow for setting the threshold of filters, except for HARM_CATEGORY_CIVIC_INTEGRITY, to OFF.
|
||||
|
||||
let body = {
|
||||
contents: prompt.contents,
|
||||
@ -328,7 +340,7 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
}
|
||||
|
||||
const body = getGeminiBody();
|
||||
console.log('Google AI Studio request:', body);
|
||||
console.debug('Google AI Studio request:', body);
|
||||
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
@ -337,7 +349,6 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
controller.abort();
|
||||
});
|
||||
|
||||
const isThinking = model.includes('thinking');
|
||||
const apiVersion = isThinking ? 'v1alpha' : 'v1beta';
|
||||
const responseType = (stream ? 'streamGenerateContent' : 'generateContent');
|
||||
|
||||
@ -355,14 +366,14 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
// Pipe remote SSE stream to Express response
|
||||
forwardFetchResponse(generateResponse, response);
|
||||
} catch (error) {
|
||||
console.log('Error forwarding streaming response:', error);
|
||||
console.error('Error forwarding streaming response:', error);
|
||||
if (!response.headersSent) {
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!generateResponse.ok) {
|
||||
console.log(`Google AI Studio API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
|
||||
console.warn(`Google AI Studio API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
|
||||
return response.status(generateResponse.status).send({ error: true });
|
||||
}
|
||||
|
||||
@ -372,7 +383,7 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
const candidates = generateResponseJson?.candidates;
|
||||
if (!candidates || candidates.length === 0) {
|
||||
let message = 'Google AI Studio API returned no candidate';
|
||||
console.log(message, generateResponseJson);
|
||||
console.warn(message, generateResponseJson);
|
||||
if (generateResponseJson?.promptFeedback?.blockReason) {
|
||||
message += `\nPrompt was blocked due to : ${generateResponseJson.promptFeedback.blockReason}`;
|
||||
}
|
||||
@ -380,25 +391,21 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
}
|
||||
|
||||
const responseContent = candidates[0].content ?? candidates[0].output;
|
||||
console.log('Google AI Studio response:', responseContent);
|
||||
console.warn('Google AI Studio response:', responseContent);
|
||||
|
||||
if (Array.isArray(responseContent?.parts) && isThinking && !showThoughts) {
|
||||
responseContent.parts = responseContent.parts.filter(part => !part.thought);
|
||||
}
|
||||
|
||||
const responseText = typeof responseContent === 'string' ? responseContent : responseContent?.parts?.map(part => part.text)?.join('\n\n');
|
||||
const responseText = typeof responseContent === 'string' ? responseContent : responseContent?.parts?.filter(part => !part.thought)?.map(part => part.text)?.join('\n\n');
|
||||
if (!responseText) {
|
||||
let message = 'Google AI Studio Candidate text empty';
|
||||
console.log(message, generateResponseJson);
|
||||
console.warn(message, generateResponseJson);
|
||||
return response.send({ error: { message } });
|
||||
}
|
||||
|
||||
// Wrap it back to OAI format
|
||||
const reply = { choices: [{ 'message': { 'content': responseText } }] };
|
||||
const reply = { choices: [{ 'message': { 'content': responseText } }], responseContent };
|
||||
return response.send(reply);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error communicating with Google AI Studio API: ', error);
|
||||
console.error('Error communicating with Google AI Studio API: ', error);
|
||||
if (!response.headersSent) {
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
@ -412,8 +419,9 @@ async function sendMakerSuiteRequest(request, response) {
|
||||
*/
|
||||
async function sendAI21Request(request, response) {
|
||||
if (!request.body) return response.sendStatus(400);
|
||||
|
||||
const controller = new AbortController();
|
||||
console.log(request.body.messages);
|
||||
console.debug(request.body.messages);
|
||||
request.socket.removeAllListeners('close');
|
||||
request.socket.on('close', function () {
|
||||
controller.abort();
|
||||
@ -439,7 +447,7 @@ async function sendAI21Request(request, response) {
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
console.log('AI21 request:', body);
|
||||
console.debug('AI21 request:', body);
|
||||
|
||||
try {
|
||||
const generateResponse = await fetch(API_AI21 + '/chat/completions', options);
|
||||
@ -448,16 +456,16 @@ async function sendAI21Request(request, response) {
|
||||
} else {
|
||||
if (!generateResponse.ok) {
|
||||
const errorText = await generateResponse.text();
|
||||
console.log(`AI21 API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
console.warn(`AI21 API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
const errorJson = tryParse(errorText) ?? { error: true };
|
||||
return response.status(500).send(errorJson);
|
||||
}
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.log('AI21 response:', generateResponseJson);
|
||||
console.debug('AI21 response:', generateResponseJson);
|
||||
return response.send(generateResponseJson);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error communicating with AI21 API: ', error);
|
||||
console.error('Error communicating with AI21 API: ', error);
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: true });
|
||||
} else {
|
||||
@ -476,7 +484,7 @@ async function sendMistralAIRequest(request, response) {
|
||||
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MISTRALAI);
|
||||
|
||||
if (!apiKey) {
|
||||
console.log('MistralAI API key is missing.');
|
||||
console.warn('MistralAI API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
@ -517,7 +525,7 @@ async function sendMistralAIRequest(request, response) {
|
||||
timeout: 0,
|
||||
};
|
||||
|
||||
console.log('MisralAI request:', requestBody);
|
||||
console.debug('MisralAI request:', requestBody);
|
||||
|
||||
const generateResponse = await fetch(apiUrl + '/chat/completions', config);
|
||||
if (request.body.stream) {
|
||||
@ -525,16 +533,16 @@ async function sendMistralAIRequest(request, response) {
|
||||
} else {
|
||||
if (!generateResponse.ok) {
|
||||
const errorText = await generateResponse.text();
|
||||
console.log(`MistralAI API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
console.warn(`MistralAI API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
const errorJson = tryParse(errorText) ?? { error: true };
|
||||
return response.status(500).send(errorJson);
|
||||
}
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.log('MistralAI response:', generateResponseJson);
|
||||
console.debug('MistralAI response:', generateResponseJson);
|
||||
return response.send(generateResponseJson);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error communicating with MistralAI API: ', error);
|
||||
console.error('Error communicating with MistralAI API: ', error);
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: true });
|
||||
} else {
|
||||
@ -557,7 +565,7 @@ async function sendCohereRequest(request, response) {
|
||||
});
|
||||
|
||||
if (!apiKey) {
|
||||
console.log('Cohere API key is missing.');
|
||||
console.warn('Cohere API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
@ -596,7 +604,7 @@ async function sendCohereRequest(request, response) {
|
||||
requestBody.safety_mode = 'OFF';
|
||||
}
|
||||
|
||||
console.log('Cohere request:', requestBody);
|
||||
console.debug('Cohere request:', requestBody);
|
||||
|
||||
const config = {
|
||||
method: 'POST',
|
||||
@ -618,16 +626,16 @@ async function sendCohereRequest(request, response) {
|
||||
const generateResponse = await fetch(apiUrl, config);
|
||||
if (!generateResponse.ok) {
|
||||
const errorText = await generateResponse.text();
|
||||
console.log(`Cohere API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
console.warn(`Cohere API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
const errorJson = tryParse(errorText) ?? { error: true };
|
||||
return response.status(500).send(errorJson);
|
||||
}
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.log('Cohere response:', generateResponseJson);
|
||||
console.debug('Cohere response:', generateResponseJson);
|
||||
return response.send(generateResponseJson);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error communicating with Cohere API: ', error);
|
||||
console.error('Error communicating with Cohere API: ', error);
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: true });
|
||||
} else {
|
||||
@ -636,6 +644,94 @@ async function sendCohereRequest(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to DeepSeek API.
|
||||
* @param {express.Request} request Express request
|
||||
* @param {express.Response} response Express response
|
||||
*/
|
||||
async function sendDeepSeekRequest(request, response) {
|
||||
const apiUrl = new URL(request.body.reverse_proxy || API_DEEPSEEK).toString();
|
||||
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
|
||||
|
||||
if (!apiKey && !request.body.reverse_proxy) {
|
||||
console.warn('DeepSeek API 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.logprobs > 0) {
|
||||
bodyParams['top_logprobs'] = request.body.logprobs;
|
||||
bodyParams['logprobs'] = true;
|
||||
}
|
||||
|
||||
if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
|
||||
bodyParams['tools'] = request.body.tools;
|
||||
bodyParams['tool_choice'] = request.body.tool_choice;
|
||||
}
|
||||
|
||||
const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek';
|
||||
const processedMessages = postProcessPrompt(request.body.messages, postProcessType, getPromptNames(request));
|
||||
|
||||
const requestBody = {
|
||||
'messages': processedMessages,
|
||||
'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,
|
||||
'stop': request.body.stop,
|
||||
'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('DeepSeek 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(`DeepSeek API returned error: ${generateResponse.status} ${generateResponse.statusText} ${errorText}`);
|
||||
const errorJson = tryParse(errorText) ?? { error: true };
|
||||
return response.status(500).send(errorJson);
|
||||
}
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.debug('DeepSeek response:', generateResponseJson);
|
||||
return response.send(generateResponseJson);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error communicating with DeepSeek API: ', error);
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: true });
|
||||
} else {
|
||||
response.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const router = express.Router();
|
||||
|
||||
router.post('/status', jsonParser, async function (request, response_getstatus_openai) {
|
||||
@ -680,16 +776,16 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
|
||||
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.DEEPSEEK) {
|
||||
api_url = API_DEEPSEEK.replace('/beta', '');
|
||||
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
|
||||
api_url = new URL(request.body.reverse_proxy || API_DEEPSEEK.replace('/beta', ''));
|
||||
api_key_openai = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
|
||||
headers = {};
|
||||
} else {
|
||||
console.log('This chat completion source is not supported yet.');
|
||||
console.warn('This chat completion source is not supported yet.');
|
||||
return response_getstatus_openai.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
if (!api_key_openai && !request.body.reverse_proxy && request.body.chat_completion_source !== CHAT_COMPLETION_SOURCES.CUSTOM) {
|
||||
console.log('Chat Completion API key is missing.');
|
||||
console.warn('Chat Completion API key is missing.');
|
||||
return response_getstatus_openai.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
@ -724,23 +820,23 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
|
||||
};
|
||||
});
|
||||
|
||||
console.log('Available OpenRouter models:', models);
|
||||
console.info('Available OpenRouter models:', models);
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.MISTRALAI) {
|
||||
const models = data?.data;
|
||||
console.log(models);
|
||||
console.info(models);
|
||||
} else {
|
||||
const models = data?.data;
|
||||
|
||||
if (Array.isArray(models)) {
|
||||
const modelIds = models.filter(x => x && typeof x === 'object').map(x => x.id).sort();
|
||||
console.log('Available models:', modelIds);
|
||||
console.info('Available models:', modelIds);
|
||||
} else {
|
||||
console.log('Chat Completion endpoint did not return a list of models.');
|
||||
console.warn('Chat Completion endpoint did not return a list of models.');
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Chat Completion status check failed. Either Access Token is incorrect or API endpoint is down.');
|
||||
console.error('Chat Completion status check failed. Either Access Token is incorrect or API endpoint is down.');
|
||||
response_getstatus_openai.send({ error: true, can_bypass: true, data: { data: [] } });
|
||||
}
|
||||
} catch (e) {
|
||||
@ -773,10 +869,18 @@ router.post('/bias', jsonParser, async function (request, response) {
|
||||
const tokenizer = getSentencepiceTokenizer(model);
|
||||
const instance = await tokenizer?.get();
|
||||
if (!instance) {
|
||||
console.warn('Tokenizer not initialized:', model);
|
||||
console.error('Tokenizer not initialized:', model);
|
||||
return response.send({});
|
||||
}
|
||||
encodeFunction = (text) => new Uint32Array(instance.encodeIds(text));
|
||||
} else if (webTokenizers.includes(model)) {
|
||||
const tokenizer = getWebTokenizer(model);
|
||||
const instance = await tokenizer?.get();
|
||||
if (!instance) {
|
||||
console.warn('Tokenizer not initialized:', model);
|
||||
return response.send({});
|
||||
}
|
||||
encodeFunction = (text) => new Uint32Array(instance.encode(text));
|
||||
} else {
|
||||
const tokenizer = getTiktokenTokenizer(model);
|
||||
encodeFunction = (tokenizer.encode.bind(tokenizer));
|
||||
@ -841,6 +945,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
case CHAT_COMPLETION_SOURCES.MAKERSUITE: return sendMakerSuiteRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.MISTRALAI: return sendMistralAIRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.COHERE: return sendCohereRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.DEEPSEEK: return sendDeepSeekRequest(request, response);
|
||||
}
|
||||
|
||||
let apiUrl;
|
||||
@ -899,6 +1004,10 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
bodyParams['route'] = 'fallback';
|
||||
}
|
||||
|
||||
if (request.body.include_reasoning) {
|
||||
bodyParams['include_reasoning'] = true;
|
||||
}
|
||||
|
||||
let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1);
|
||||
if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && request.body.model?.startsWith('anthropic/claude-3')) {
|
||||
cachingAtDepthForOpenRouterClaude(request.body.messages, cachingAtDepth);
|
||||
@ -922,7 +1031,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
mergeObjectWithYaml(headers, request.body.custom_include_headers);
|
||||
|
||||
if (request.body.custom_prompt_post_processing) {
|
||||
console.log('Applying custom prompt post-processing of type', request.body.custom_prompt_post_processing);
|
||||
console.info('Applying custom prompt post-processing of type', request.body.custom_prompt_post_processing);
|
||||
request.body.messages = postProcessPrompt(
|
||||
request.body.messages,
|
||||
request.body.custom_prompt_post_processing,
|
||||
@ -954,25 +1063,20 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||
headers = {};
|
||||
bodyParams = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.DEEPSEEK) {
|
||||
apiUrl = API_DEEPSEEK;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.DEEPSEEK);
|
||||
headers = {};
|
||||
bodyParams = {};
|
||||
|
||||
if (request.body.logprobs > 0) {
|
||||
bodyParams['top_logprobs'] = request.body.logprobs;
|
||||
bodyParams['logprobs'] = true;
|
||||
}
|
||||
|
||||
request.body.messages = postProcessPrompt(request.body.messages, 'deepseek', getPromptNames(request));
|
||||
} else {
|
||||
console.log('This chat completion source is not supported yet.');
|
||||
console.warn('This chat completion source is not supported yet.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
// A few of OpenAIs reasoning models support reasoning effort
|
||||
if ([CHAT_COMPLETION_SOURCES.CUSTOM, CHAT_COMPLETION_SOURCES.OPENAI].includes(request.body.chat_completion_source)) {
|
||||
if (['o1', 'o3-mini', 'o3-mini-2025-01-31'].includes(request.body.model)) {
|
||||
bodyParams['reasoning_effort'] = request.body.reasoning_effort;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apiKey && !request.body.reverse_proxy && request.body.chat_completion_source !== CHAT_COMPLETION_SOURCES.CUSTOM) {
|
||||
console.log('OpenAI API key is missing.');
|
||||
console.warn('OpenAI API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
@ -1032,7 +1136,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
console.log(requestBody);
|
||||
console.debug(requestBody);
|
||||
|
||||
makeRequest(config, response, request);
|
||||
|
||||
@ -1049,7 +1153,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
const fetchResponse = await fetch(endpointUrl, config);
|
||||
|
||||
if (request.body.stream) {
|
||||
console.log('Streaming request in progress');
|
||||
console.info('Streaming request in progress');
|
||||
forwardFetchResponse(fetchResponse, response);
|
||||
return;
|
||||
}
|
||||
@ -1058,10 +1162,10 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
/** @type {any} */
|
||||
let json = await fetchResponse.json();
|
||||
response.send(json);
|
||||
console.log(json);
|
||||
console.log(json?.choices?.[0]?.message);
|
||||
console.debug(json);
|
||||
console.debug(json?.choices?.[0]?.message);
|
||||
} else if (fetchResponse.status === 429 && retries > 0) {
|
||||
console.log(`Out of quota, retrying in ${Math.round(timeout / 1000)}s`);
|
||||
console.warn(`Out of quota, retrying in ${Math.round(timeout / 1000)}s`);
|
||||
setTimeout(() => {
|
||||
timeout *= 2;
|
||||
makeRequest(config, response, request, retries - 1, timeout);
|
||||
@ -1070,7 +1174,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
await handleErrorResponse(fetchResponse);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Generation failed', error);
|
||||
console.error('Generation failed', error);
|
||||
const message = error.code === 'ECONNREFUSED'
|
||||
? `Connection refused: ${error.message}`
|
||||
: error.message || 'Unknown error occurred';
|
||||
@ -1092,7 +1196,7 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
|
||||
const message = errorResponse.statusText || 'Unknown error occurred';
|
||||
const quota_error = errorResponse.status === 429 && errorData?.error?.type === 'insufficient_quota';
|
||||
console.log('Chat completion request error: ', message, responseText);
|
||||
console.error('Chat completion request error: ', message, responseText);
|
||||
|
||||
if (!response.headersSent) {
|
||||
response.send({ error: { message }, quota_error: quota_error });
|
||||
@ -1103,4 +1207,3 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -22,17 +22,17 @@ router.post('/generate', jsonParser, async function (request, response_generate)
|
||||
request.socket.on('close', async function () {
|
||||
if (request.body.can_abort && !response_generate.writableEnded) {
|
||||
try {
|
||||
console.log('Aborting Kobold generation...');
|
||||
console.info('Aborting Kobold generation...');
|
||||
// send abort signal to koboldcpp
|
||||
const abortResponse = await fetch(`${request.body.api_server}/extra/abort`, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
if (!abortResponse.ok) {
|
||||
console.log('Error sending abort request to Kobold:', abortResponse.status);
|
||||
console.error('Error sending abort request to Kobold:', abortResponse.status);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
controller.abort();
|
||||
@ -81,7 +81,7 @@ router.post('/generate', jsonParser, async function (request, response_generate)
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this_settings);
|
||||
console.debug(this_settings);
|
||||
const args = {
|
||||
body: JSON.stringify(this_settings),
|
||||
headers: Object.assign(
|
||||
@ -105,7 +105,7 @@ router.post('/generate', jsonParser, async function (request, response_generate)
|
||||
} else {
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.log(`Kobold returned error: ${response.status} ${response.statusText} ${errorText}`);
|
||||
console.warn(`Kobold returned error: ${response.status} ${response.statusText} ${errorText}`);
|
||||
|
||||
try {
|
||||
const errorJson = JSON.parse(errorText);
|
||||
@ -117,7 +117,7 @@ router.post('/generate', jsonParser, async function (request, response_generate)
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('Endpoint response:', data);
|
||||
console.debug('Endpoint response:', data);
|
||||
return response_generate.send(data);
|
||||
}
|
||||
} catch (error) {
|
||||
@ -125,19 +125,19 @@ router.post('/generate', jsonParser, async function (request, response_generate)
|
||||
switch (error?.status) {
|
||||
case 403:
|
||||
case 503: // retry in case of temporary service issue, possibly caused by a queue failure?
|
||||
console.debug(`KoboldAI is busy. Retry attempt ${i + 1} of ${MAX_RETRIES}...`);
|
||||
console.warn(`KoboldAI is busy. Retry attempt ${i + 1} of ${MAX_RETRIES}...`);
|
||||
await delay(delayAmount);
|
||||
break;
|
||||
default:
|
||||
if ('status' in error) {
|
||||
console.log('Status Code from Kobold:', error.status);
|
||||
console.error('Status Code from Kobold:', error.status);
|
||||
}
|
||||
return response_generate.send({ error: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Max retries exceeded. Giving up.');
|
||||
console.error('Max retries exceeded. Giving up.');
|
||||
return response_generate.send({ error: true });
|
||||
});
|
||||
|
||||
@ -193,16 +193,16 @@ router.post('/transcribe-audio', urlencodedParser, async function (request, resp
|
||||
const server = request.body.server;
|
||||
|
||||
if (!server) {
|
||||
console.log('Server is not set');
|
||||
console.error('Server is not set');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
if (!request.file) {
|
||||
console.log('No audio file found');
|
||||
console.error('No audio file found');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
console.log('Transcribing audio with KoboldCpp', server);
|
||||
console.debug('Transcribing audio with KoboldCpp', server);
|
||||
|
||||
const fileBase64 = fs.readFileSync(request.file.path).toString('base64');
|
||||
fs.rmSync(request.file.path);
|
||||
@ -226,12 +226,12 @@ router.post('/transcribe-audio', urlencodedParser, async function (request, resp
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.log('KoboldCpp request failed', result.statusText, text);
|
||||
console.error('KoboldCpp request failed', result.statusText, text);
|
||||
return response.status(500).send(text);
|
||||
}
|
||||
|
||||
const data = await result.json();
|
||||
console.log('KoboldCpp transcription response', data);
|
||||
console.debug('KoboldCpp transcription response', data);
|
||||
return response.json(data);
|
||||
} catch (error) {
|
||||
console.error('KoboldCpp transcription failed', error);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user