Add preset related features
This commit is contained in:
@@ -5,7 +5,7 @@ import type { RisuPlugin } from '../plugins/plugins';
|
||||
import type {triggerscript as triggerscriptMain} from '../process/triggers';
|
||||
import { downloadFile, saveAsset as saveImageGlobal } from '../globalApi.svelte';
|
||||
import { defaultAutoSuggestPrompt, defaultJailbreak, defaultMainPrompt } from './defaultPrompts';
|
||||
import { alertNormal, alertSelect } from '../alert';
|
||||
import { alertError, alertNormal, alertSelect } from '../alert';
|
||||
import type { NAISettings } from '../process/models/nai';
|
||||
import { prebuiltNAIpresets, prebuiltPresets } from '../process/templates/templates';
|
||||
import { defaultColorScheme, type ColorScheme } from '../gui/colorscheme';
|
||||
@@ -353,6 +353,7 @@ export function setDatabase(data:Database){
|
||||
data.huggingfaceKey ??= ''
|
||||
data.fishSpeechKey ??= ''
|
||||
data.statistics ??= {}
|
||||
data.presetRegex ??= []
|
||||
data.reverseProxyOobaArgs ??= {
|
||||
mode: 'instruct'
|
||||
}
|
||||
@@ -860,6 +861,7 @@ export interface Database{
|
||||
menuSideBar:boolean
|
||||
pluginV2: RisuPlugin[]
|
||||
showSavingIcon:boolean
|
||||
presetRegex: customscript[]
|
||||
}
|
||||
|
||||
interface SeparateParameters{
|
||||
@@ -1181,6 +1183,8 @@ export interface botPreset{
|
||||
openAIPrediction?: string
|
||||
enableCustomFlags?: boolean
|
||||
customFlags?: LLMFlags[]
|
||||
image?:string
|
||||
regex?:customscript[]
|
||||
}
|
||||
|
||||
|
||||
@@ -1481,6 +1485,7 @@ export function saveCurrentPreset(){
|
||||
systemRoleReplacement: db.systemRoleReplacement,
|
||||
customFlags: safeStructuredClone(db.customFlags),
|
||||
enableCustomFlags: db.enableCustomFlags,
|
||||
regex: db.presetRegex
|
||||
}
|
||||
db.botPresets = pres
|
||||
setDatabase(db)
|
||||
@@ -1588,6 +1593,7 @@ export function setPreset(db:Database, newPres: botPreset){
|
||||
db.systemRoleReplacement = newPres.systemRoleReplacement ?? 'user'
|
||||
db.customFlags = safeStructuredClone(newPres.customFlags) ?? []
|
||||
db.enableCustomFlags = newPres.enableCustomFlags ?? false
|
||||
db.presetRegex = newPres.regex ?? []
|
||||
return db
|
||||
}
|
||||
|
||||
@@ -1613,6 +1619,12 @@ export async function downloadPreset(id:number, type:'json'|'risupreset'|'return
|
||||
pres.proxyKey = ''
|
||||
pres.textgenWebUIStreamURL= ''
|
||||
pres.textgenWebUIBlockingURL= ''
|
||||
|
||||
if((pres.image || pres.regex?.length > 0) && type !== 'return'){
|
||||
alertError("Preset with image or regexes cannot be exported for now. use RisuRealm to share the preset.")
|
||||
return
|
||||
}
|
||||
|
||||
if(type === 'json'){
|
||||
downloadFile(pres.name + "_preset.json", Buffer.from(JSON.stringify(pres, null, 2)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user