Change first message to chat dependent
This commit is contained in:
@@ -249,7 +249,7 @@ export async function exportChat(page:number){
|
||||
<div class="chat">
|
||||
<h2>${char.name}</h2>
|
||||
<div>${await htmlChatParse(
|
||||
char.firstMsgIndex === -1 ? char.firstMessage : char.alternateGreetings?.[char.firstMsgIndex ?? 0]
|
||||
chat.fmIndex === -1 ? char.firstMessage : char.alternateGreetings?.[chat.fmIndex ?? 0]
|
||||
)}</div>
|
||||
</div>
|
||||
${chatContentHTML}
|
||||
@@ -513,6 +513,10 @@ export function characterFormatUpdate(index:number|character, arg:{
|
||||
db.characters[index] = cha
|
||||
setDatabase(db)
|
||||
}
|
||||
cha.chats = cha.chats.map((v) => {
|
||||
v.fmIndex ??= cha.firstMsgIndex ?? -1
|
||||
return v
|
||||
})
|
||||
return cha
|
||||
}
|
||||
|
||||
|
||||
@@ -650,7 +650,7 @@ function basicMatcher (p1:string,matcherArg:matcherArg,vars:{[key:string]:string
|
||||
}
|
||||
pointer--
|
||||
}
|
||||
return selchar.firstMsgIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[selchar.firstMsgIndex]
|
||||
return chat.fmIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[chat.fmIndex]
|
||||
}
|
||||
case 'previous_user_chat':
|
||||
case 'lastusermessage':{
|
||||
@@ -664,7 +664,7 @@ function basicMatcher (p1:string,matcherArg:matcherArg,vars:{[key:string]:string
|
||||
}
|
||||
pointer--
|
||||
}
|
||||
return selchar.firstMsgIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[selchar.firstMsgIndex]
|
||||
return chat.fmIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[chat.fmIndex]
|
||||
}
|
||||
return ''
|
||||
}
|
||||
@@ -795,7 +795,8 @@ function basicMatcher (p1:string,matcherArg:matcherArg,vars:{[key:string]:string
|
||||
}
|
||||
case 'first_msg_index':{
|
||||
const selchar = db.characters[get(selectedCharID)]
|
||||
return selchar.firstMsgIndex.toString()
|
||||
const chat = selchar.chats[selchar.chatPage]
|
||||
return chat.fmIndex.toString()
|
||||
}
|
||||
case 'blank':
|
||||
case 'none':{
|
||||
|
||||
@@ -612,7 +612,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
}
|
||||
|
||||
if(nowChatroom.type !== 'group'){
|
||||
const firstMsg = nowChatroom.firstMsgIndex === -1 ? nowChatroom.firstMessage : nowChatroom.alternateGreetings[nowChatroom.firstMsgIndex]
|
||||
const firstMsg = currentChat.fmIndex === -1 ? nowChatroom.firstMessage : nowChatroom.alternateGreetings[currentChat.fmIndex]
|
||||
|
||||
const chat:OpenAIChat = {
|
||||
role: 'assistant',
|
||||
|
||||
@@ -383,7 +383,7 @@ export async function loadLoreBookV3Prompt(){
|
||||
if(Number.isNaN(int)){
|
||||
return false
|
||||
}
|
||||
if(((char.firstMsgIndex ?? -1) + 1) !== int){
|
||||
if(((char.chats[page].fmIndex ?? -1) + 1) !== int){
|
||||
activated = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getChatVar, hasher, risuChatParser, setChatVar, type simpleCharacterArg
|
||||
import { LuaEngine, LuaFactory } from "wasmoon";
|
||||
import { DataBase, setDatabase, type Chat, type character, type groupChat } from "../storage/database";
|
||||
import { get } from "svelte/store";
|
||||
import { CurrentCharacter, CurrentChat, CurrentVariablePointer, ReloadGUIPointer, selectedCharID } from "../stores";
|
||||
import { CurrentCharacter, CurrentChat, ReloadGUIPointer, selectedCharID } from "../stores";
|
||||
import { alertError, alertInput, alertNormal } from "../alert";
|
||||
import { HypaProcesser } from "./memory/hypamemory";
|
||||
import { generateAIImage } from "./stableDiff";
|
||||
|
||||
@@ -180,7 +180,7 @@ export async function processScriptFull(char:character|groupChat|simpleCharacter
|
||||
const v = outScript.split(' ', 2)[1]
|
||||
const selchar = db.characters[get(selectedCharID)]
|
||||
const chat = selchar.chats[selchar.chatPage]
|
||||
let lastChat = selchar.firstMsgIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[selchar.firstMsgIndex]
|
||||
let lastChat = chat.fmIndex === -1 ? selchar.firstMessage : selchar.alternateGreetings[chat.fmIndex]
|
||||
let pointer = chatID - 1
|
||||
while(pointer >= 0){
|
||||
if(chat.message[pointer].role === chat.message[chatID].role){
|
||||
|
||||
@@ -1073,6 +1073,7 @@ export interface Chat{
|
||||
modules?:string[]
|
||||
id?:string
|
||||
bindedPersona?:string
|
||||
fmIndex?:number
|
||||
}
|
||||
|
||||
export interface Message{
|
||||
|
||||
@@ -40,7 +40,6 @@ export const CurrentUserIcon = writable('') as Writable<string>
|
||||
export const CurrentShowMemoryLimit = writable(false) as Writable<boolean>
|
||||
export const ShowVN = writable(false)
|
||||
export const SettingsMenuIndex = writable(-1)
|
||||
export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean})
|
||||
export const ReloadGUIPointer = writable(0)
|
||||
export const OpenRealmStore = writable(false)
|
||||
export const ShowRealmFrameStore = writable('')
|
||||
@@ -231,13 +230,6 @@ async function preInit(){
|
||||
if(getUserIcon() !== get(CurrentUserIcon)){
|
||||
CurrentUserIcon.set(getUserIcon())
|
||||
}
|
||||
|
||||
const variablePointer = get(CurrentVariablePointer)
|
||||
const currentState = structuredClone(chat?.scriptstate)
|
||||
|
||||
if(!isEqual(variablePointer, currentState)){
|
||||
CurrentVariablePointer.set(currentState)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user