feat: add hypav2 button

This commit is contained in:
kwaroran
2024-05-23 07:02:16 +09:00
parent 53b7771ed4
commit 5b7e66723f
4 changed files with 71 additions and 10 deletions

View File

@@ -17,6 +17,7 @@
import { getFetchData } from 'src/ts/storage/globalApi';
import { CurrentChat } from "src/ts/stores";
import { tokenize } from "src/ts/tokenizer";
import TextAreaInput from "../UI/GUI/TextAreaInput.svelte";
let btn
let input = ''
let cardExportType = ''
@@ -77,7 +78,7 @@
<div class="text-textcolor">You should accept RisuRealm's <a class="text-green-600 hover:text-green-500 transition-colors duration-200 cursor-pointer" on:click={() => {
openURL('https://sv.risuai.xyz/hub/tos')
}}>Terms of Service</a> to continue</div>
{:else if $alertStore.type !== 'select' && $alertStore.type !== 'requestdata' && $alertStore.type !== 'addchar'}
{:else if $alertStore.type !== 'select' && $alertStore.type !== 'requestdata' && $alertStore.type !== 'addchar' && $alertStore.type !== 'hypaV2'}
<span class="text-gray-300">{$alertStore.msg}</span>
{#if $alertStore.submsg}
<span class="text-gray-500 text-sm">{$alertStore.submsg}</span>
@@ -254,6 +255,47 @@
{/if}
{/await}
{/if}
{:else if $alertStore.type === 'hypaV2'}
<div class="flex flex-wrap gap-2 mb-4 max-w-full w-124">
<Button selected={generationInfoMenuIndex === 0} size="sm" on:click={() => {generationInfoMenuIndex = 0}}>
Chunks
</Button>
<Button selected={generationInfoMenuIndex === 1} size="sm" on:click={() => {generationInfoMenuIndex = 1}}>
Summarized
</Button>
<button class="ml-auto" on:click={() => {
alertStore.set({
type: 'none',
msg: ''
})
}}>✖</button>
</div>
{#if generationInfoMenuIndex === 0}
<div class="flex flex-col gap-2 w-full">
{#each $CurrentChat.hypaV2Data.chunks as chunk}
<TextAreaInput bind:value={chunk.text} />
{/each}
<Button on:click={() => {
$CurrentChat.hypaV2Data.chunks.push({
text: '',
targetId: 'all'
})
$CurrentChat.hypaV2Data.chunks = $CurrentChat.hypaV2Data.chunks
}}>+</Button>
</div>
{:else}
{#each $CurrentChat.hypaV2Data.chunks as chunk, i}
<div class="flex flex-col p-2 rounded-md border-darkborderc border">
{#if i === 0}
<span class="text-green-500">Active</span>
{:else}
<span>Inactive</span>
{/if}
<TextAreaInput bind:value={chunk.text} />
</div>
{/each}
{/if}
{:else if $alertStore.type === 'addchar'}
<div class="w-2xl flex flex-col max-w-full">

View File

@@ -7,7 +7,7 @@
import Check from "../UI/GUI/CheckInput.svelte";
import { addCharEmotion, addingEmotion, getCharImage, rmCharEmotion, selectCharImg, makeGroupImage } from "../../ts/characters";
import LoreBook from "./LoreBook/LoreBookSetting.svelte";
import { alertConfirm, alertNormal, alertSelectChar, alertTOS } from "../../ts/alert";
import { alertConfirm, alertNormal, alertSelectChar, alertTOS, showHypaV2Alert } from "../../ts/alert";
import BarIcon from "./BarIcon.svelte";
import { findCharacterbyId, getAuthorNoteDefaultText, selectMultipleFile } from "../../ts/util";
import { onDestroy } from "svelte";
@@ -672,11 +672,6 @@
<span class="text-textcolor mt-2">{language.additionalText} <Help key="additionalText" /></span>
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.additionalText}></TextAreaInput>
{#if currentChar.data.chats[currentChar.data.chatPage].supaMemoryData && currentChar.data.chats[currentChar.data.chatPage].supaMemoryData.length > 4 || currentChar.data.supaMemory}
<span class="text-textcolor">{language.SuperMemory}</span>
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.chats[currentChar.data.chatPage].supaMemoryData}></TextAreaInput>
{/if}
{#if $DataBase.showUnrecommended || currentChar.data.personality.length > 3}
<span class="text-textcolor">{language.personality} <Help key="personality" unrecommended/></span>
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.personality}></TextAreaInput>
@@ -816,6 +811,21 @@
<span> <Help key="utilityBot" name={language.utilityBot}/></span>
</div>
{#if $DataBase.supaMemoryType === 'hypaV2'}
<Button on:click={() => {
currentChar.data.chats[currentChar.data.chatPage].hypaV2Data ??= {
chunks: [],
mainChunks: []
}
showHypaV2Alert()
}}>
{language.HypaMemory} V2 Data
</Button>
{:else if currentChar.data.chats[currentChar.data.chatPage].supaMemoryData && currentChar.data.chats[currentChar.data.chatPage].supaMemoryData.length > 4 || currentChar.data.supaMemory}
<span class="text-textcolor">{language.SuperMemory}</span>
<TextAreaInput margin="both" autocomplete="off" bind:value={currentChar.data.chats[currentChar.data.chatPage].supaMemoryData}></TextAreaInput>
{/if}
{#if currentChar.data.license !== 'CC BY-NC-SA 4.0'
&& currentChar.data.license !== 'CC BY-SA 4.0'
&& currentChar.data.license !== 'CC BY-ND 4.0'

View File

@@ -6,7 +6,7 @@ import { Capacitor } from "@capacitor/core"
import { DataBase, type MessageGenerationInfo } from "./storage/database"
interface alertData{
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata'|'addchar'
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'|'requestdata'|'addchar'|'hypaV2',
msg: string,
submsg?: string
}
@@ -275,4 +275,11 @@ export function alertRequestData(info:AlertGenerationInfoStoreData){
'type': 'requestdata',
'msg': info.genInfo.generationId ?? 'none'
})
}
export function showHypaV2Alert(){
alertStore.set({
'type': 'hypaV2',
'msg': ""
})
}

View File

@@ -145,8 +145,10 @@ export async function hypaMemoryV2(
const processer = new HypaProcesser("nomic")
await processer.addText(data.chunks.map((v) => {
return "search_document: " + v.text
await processer.addText(data.chunks.filter(v => {
return v.text.trim().length > 0
}).map((v) => {
return "search_document: " + v.text.trim()
}))
let scoredResults:{[key:string]:number} = {}