allow char scpoed regex (#2271)

* Update engine.js to allow char scpoed regex

no ui because i'm not good at it, but works.

* add typedef

* update

* little fix

* Rework scoped scripts UI

* Add locale attributes

* Purge allowance on delete

* add d&d for `saved_scoped_scripts`

* better code

* Save settings on regex scope toggle

* Fix reordering logic

* Fix scoped setter

* Add unique ids for regex scripts

* Wording

* Reload chat after deleting scripts

* Reload chat after toggling scoped regex

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
steve green
2024-05-26 22:19:00 +08:00
committed by GitHub
parent 31f4a34f5a
commit 00fc40408a
11 changed files with 423 additions and 78 deletions

View File

@ -68,6 +68,7 @@
* @property {number} depth_prompt.depth - The level of detail or nuance targeted by the prompt.
* @property {string} depth_prompt.prompt - The actual prompt text used for deeper character interaction.
* @property {"system" | "user" | "assistant"} depth_prompt.role - The role the character takes on during the prompted interaction (system, user, or assistant).
* @property {RegexScriptData[]} regex_scripts - Custom regex scripts for the character.
* // Non-standard extensions added by external tools
* @property {string} [pygmalion_id] - The unique identifier assigned to the character by the Pygmalion.chat.
* @property {string} [github_repo] - The gitHub repository associated with the character.
@ -76,6 +77,23 @@
* @property {{source: string[]}} [risuai] - The RisuAI-specific data associated with the character.
*/
/**
* @typedef {object} RegexScriptData
* @property {string} id - UUID of the script
* @property {string} scriptName - The name of the script
* @property {string} findRegex - The regex to find
* @property {string} replaceString - The string to replace
* @property {string[]} trimStrings - The strings to trim
* @property {number[]} placement - The placement of the script
* @property {boolean} disabled - Whether the script is disabled
* @property {boolean} markdownOnly - Whether the script only applies to Markdown
* @property {boolean} promptOnly - Whether the script only applies to prompts
* @property {boolean} runOnEdit - Whether the script runs on edit
* @property {boolean} substituteRegex - Whether the regex should be substituted
* @property {number} minDepth - The minimum depth
* @property {number} maxDepth - The maximum depth
*/
/**
* @typedef {object} v1CharData
* @property {string} name - the name of the character