Commit Graph

413 Commits

Author SHA1 Message Date
kingbri
b8f86d55da Regex: Add substitution to regex and undefined checks
Sometimes a user may want to substitute variables in the regex
itself rather than just matching those variables. This can be
optionally enabled in the editor.

In addition, try preventing crashes by checking for undefined
variables or null coalescing.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
fee801c2a4 Regex: Upgrade engine
If the extension is disabled, don't use any regex formatting. In
addition, wrap all foreach logic into its own function which
reduces the size of all regex injections.

This commit also removes the need for working around static imports
as UI is separate from the engine and is therefore imported at the
same time as other non-static extensions.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
fb02c00402 Extensions: Workaround loading static extensions
Some extensions are statically imported inside script.js, bypassing
the extension load method. The true method to solve this is using
dynamic imports and undefined checks, but implementing this is
extremely time-consuming.

For now, add the extension_first_load event which fires when
first load is about to start. This changes loading priority to
static -> offline -> online/API.

In addition, initialize the event source earlier since it's more
important than most of the other imports.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
7c0222a15b Regex: Migrate CSS styling
Universal styling has been moved to the main styles.css.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
e6eae0aad1 Regex: Fix script duplication on edit
Editing a script can bypass the unique naming system by just renaming
the script to another one. This change ensures that no two script
names can be the same by checking if the existing index and found indices
differ.

If something goes wrong, it would be better to use a filter and a
map and then check the index array length/includes. FindIndex
is used here for efficiency's sake since each array index is unique.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
0f8d07053e Regex: Don't wrap scriptTemplate elements
Fix some UI for flex element wrapping. Text overflow for a script
name is now truncated if it exceeds one line of text. Also fix
how extension settings are laid out to prevent unnecessary
flex resizing.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
ee6a6603a3 Regex: Add trimStrings option
Sometimes the matched regex string needs to be pruned before
replacement. Add a method for the user to provide strings which
globally trims a regex match before any replacement is done.

Example without trim:
input - <Manami's thoughts: This is a thought>
regex - /<([^>]*)>/g
output - <Manami's thoughts: Manami's thoughts: This is a thought>

With trim:
input - <Manami's thoughts: This is a thought>
regex - /<([^>]*)>/g
trim - ["{{char}}'s thoughts: "]
output - <Manami's thoughts: This is a thought>

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:50 -04:00
kingbri
ef7aa3941b Extensions: Add regex engine
Regex is a method that is commonly used to find and replace parts
of a string using a single pattern. Add support for using regex in
SillyTavern which allows users to dynamically change various aspects
of the chatting experience.

Users are able to choose where a given regex script should apply
(both invasive and non-invasive options!). Invasive options alter
chat history while non-invasive alters markdown display for the
entire chat.

A new variable called {{match}} is added in regex scripts which
substitutes in the found match from the original find regex script.

There is a lot more that can be added to this extension, but for now,
this is enough.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-07-05 01:30:49 -04:00
Cohee
9a8e036ff9 Use floor rounding on chroma auto-calc 2023-07-05 01:25:43 +03:00
Cohee
0d858bdefb #591 Fix Chroma auto-adjust rounding N query to 0 2023-07-05 01:23:11 +03:00
RossAscends
19502492c6 Merge branch 'dev' of https://github.com/Cohee1207/SillyTavern into dev 2023-07-04 23:00:13 +09:00
RossAscends
3426f80656 Impervious MovingUI 2023-07-04 23:00:10 +09:00
Cohee
856b835172 Fix migration of settings.json 2023-07-04 11:41:15 +03:00
Cohee
6e15f7474f Fix obliteration of quick reply slots on input 2023-07-02 23:09:32 +03:00
Cohee
2e80de230e Fix Quick reply skill issue 2023-07-02 22:18:11 +03:00
Cohee
febef5dfba Customizable number of quick reply slots 2023-07-02 21:37:14 +03:00
Cohee
63bd4cd499 Fix selecting personas with quick reply 2023-07-01 19:25:04 +03:00
Cohee
cba2feb875 #569 Use main API as summary source 2023-06-30 23:37:01 +03:00
Cohee
b9a067b79f #588 Fix System TTS promise never resolving 2023-06-29 13:00:15 +03:00
Cohee
c18008725d Fix group VN mode 2023-06-28 16:39:37 +03:00
Cohee1207
f06ca28bbf Reduce console spam on expressions 2023-06-28 15:55:53 +03:00
Cohee
10e87dd5ca [WIP/Untested] DeepL translation API 2023-06-27 20:48:09 +03:00
Cohee
04cfedea7c Chroma: Remove dupe label 2023-06-25 19:56:15 +03:00
Cohee
16fd92b1a3 Merge pull request #566 from BlipRanger/dev
First try at chromadb multichat
2023-06-25 19:36:19 +03:00
Cohee
612db28bcb Better name for backgrounds plugin 2023-06-25 17:06:20 +03:00
Cohee
26ac519c55 User persona management block. Persona descriptions. Dummy personas. Change persona avatar 2023-06-25 16:46:23 +03:00
BlipRanger
d004a3141e Default bracket, make sure we have memories. 2023-06-25 01:03:47 -04:00
BlipRanger
bd74939a55 Add templating for custom injection 2023-06-25 01:01:47 -04:00
BlipRanger
2836704c4e Add sort options, remove duplicate entires from custom. 2023-06-25 00:17:58 -04:00
BlipRanger
71201377ef Merge branch 'SillyTavern:dev' into dev 2023-06-24 20:43:42 -04:00
BlipRanger
9de7db8f2d Add custom chroma strat 2023-06-24 20:41:54 -04:00
Cohee
66de4a1e09 Add positions for char A/N 2023-06-25 01:40:06 +03:00
Cohee
4cc3d335a8 Save A/N to metadata immediately 2023-06-25 01:08:38 +03:00
BlipRanger
3ce14883b9 First try at chromadb multichat 2023-06-24 15:36:26 -04:00
RossAscends
fed47d7477 /api 2023-06-24 00:59:09 +09:00
kingbri
350e2108e2 WI2AN: Fix formatting
Signed-off-by: kingbri <bdashore3@proton.me>
2023-06-20 11:30:29 -04:00
RossAscends
3b66310dd2 fix WI2AN insertions 2023-06-20 17:59:01 +09:00
Cohee
2d6ed116e6 Clarify auto-adjust UI labels 2023-06-19 21:54:58 +03:00
RossAscends
8c710a08a3 fix timestamps on SD gens 2023-06-20 01:08:58 +09:00
RossAscends
0490ca25b0 char panel buttons into dropdown; sheld width fix 2023-06-19 13:23:26 +09:00
Cohee
511f762e54 Auto-adjust values should not exceed max slider limits 2023-06-18 21:25:47 +03:00
Cohee
976248b665 Fix char A/N in groups 2023-06-18 18:33:57 +03:00
Cohee
22a5def618 Add option to auto-adjust number of chroma messages to keep / query based on context size. 2023-06-18 16:29:23 +03:00
RossAscends
58a6ccd4a5 WI-to-AN for real this time. 2023-06-18 18:17:43 +09:00
RossAscends
0c0baecb5f clarify TTS checkboxes 2023-06-17 10:19:27 +09:00
Cohee
329158349f Remove debug statement 2023-06-16 00:08:52 +03:00
Cohee
e420c96e77 Fix mobile audio playback stopping on swiping 2023-06-15 19:31:18 +03:00
Cohee
8e468908c0 Remove char name from the TTS if it is hidden from display with power user setting 2023-06-15 15:04:09 +03:00
Cohee
a9cfcff8bf Fix debouncing of author's note prompts 2023-06-15 12:02:58 +03:00
kingbri
63939fe660 Author's Notes: Add debouncing for token updates
Whenever a character is typed, add a debounce to not ovewhelm online
tokenizers such as OpenAI's.

Signed-off-by: kingbri <bdashore3@proton.me>
2023-06-14 23:30:48 -04:00