Add new asset finder and preset chain

This commit is contained in:
kwaroran
2024-12-08 21:25:57 +09:00
parent c454f8df2d
commit 40ad42ffe9
6 changed files with 84 additions and 8 deletions

View File

@@ -1,10 +1,10 @@
import { get, writable } from "svelte/store";
import { type character, type MessageGenerationInfo, type Chat } from "../storage/database.svelte";
import { type character, type MessageGenerationInfo, type Chat, changeToPreset } from "../storage/database.svelte";
import { DBState } from '../stores.svelte';
import { CharEmotion, selectedCharID } from "../stores.svelte";
import { ChatTokenizer, tokenize, tokenizeNum } from "../tokenizer";
import { language } from "../../lang";
import { alertError } from "../alert";
import { alertError, alertToast } from "../alert";
import { loadLoreBookV3Prompt } from "./lorebook.svelte";
import { findCharacterbyId, getAuthorNoteDefaultText, getPersonaPrompt, getUserName, isLastCharPunctuation, trimUntilPunctuation } from "../util";
import { requestChatData } from "./request";
@@ -109,6 +109,22 @@ export async function sendChat(chatProcessIndex = -1,arg:{
}
doingChat.set(true)
if(chatProcessIndex === -1 && DBState.db.presetChain){
const names = DBState.db.presetChain.split(' ')
const ele = names[Math.random() * names.length]
const findId = DBState.db.botPresets.findIndex((v) => {
return v.name === ele
})
if(findId === -1){
alertToast(`Cannot find preset: ${ele}`)
}
else{
changeToPreset(findId, true)
}
}
if(connectionOpen){
chatProcessStage.set(4)
const peerSafe = await peerSafeCheck()