diff --git a/src/lang/en.ts b/src/lang/en.ts
index eba5a18d..46e20ea7 100644
--- a/src/lang/en.ts
+++ b/src/lang/en.ts
@@ -414,4 +414,5 @@ export const languageEnglish = {
HypaMemory: "HypaMemory",
ToggleHypaMemory: "Toggle HypaMemory",
resetPromptTemplateConfirm: "Do you really want to reset prompt template?",
+ emotionMethod: "Emotion Method",
}
\ No newline at end of file
diff --git a/src/lib/Setting/Pages/OtherBotSettings.svelte b/src/lib/Setting/Pages/OtherBotSettings.svelte
index 1c256485..fc3864f6 100644
--- a/src/lib/Setting/Pages/OtherBotSettings.svelte
+++ b/src/lib/Setting/Pages/OtherBotSettings.svelte
@@ -14,7 +14,7 @@
{language.imageGeneration}
-{language.provider}
+{language.imageGeneration} {language.provider}
None
Stable Diffusion WebUI
@@ -64,6 +64,14 @@
VOICEVOX URL
+{language.emotionImage}
+
+{language.emotionMethod}
+
+ Ax. Model
+ MiniLM-L6-v2
+
+
{language.SuperMemory}
{language.SuperMemory} {language.model}
diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts
index 02b3a878..430903de 100644
--- a/src/ts/process/index.ts
+++ b/src/ts/process/index.ts
@@ -16,6 +16,7 @@ import { v4 } from "uuid";
import { clone, cloneDeep } from "lodash";
import { groupOrder } from "./group";
import { runTrigger, type additonalSysPrompt } from "./triggers";
+import { HypaProcesser } from "./memory/hypamemory";
export interface OpenAIChat{
role: 'system'|'user'|'assistant'|'function'
@@ -762,19 +763,9 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
if(currentChar.viewScreen === 'emotion' && (!emoChanged) && (abortSignal.aborted === false)){
let currentEmotion = currentChar.emotionImages
-
- function shuffleArray(array:string[]) {
- for (let i = array.length - 1; i > 0; i--) {
- const j = Math.floor(Math.random() * (i + 1));
- [array[i], array[j]] = [array[j], array[i]];
- }
- return array
- }
-
let emotionList = currentEmotion.map((a) => {
return a[0]
})
-
let charemotions = get(CharEmotion)
let tempEmotion = charemotions[currentChar.chaId]
@@ -785,6 +776,61 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
tempEmotion.splice(0, 1)
}
+ if(db.emotionProcesser === 'embedding'){
+ const hypaProcesser = new HypaProcesser('MiniLM')
+ await hypaProcesser.addText(emotionList.map((v) => 'emotion:' + v))
+ let searched = (await hypaProcesser.similaritySearchScored(result)).map((v) => {
+ v[0] = v[0].replace("emotion:",'')
+ return v
+ })
+
+ //give panaltys
+ for(let i =0;i {
+ return v[0] === emo[0]
+ })
+
+ const modifier = ((5 - ((tempEmotion.length - (i + 1))))) / 200
+
+ if(index !== -1){
+ searched[index][1] -= modifier
+ }
+ }
+
+ //make a sorted array by score
+ const emoresult = searched.sort((a,b) => {
+ return b[1] - a[1]
+ }).map((v) => {
+ return v[0]
+ })
+
+ console.log(searched)
+
+ for(const emo of currentEmotion){
+ if(emo[0] === emoresult[0]){
+ const emos:[string, string,number] = [emo[0], emo[1], Date.now()]
+ tempEmotion.push(emos)
+ charemotions[currentChar.chaId] = tempEmotion
+ CharEmotion.set(charemotions)
+ break
+ }
+ }
+
+
+
+ return true
+ }
+
+ function shuffleArray(array:string[]) {
+ for (let i = array.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [array[i], array[j]] = [array[j], array[i]];
+ }
+ return array
+ }
+
let emobias:{[key:number]:number} = {}
for(const emo of emotionList){
diff --git a/src/ts/process/memory/hypamemory.ts b/src/ts/process/memory/hypamemory.ts
index 7b43d39a..47f00793 100644
--- a/src/ts/process/memory/hypamemory.ts
+++ b/src/ts/process/memory/hypamemory.ts
@@ -122,12 +122,15 @@ export class HypaProcesser{
async similaritySearch(query: string) {
const results = await this.similaritySearchVectorWithScore((await this.getEmbeds(query))[0],);
-
- console.log(results)
return results.map((result) => result[0]);
}
- async similaritySearchVectorWithScore(
+ async similaritySearchScored(query: string) {
+ const results = await this.similaritySearchVectorWithScore((await this.getEmbeds(query))[0],);
+ return results
+ }
+
+ private async similaritySearchVectorWithScore(
query: number[],
): Promise<[string, number][]> {
const memoryVectors = this.vectors
diff --git a/src/ts/storage/database.ts b/src/ts/storage/database.ts
index d71dc196..50f6b3fa 100644
--- a/src/ts/storage/database.ts
+++ b/src/ts/storage/database.ts
@@ -304,6 +304,7 @@ export function setDatabase(data:Database){
data.NAIsettings.starter ??= ""
data.hypaModel ??= 'MiniLM'
data.mancerHeader ??= ''
+ data.emotionProcesser ??= 'submodel'
changeLanguage(data.language)
DataBase.set(data)
}
@@ -623,6 +624,7 @@ export interface Database{
hypaModel:'ada'|'MiniLM'
saveTime?:number
mancerHeader:string
+ emotionProcesser:'submodel'|'embedding'
}
interface hordeConfig{