[feat] global scripts
This commit is contained in:
@@ -51,7 +51,7 @@ export const languageEnglish = {
|
|||||||
+ "\n- if the key starts with **$**, the key's value will more likely to change."
|
+ "\n- if the key starts with **$**, the key's value will more likely to change."
|
||||||
+ "\n\nwhen the image is first generated, you can only change it by modifying 'Current Image Generation Data' in below.",
|
+ "\n\nwhen the image is first generated, you can only change it by modifying 'Current Image Generation Data' in below.",
|
||||||
|
|
||||||
regexScript: "Regex Script is a custom script that is embbedded to the character. it replaces string that matches IN to OUT.\n\nThere are three type options."
|
regexScript: "Regex Script is a custom script that replaces string that matches IN to OUT.\n\nThere are three type options."
|
||||||
+ "- **Modify Input** modifys user's input"
|
+ "- **Modify Input** modifys user's input"
|
||||||
+ "- **Modify Output** modifys character's output"
|
+ "- **Modify Output** modifys character's output"
|
||||||
+ "- **Modify Request Data** modifys current chat data when sent.\n\nIN must be a regex without flags and without slashes in start and end.\n\nOUT is a normal string."
|
+ "- **Modify Request Data** modifys current chat data when sent.\n\nIN must be a regex without flags and without slashes in start and end.\n\nOUT is a normal string."
|
||||||
@@ -271,4 +271,6 @@ export const languageEnglish = {
|
|||||||
replaceGlobalNote: "Global Note Replacement",
|
replaceGlobalNote: "Global Note Replacement",
|
||||||
charLoreBook: 'Character Lorebook',
|
charLoreBook: 'Character Lorebook',
|
||||||
globalLoreBook: 'Global Lorebook',
|
globalLoreBook: 'Global Lorebook',
|
||||||
|
globalRegexScript: "Regex Script",
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ export const languageKorean = {
|
|||||||
+ "\n- 키의 이름이 **$** 로 시작할 시, 값은 더 자주 변합니다."
|
+ "\n- 키의 이름이 **$** 로 시작할 시, 값은 더 자주 변합니다."
|
||||||
+ "\n\n이미지가 처음 생성된 이후부터는 '현재 이미지 생성 데이터'를 수정하여 변경할 수 있습니다.",
|
+ "\n\n이미지가 처음 생성된 이후부터는 '현재 이미지 생성 데이터'를 수정하여 변경할 수 있습니다.",
|
||||||
experimental: "실험적 기능입니다. 불안정할 수 있습니다.",
|
experimental: "실험적 기능입니다. 불안정할 수 있습니다.",
|
||||||
regexScript: "정규식 스크립트는 캐릭터에 종속된 커스텀 스크립트입니다. IN의 조건에 맞는 문자열을 OUT으로 변경합니다.\n\n타입은 세가지가 있습니다."
|
regexScript: "정규식 스크립트는 IN의 조건에 맞는 문자열을 OUT으로 변경합니다.\n\n타입은 세가지가 있습니다."
|
||||||
+ "- **입력문 수정** 유저의 입력문을 수정합니다"
|
+ "- **입력문 수정** 유저의 입력문을 수정합니다"
|
||||||
+ "- **출력문 수정** 캐릭터의 출력문을 수정합니다"
|
+ "- **출력문 수정** 캐릭터의 출력문을 수정합니다"
|
||||||
+ "- **리퀘스트 데이터 수정** 리퀘스트를 보낼 때 채팅 데이터를 수정합니다.\n\nIN은 flag가 없고, 양끝에 슬레시가 없는 Regex여야 합니다.\n\nOUT은 일반 문자열입니다."
|
+ "- **리퀘스트 데이터 수정** 리퀘스트를 보낼 때 채팅 데이터를 수정합니다.\n\nIN은 flag가 없고, 양끝에 슬레시가 없는 Regex여야 합니다.\n\nOUT은 일반 문자열입니다."
|
||||||
@@ -250,5 +250,5 @@ export const languageKorean = {
|
|||||||
replaceGlobalNote: "글로벌 노트 덮어쓰기",
|
replaceGlobalNote: "글로벌 노트 덮어쓰기",
|
||||||
charLoreBook: '캐릭터 로어북',
|
charLoreBook: '캐릭터 로어북',
|
||||||
globalLoreBook: '글로벌 로어북',
|
globalLoreBook: '글로벌 로어북',
|
||||||
|
globalRegexScript: "글로별 정규식 스크립트",
|
||||||
}
|
}
|
||||||
30
src/lib/Setting/Pages/GlobalRegex.svelte
Normal file
30
src/lib/Setting/Pages/GlobalRegex.svelte
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { PlusIcon } from "lucide-svelte";
|
||||||
|
import { language } from "src/lang";
|
||||||
|
import Help from "src/lib/Others/Help.svelte";
|
||||||
|
import RegexData from "src/lib/SideBars/RegexData.svelte";
|
||||||
|
import { DataBase } from "src/ts/database";
|
||||||
|
</script>
|
||||||
|
<h2 class="mb-2 text-2xl font-bold mt-2">{language.globalRegexScript} <Help key="regexScript" /></h2>
|
||||||
|
<table class="contain w-full max-w-full tabler mt-4 flex flex-col p-2 gap-2 border-selected border-1">
|
||||||
|
{#if $DataBase.globalscript.length === 0}
|
||||||
|
<div class="text-gray-500">No Scripts</div>
|
||||||
|
{/if}
|
||||||
|
{#each $DataBase.globalscript as customscript, i}
|
||||||
|
<RegexData bind:value={$DataBase.globalscript[i]} onRemove={() => {
|
||||||
|
let customscript = $DataBase.globalscript
|
||||||
|
customscript.splice(i, 1)
|
||||||
|
$DataBase.globalscript = customscript
|
||||||
|
}}/>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
|
<button class="font-medium cursor-pointer hover:text-green-500 mb-2" on:click={() => {
|
||||||
|
let script = $DataBase.globalscript
|
||||||
|
script.push({
|
||||||
|
comment: "",
|
||||||
|
in: "",
|
||||||
|
out: "",
|
||||||
|
type: "editinput"
|
||||||
|
})
|
||||||
|
$DataBase.globalscript = script
|
||||||
|
}}><PlusIcon /></button>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ActivityIcon, BookIcon, BotIcon, BoxIcon, CodeIcon, DiamondIcon, FolderIcon, MonitorIcon, Sailboat, UserIcon, XCircleIcon } from "lucide-svelte";
|
import { ActivityIcon, AlignLeft, BookIcon, BotIcon, BoxIcon, CodeIcon, DiamondIcon, FolderIcon, MonitorIcon, Sailboat, UserIcon, XCircleIcon } from "lucide-svelte";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import DisplaySettings from "./Pages/DisplaySettings.svelte";
|
import DisplaySettings from "./Pages/DisplaySettings.svelte";
|
||||||
import UserSettings from "./Pages/UserSettings.svelte";
|
import UserSettings from "./Pages/UserSettings.svelte";
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
import Communities from "./Pages/Communities.svelte";
|
import Communities from "./Pages/Communities.svelte";
|
||||||
import GlobalLoreBookSettings from "./Pages/GlobalLoreBookSettings.svelte";
|
import GlobalLoreBookSettings from "./Pages/GlobalLoreBookSettings.svelte";
|
||||||
import Lorepreset from "./lorepreset.svelte";
|
import Lorepreset from "./lorepreset.svelte";
|
||||||
|
import GlobalRegex from "./Pages/GlobalRegex.svelte";
|
||||||
let selected = -1
|
let selected = -1
|
||||||
let openPresetList = false
|
let openPresetList = false
|
||||||
let openLoreList = false
|
let openLoreList = false
|
||||||
@@ -56,6 +57,12 @@
|
|||||||
<BookIcon />
|
<BookIcon />
|
||||||
<span>{language.globalLoreBook}</span>
|
<span>{language.globalLoreBook}</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button class="text-gray-400 flex gap-2 items-center hover:text-gray-200" class:text-white={selected === 9} on:click={() => {
|
||||||
|
selected = 9
|
||||||
|
}}>
|
||||||
|
<AlignLeft />
|
||||||
|
<span>{language.globalRegexScript}</span>
|
||||||
|
</button>
|
||||||
<button class="text-gray-400 flex gap-2 items-center hover:text-gray-200" class:text-white={selected === 4} on:click={() => {
|
<button class="text-gray-400 flex gap-2 items-center hover:text-gray-200" class:text-white={selected === 4} on:click={() => {
|
||||||
selected = 4
|
selected = 4
|
||||||
}}>
|
}}>
|
||||||
@@ -107,6 +114,8 @@
|
|||||||
<Communities />
|
<Communities />
|
||||||
{:else if selected === 8}
|
{:else if selected === 8}
|
||||||
<GlobalLoreBookSettings bind:openLoreList />
|
<GlobalLoreBookSettings bind:openLoreList />
|
||||||
|
{:else if selected === 9}
|
||||||
|
<GlobalRegex/>
|
||||||
{/if}
|
{/if}
|
||||||
<button class="absolute top-2 right-2 hover:text-green-500" on:click={() => {
|
<button class="absolute top-2 right-2 hover:text-green-500" on:click={() => {
|
||||||
if(window.innerWidth >= 700){
|
if(window.innerWidth >= 700){
|
||||||
|
|||||||
@@ -245,6 +245,12 @@ export function setDatabase(data:Database){
|
|||||||
data: []
|
data: []
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
if(checkNullish(data.loreBookPage) || data.loreBook.length < data.loreBookPage){
|
||||||
|
data.loreBookPage = 0
|
||||||
|
}
|
||||||
|
if(checkNullish(data.globalscript)){
|
||||||
|
data.globalscript = []
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
@@ -474,6 +480,8 @@ export interface Database{
|
|||||||
token:string,
|
token:string,
|
||||||
model:string
|
model:string
|
||||||
}
|
}
|
||||||
|
globalscript: customscript[]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface hordeConfig{
|
interface hordeConfig{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { CharEmotion, selectedCharID } from "../stores";
|
import { CharEmotion, selectedCharID } from "../stores";
|
||||||
import type { character } from "../database";
|
import { DataBase, type character } from "../database";
|
||||||
|
|
||||||
const dreg = /{{data}}/g
|
const dreg = /{{data}}/g
|
||||||
|
|
||||||
@@ -11,7 +11,9 @@ export function processScript(char:character, data:string, mode:ScriptMode){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function processScriptFull(char:character, data:string, mode:ScriptMode){
|
export function processScriptFull(char:character, data:string, mode:ScriptMode){
|
||||||
|
let db = get(DataBase)
|
||||||
let emoChanged = false
|
let emoChanged = false
|
||||||
|
const scripts = char.customscript.concat(db.globalscript ?? [])
|
||||||
for (const script of char.customscript){
|
for (const script of char.customscript){
|
||||||
if(script.type === mode){
|
if(script.type === mode){
|
||||||
const reg = new RegExp(script.in,'g')
|
const reg = new RegExp(script.in,'g')
|
||||||
|
|||||||
Reference in New Issue
Block a user