refactor: cleanup lore local activation
This commit is contained in:
@@ -37,25 +37,14 @@
|
|||||||
let tokens = $state(0)
|
let tokens = $state(0)
|
||||||
|
|
||||||
function isLocallyActivated(book: loreBook){
|
function isLocallyActivated(book: loreBook){
|
||||||
return getCurrentChat()?.localLore.some(e =>
|
return book.id ? getCurrentChat()?.localLore.some(e => e.id === book.id) : false
|
||||||
e.id === book.id &&
|
|
||||||
e.alwaysActive
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
function activateLocally(book: loreBook){
|
function activateLocally(book: loreBook){
|
||||||
const chat = getCurrentChat()
|
|
||||||
let childLore: loreBook | undefined
|
|
||||||
|
|
||||||
if(!book.id){
|
if(!book.id){
|
||||||
book.id = v4()
|
book.id = v4()
|
||||||
}else{
|
|
||||||
childLore = chat.localLore.find(e => e.id === book.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(childLore){
|
const childLore: loreBook = {
|
||||||
childLore.alwaysActive = true
|
|
||||||
}else{
|
|
||||||
childLore = {
|
|
||||||
key: '',
|
key: '',
|
||||||
comment: '',
|
comment: '',
|
||||||
content: '',
|
content: '',
|
||||||
@@ -66,8 +55,7 @@
|
|||||||
selective: false,
|
selective: false,
|
||||||
id: book.id,
|
id: book.id,
|
||||||
}
|
}
|
||||||
chat.localLore.push(childLore)
|
getCurrentChat().localLore.push(childLore)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function deactivateLocally(book: loreBook){
|
function deactivateLocally(book: loreBook){
|
||||||
if(!book.id) return
|
if(!book.id) return
|
||||||
|
|||||||
Reference in New Issue
Block a user