Merge branch 'patch-23' of https://github.com/Bo26fhmC5M/RisuAI into patch-23

This commit is contained in:
Bo26fhmC5M
2025-02-09 09:02:55 +09:00
5 changed files with 28 additions and 6 deletions

View File

@@ -132,6 +132,8 @@
<div class="flex items-center mt-4">
<Check bind:check={currentModule.hideIcon} name={language.hideChatIcon}/>
</div>
<span class="mt-4">{language.customPromptTemplateToggle} <Help key='customPromptTemplateToggle' /></span>
<TextAreaInput bind:value={currentModule.customModuleToggle}/>
{/if}
{#if submenu === 1 && (Array.isArray(currentModule.lorebook))}
<div class="border border-selected p-2 flex flex-col rounded-md mt-2">

View File

@@ -82,6 +82,10 @@
e.stopPropagation()
const d = await alertConfirm(`${language.removeConfirm}` + rmodule.name)
if(d){
if(DBState.db.enabledModules.includes(rmodule.id)){
DBState.db.enabledModules.splice(DBState.db.enabledModules.indexOf(rmodule.id), 1)
DBState.db.enabledModules = DBState.db.enabledModules
}
const index = DBState.db.modules.findIndex((v) => v.id === rmodule.id)
DBState.db.modules.splice(index, 1)
DBState.db.modules = DBState.db.modules

View File

@@ -30,7 +30,7 @@
import { updateInlayScreen } from "src/ts/process/inlayScreen";
import { registerOnnxModel } from "src/ts/process/transformers";
import MultiLangInput from "../UI/GUI/MultiLangInput.svelte";
import { applyModule } from "src/ts/process/modules";
import { applyModule, getModuleToggles } from "src/ts/process/modules";
import { exportRegex, importRegex } from "src/ts/process/scripts";
import Arcodion from "../UI/Arcodion.svelte";
import SliderInput from "../UI/GUI/SliderInput.svelte";
@@ -293,7 +293,7 @@
<Check bind:check={DBState.db.jailbreakToggle} name={language.jailbreakToggle}/>
</div>
{#each parseKeyValue(DBState.db.customPromptTemplateToggle) as toggle}
{#each parseKeyValue(DBState.db.customPromptTemplateToggle + getModuleToggles()) as toggle}
<div class="flex mt-2 items-center">
<Check check={DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
DBState.db.globalChatVariables[`toggle_${toggle[0]}`] = DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'

View File

@@ -16,6 +16,7 @@
import { onDestroy, onMount } from "svelte";
import { v4 } from "uuid";
import { getChatBranches } from "src/ts/gui/branches";
import { getModuleToggles } from "src/ts/process/modules";
interface Props {
chara: character|groupChat;
@@ -221,12 +222,12 @@
{#if DBState.db.characters[$selectedCharID]?.chaId !== '§playground'}
{#if parseKeyValue(DBState.db.customPromptTemplateToggle).length > 4}
{#if parseKeyValue(DBState.db.customPromptTemplateToggle + getModuleToggles()).length > 4}
<div class="h-48 border-darkborderc p-2 border rounded flex flex-col items-start mt-2 overflow-y-auto">
<div class="flex mt-2 items-center w-full" class:justify-end={$MobileGUI}>
<CheckInput bind:check={DBState.db.jailbreakToggle} name={language.jailbreakToggle} reverse />
</div>
{#each parseKeyValue(DBState.db.customPromptTemplateToggle) as toggle}
{#each parseKeyValue(DBState.db.customPromptTemplateToggle + getModuleToggles()) as toggle}
<div class="flex mt-2 items-center w-full" class:justify-end={$MobileGUI}>
<CheckInput check={DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1'} reverse name={toggle[1]} onChange={() => {
DBState.db.globalChatVariables[`toggle_${toggle[0]}`] = DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
@@ -239,11 +240,11 @@
</div>
{/if}
</div>
{:else if parseKeyValue(DBState.db.customPromptTemplateToggle).length > 0}
{:else if parseKeyValue(DBState.db.customPromptTemplateToggle + getModuleToggles()).length > 0}
<div class="flex mt-2 items-center">
<CheckInput bind:check={DBState.db.jailbreakToggle} name={language.jailbreakToggle} reverse/>
</div>
{#each parseKeyValue(DBState.db.customPromptTemplateToggle) as toggle}
{#each parseKeyValue(DBState.db.customPromptTemplateToggle + getModuleToggles()) as toggle}
<div class="flex mt-2 items-center">
<CheckInput check={DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1'} reverse name={toggle[1]} onChange={() => {
DBState.db.globalChatVariables[`toggle_${toggle[0]}`] = DBState.db.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'

View File

@@ -24,6 +24,7 @@ export interface RisuModule{
backgroundEmbedding?:string
assets?:[string,string,string][]
namespace?:string
customModuleToggle?:string
}
export async function exportModule(module:RisuModule, arg:{
@@ -352,6 +353,20 @@ export function getModuleRegexScripts() {
return customscripts
}
export function getModuleToggles() {
const modules = getModules()
let costomModuleToggles: string = ''
for (const module of modules) {
if(!module){
continue
}
if (module.customModuleToggle) {
costomModuleToggles += '\n' + module.customModuleToggle + '\n'
}
}
return costomModuleToggles
}
export async function applyModule() {
const sel = await alertModuleSelect()
if (!sel) {