feat: reintroduce module integration
This commit is contained in:
@@ -10,7 +10,7 @@ import { SizeStore, selectedCharID } from './stores.svelte';
|
||||
import { calcString } from './process/infunctions';
|
||||
import { findCharacterbyId, getPersonaPrompt, getUserIcon, getUserName, parseKeyValue, sfc32, sleep, uuidtoNumber } from './util';
|
||||
import { getInlayAsset } from './process/files/inlays';
|
||||
import { getModuleAssets, getModuleLorebooks } from './process/modules';
|
||||
import { getModuleAssets, getModuleLorebooks, getModules } from './process/modules';
|
||||
import type { OpenAIChat } from './process/index.svelte';
|
||||
import hljs from 'highlight.js/lib/core'
|
||||
import 'highlight.js/styles/atom-one-dark.min.css'
|
||||
@@ -1531,16 +1531,13 @@ function basicMatcher (p1:string,matcherArg:matcherArg,vars:{[key:string]:string
|
||||
return dateTimeFormat(arra[1],t)
|
||||
}
|
||||
case 'module_enabled':{
|
||||
const selchar = db.characters[get(selectedCharID)]
|
||||
let enabledChatModules:string[] = []
|
||||
if(!selchar){
|
||||
enabledChatModules = selchar.chats[selchar.chatPage].modules ?? []
|
||||
|
||||
const modules = getModules()
|
||||
for(const module of modules){
|
||||
if(module.namespace === arra[1]){
|
||||
return '1'
|
||||
}
|
||||
}
|
||||
const moduleId = db.modules.find((f) => {
|
||||
return f.name === arra[1]
|
||||
}).id
|
||||
return (db.enabledModules.includes(moduleId) || enabledChatModules.includes(moduleId)) ? '1' : '0'
|
||||
return '0'
|
||||
}
|
||||
case 'filter':{
|
||||
const array = parseArray(arra[1])
|
||||
|
||||
@@ -268,7 +268,20 @@ function getModuleByIds(ids:string[]){
|
||||
modules.push(module)
|
||||
}
|
||||
}
|
||||
return modules
|
||||
return deduplicateModuleById(modules)
|
||||
}
|
||||
|
||||
function deduplicateModuleById(modules:RisuModule[]){
|
||||
let ids:string[] = []
|
||||
let newModules:RisuModule[] = []
|
||||
for(let i=0;i<modules.length;i++){
|
||||
if(ids.includes(modules[i].id)){
|
||||
continue
|
||||
}
|
||||
ids.push(modules[i].id)
|
||||
newModules.push(modules[i])
|
||||
}
|
||||
return newModules
|
||||
}
|
||||
|
||||
let lastModules = ''
|
||||
@@ -280,6 +293,10 @@ export function getModules(){
|
||||
if (currentChat){
|
||||
ids = ids.concat(currentChat.modules ?? [])
|
||||
}
|
||||
if(db.moduleIntergration){
|
||||
const intList = db.moduleIntergration.split(',').map((s) => s.trim())
|
||||
ids = ids.concat(intList)
|
||||
}
|
||||
const idsJoined = ids.join('-')
|
||||
if(lastModules === idsJoined){
|
||||
return lastModuleData
|
||||
@@ -440,4 +457,9 @@ export function moduleUpdate(){
|
||||
ReloadGUIPointer.set(get(ReloadGUIPointer) + 1)
|
||||
lastModuleIds = ids
|
||||
}
|
||||
}
|
||||
|
||||
export function refreshModules(){
|
||||
lastModules = ''
|
||||
lastModuleData = []
|
||||
}
|
||||
@@ -115,6 +115,7 @@ $effect.root(() => {
|
||||
DBState?.db?.characters?.[selIdState.selId]?.chats?.[DBState?.db?.characters?.[selIdState.selId]?.chatPage]?.modules?.length
|
||||
DBState?.db?.characters?.[selIdState.selId]?.hideChatIcon
|
||||
DBState?.db?.characters?.[selIdState.selId]?.backgroundHTML
|
||||
DBState?.db?.moduleIntergration
|
||||
moduleUpdate()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user