Merge remote-tracking branch 'upstream/main'

This commit is contained in:
LightningHyperBlaze45654
2024-12-08 20:08:25 -08:00
30 changed files with 887 additions and 298 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,23 @@ export async function sendChat(chatProcessIndex = -1,arg:{
}
doingChat.set(true)
if(chatProcessIndex === -1 && DBState.db.presetChain){
const names = DBState.db.presetChain.split(',').map((v) => v.trim())
const randomSelect = Math.floor(Math.random() * names.length)
const ele = names[randomSelect]
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()
@@ -1396,7 +1413,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
}
if(DBState.db.emotionProcesser === 'embedding'){
const hypaProcesser = new HypaProcesser('MiniLM')
const hypaProcesser = new HypaProcesser()
await hypaProcesser.addText(emotionList.map((v) => 'emotion:' + v))
let searched = (await hypaProcesser.similaritySearchScored(result)).map((v) => {
v[0] = v[0].replace("emotion:",'')