refactor: Move getCustomToggles to parseKeyValue
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
import LoreBook from "./LoreBook/LoreBookSetting.svelte";
|
import LoreBook from "./LoreBook/LoreBookSetting.svelte";
|
||||||
import { alertConfirm, alertNormal, alertSelectChar, alertTOS, showHypaV2Alert } from "../../ts/alert";
|
import { alertConfirm, alertNormal, alertSelectChar, alertTOS, showHypaV2Alert } from "../../ts/alert";
|
||||||
import BarIcon from "./BarIcon.svelte";
|
import BarIcon from "./BarIcon.svelte";
|
||||||
import { findCharacterbyId, getAuthorNoteDefaultText, selectMultipleFile } from "../../ts/util";
|
import { findCharacterbyId, getAuthorNoteDefaultText, parseKeyValue, selectMultipleFile } from "../../ts/util";
|
||||||
import { onDestroy } from "svelte";
|
import { onDestroy } from "svelte";
|
||||||
import {isEqual} from 'lodash'
|
import {isEqual} from 'lodash'
|
||||||
import Help from "../Others/Help.svelte";
|
import Help from "../Others/Help.svelte";
|
||||||
@@ -29,7 +29,6 @@
|
|||||||
import { updateInlayScreen } from "src/ts/process/inlayScreen";
|
import { updateInlayScreen } from "src/ts/process/inlayScreen";
|
||||||
import { registerOnnxModel } from "src/ts/process/transformers";
|
import { registerOnnxModel } from "src/ts/process/transformers";
|
||||||
import MultiLangInput from "../UI/GUI/MultiLangInput.svelte";
|
import MultiLangInput from "../UI/GUI/MultiLangInput.svelte";
|
||||||
import { getCustomToggles } from "src/ts/process/prompt";
|
|
||||||
|
|
||||||
|
|
||||||
let subMenu = 0
|
let subMenu = 0
|
||||||
@@ -248,7 +247,7 @@
|
|||||||
<Check bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
|
<Check bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each getCustomToggles($DataBase.customPromptTemplateToggle) as toggle}
|
{#each parseKeyValue($DataBase.customPromptTemplateToggle) as toggle}
|
||||||
<div class="flex mt-2 items-center">
|
<div class="flex mt-2 items-center">
|
||||||
<Check check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
|
<Check check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
|
||||||
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
|
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
|
||||||
|
|||||||
@@ -7,11 +7,10 @@
|
|||||||
import { alertConfirm, alertError, alertSelect } from "src/ts/alert";
|
import { alertConfirm, alertError, alertSelect } from "src/ts/alert";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import Button from "../UI/GUI/Button.svelte";
|
import Button from "../UI/GUI/Button.svelte";
|
||||||
import { findCharacterbyId } from "src/ts/util";
|
import { findCharacterbyId, parseKeyValue } from "src/ts/util";
|
||||||
import CheckInput from "../UI/GUI/CheckInput.svelte";
|
import CheckInput from "../UI/GUI/CheckInput.svelte";
|
||||||
import { createMultiuserRoom } from "src/ts/sync/multiuser";
|
import { createMultiuserRoom } from "src/ts/sync/multiuser";
|
||||||
import { CurrentCharacter } from "src/ts/stores";
|
import { CurrentCharacter } from "src/ts/stores";
|
||||||
import { getCustomToggles } from "src/ts/process/prompt";
|
|
||||||
export let chara:character|groupChat
|
export let chara:character|groupChat
|
||||||
let editMode = false
|
let editMode = false
|
||||||
</script>
|
</script>
|
||||||
@@ -111,7 +110,7 @@
|
|||||||
<CheckInput bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
|
<CheckInput bind:check={$DataBase.jailbreakToggle} name={language.jailbreakToggle}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#each getCustomToggles($DataBase.customPromptTemplateToggle) as toggle}
|
{#each parseKeyValue($DataBase.customPromptTemplateToggle) as toggle}
|
||||||
<div class="flex mt-2 items-center">
|
<div class="flex mt-2 items-center">
|
||||||
<CheckInput check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
|
<CheckInput check={$DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1'} name={toggle[1]} onChange={() => {
|
||||||
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
|
$DataBase.globalChatVariables[`toggle_${toggle[0]}`] = $DataBase.globalChatVariables[`toggle_${toggle[0]}`] === '1' ? '0' : '1'
|
||||||
|
|||||||
@@ -64,20 +64,3 @@ export async function tokenizePreset(prompts:PromptItem[], consti:boolean = fals
|
|||||||
}
|
}
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCustomToggles(template:string){
|
|
||||||
if(!template){
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyValue:[string, string][] = []
|
|
||||||
|
|
||||||
for(const line of template.split('\n')){
|
|
||||||
const [key, value] = line.split('=')
|
|
||||||
if(key && value){
|
|
||||||
keyValue.push([key, value])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return keyValue
|
|
||||||
}
|
|
||||||
@@ -967,4 +967,21 @@ export const isKnownUri = (uri:string) => {
|
|||||||
|| uri.startsWith('https://')
|
|| uri.startsWith('https://')
|
||||||
|| uri.startsWith('ccdefault:')
|
|| uri.startsWith('ccdefault:')
|
||||||
|| uri.startsWith('embeded://')
|
|| uri.startsWith('embeded://')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseKeyValue(template:string){
|
||||||
|
if(!template){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyValue:[string, string][] = []
|
||||||
|
|
||||||
|
for(const line of template.split('\n')){
|
||||||
|
const [key, value] = line.split('=')
|
||||||
|
if(key && value){
|
||||||
|
keyValue.push([key, value])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyValue
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user