Merge branch 'main' into patch-2
This commit is contained in:
@@ -176,6 +176,7 @@ export const languageEnglish = {
|
|||||||
comfyWorkflow: "Put the API workflow of comfy UI. you can get your API workflow in comfy UI by pressing the 'Workflow > Export (API)' button. you must also put {{risu_prompt}} in you workflow text. the {{risu_prompt}} will be replaced with the prompt provided by the Risu.",
|
comfyWorkflow: "Put the API workflow of comfy UI. you can get your API workflow in comfy UI by pressing the 'Workflow > Export (API)' button. you must also put {{risu_prompt}} in you workflow text. the {{risu_prompt}} will be replaced with the prompt provided by the Risu.",
|
||||||
automaticCachePoint: "Automatically creates cache point after the chat ends, if the caching point doesn't exist.",
|
automaticCachePoint: "Automatically creates cache point after the chat ends, if the caching point doesn't exist.",
|
||||||
experimentalChatCompressionDesc: "Compresses the unused chat data and saves in seperate file. this greatly reduces the size of the chat data, and greatly improves the performance, however its experimental and can be unstable, causing issues in backup feature and more.",
|
experimentalChatCompressionDesc: "Compresses the unused chat data and saves in seperate file. this greatly reduces the size of the chat data, and greatly improves the performance, however its experimental and can be unstable, causing issues in backup feature and more.",
|
||||||
|
promptInfoInsideChatDesc: "When enabled, this stores prompt preset information in the chat metadata. The stored data includes the preset name, active toggles, and the prompt text. This may slightly increase processing time and storage usage.",
|
||||||
},
|
},
|
||||||
setup: {
|
setup: {
|
||||||
chooseProvider: "Choose AI Provider",
|
chooseProvider: "Choose AI Provider",
|
||||||
@@ -1122,4 +1123,9 @@ export const languageEnglish = {
|
|||||||
hypaMemoryV2Modal: "Hypa V2 Modal",
|
hypaMemoryV2Modal: "Hypa V2 Modal",
|
||||||
hypaMemoryV3Modal: "Hypa V3 Modal",
|
hypaMemoryV3Modal: "Hypa V3 Modal",
|
||||||
showMenuHypaMemoryModal: "Show Menu Hypa Modal",
|
showMenuHypaMemoryModal: "Show Menu Hypa Modal",
|
||||||
|
promptInfoInsideChat: "Add Prompt Info to Chat",
|
||||||
|
promptTextInfoInsideChat: "Add Prompt Text to Chat",
|
||||||
|
promptInfoEmptyMessage: "No prompt information is available for this message.",
|
||||||
|
promptInfoEmptyToggle: "No custom toggles are currently active.",
|
||||||
|
promptInfoEmptyText: "No prompt text has been saved.",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export const languageKorean = {
|
|||||||
"groupOtherBotRole": "This defines a role that is used in group chat for characters that isn't speaker.",
|
"groupOtherBotRole": "This defines a role that is used in group chat for characters that isn't speaker.",
|
||||||
"chatHTML": "A HTML that would be inserted as each chat.\n\nYou can use CBS and special tags.\n- `<risutextbox>`: a textbox that would be used to render text\n- `<risuicon>`: an icon for user or assistant\n- `<risubuttons>`: icon buttons for chat edit, translations and etc.\n- `<risugeninfo>`: generation information button.",
|
"chatHTML": "A HTML that would be inserted as each chat.\n\nYou can use CBS and special tags.\n- `<risutextbox>`: a textbox that would be used to render text\n- `<risuicon>`: an icon for user or assistant\n- `<risubuttons>`: icon buttons for chat edit, translations and etc.\n- `<risugeninfo>`: generation information button.",
|
||||||
"autoTranslateCachedOnly": "자동 번역 옵션이 켜진 상태에서 활성화하면, 사용자가 이전에 번역한 메시지만 자동으로 번역됩니다.",
|
"autoTranslateCachedOnly": "자동 번역 옵션이 켜진 상태에서 활성화하면, 사용자가 이전에 번역한 메시지만 자동으로 번역됩니다.",
|
||||||
|
"promptInfoInsideChatDesc": "활성화되면 채팅 메타데이터에 프롬프트 프리셋 정보를 저장합니다. 저장되는 정보는 프롬프트 프리셋 이름과 활성화된 토글, 그리고 프롬프트 텍스트입니다. 약간의 처리 시간과 용량을 차지할 수 있습니다.",
|
||||||
},
|
},
|
||||||
"setup": {
|
"setup": {
|
||||||
"chooseProvider": "AI 제공자를 선택해 주세요",
|
"chooseProvider": "AI 제공자를 선택해 주세요",
|
||||||
@@ -989,4 +990,9 @@ export const languageKorean = {
|
|||||||
"hypaMemoryV2Modal": "하이파 V2 모달",
|
"hypaMemoryV2Modal": "하이파 V2 모달",
|
||||||
"hypaMemoryV3Modal": "하이파 V3 모달",
|
"hypaMemoryV3Modal": "하이파 V3 모달",
|
||||||
"showMenuHypaMemoryModal": "메뉴에서 하이파 모달 보이기",
|
"showMenuHypaMemoryModal": "메뉴에서 하이파 모달 보이기",
|
||||||
|
"promptInfoInsideChat": "채팅에 프롬프트 정보 추가하기",
|
||||||
|
"promptTextInfoInsideChat": "채팅에 프롬프트 텍스트 정보 추가하기",
|
||||||
|
"promptInfoEmptyMessage": "이 메시지에 대한 프롬프트 정보가 없습니다.",
|
||||||
|
"promptInfoEmptyToggle": "활성화된 커스텀 토글이 없습니다.",
|
||||||
|
"promptInfoEmptyText": "저장된 프롬프트 텍스트가 없습니다.",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,6 +224,9 @@
|
|||||||
<Button selected={generationInfoMenuIndex === 2} size="sm" onclick={() => {generationInfoMenuIndex = 2}}>
|
<Button selected={generationInfoMenuIndex === 2} size="sm" onclick={() => {generationInfoMenuIndex = 2}}>
|
||||||
{language.log}
|
{language.log}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button selected={generationInfoMenuIndex === 3} size="sm" onclick={() => {generationInfoMenuIndex = 3}}>
|
||||||
|
{language.prompt}
|
||||||
|
</Button>
|
||||||
<button class="ml-auto" onclick={() => {
|
<button class="ml-auto" onclick={() => {
|
||||||
alertStore.set({
|
alertStore.set({
|
||||||
type: 'none',
|
type: 'none',
|
||||||
@@ -294,6 +297,42 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if generationInfoMenuIndex === 3}
|
||||||
|
{#if Object.keys(DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo || {}).length === 0}
|
||||||
|
<div class="text-gray-300 text-lg mt-2">{language.promptInfoEmptyMessage}</div>
|
||||||
|
{:else}
|
||||||
|
<div class="grid grid-cols-2 gap-y-2 gap-x-4 mt-4">
|
||||||
|
<span class="text-blue-500">Preset Name</span>
|
||||||
|
<span class="text-blue-500 justify-self-end">{DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo.promptName}</span>
|
||||||
|
<span class="text-purple-500">Toggles</span>
|
||||||
|
<div class="col-span-2 max-h-32 overflow-y-auto border border-stone-500 rounded p-2 bg-gray-900">
|
||||||
|
{#if DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo.promptToggles.length === 0}
|
||||||
|
<div class="text-gray-500 italic text-center py-4">{language.promptInfoEmptyToggle}</div>
|
||||||
|
{:else}
|
||||||
|
<div class="grid grid-cols-2 gap-y-2 gap-x-4">
|
||||||
|
{#each DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo.promptToggles as toggle}
|
||||||
|
<span class="text-gray-200 truncate">{toggle.key}</span>
|
||||||
|
<span class="text-gray-200 justify-self-end truncate">{toggle.value}</span>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<span class="text-red-500">Prompt Text</span>
|
||||||
|
<div class="col-span-2 max-h-80 overflow-y-auto border border-stone-500 rounded p-4 bg-gray-900">
|
||||||
|
{#if !DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo.promptText}
|
||||||
|
<div class="text-gray-500 italic text-center py-4">{language.promptInfoEmptyText}</div>
|
||||||
|
{:else}
|
||||||
|
{#each DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message[$alertGenerationInfoStore.idx].promptInfo.promptText as block}
|
||||||
|
<div class="mb-2">
|
||||||
|
<div class="font-bold text-gray-600">{block.role}</div>
|
||||||
|
<pre class="whitespace-pre-wrap text-sm bg-stone-900 p-2 rounded border border-stone-500">{block.content}</pre>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
{:else if $alertStore.type === 'hypaV2'}
|
{:else if $alertStore.type === 'hypaV2'}
|
||||||
<div class="flex flex-wrap gap-2 mb-4 max-w-full w-124">
|
<div class="flex flex-wrap gap-2 mb-4 max-w-full w-124">
|
||||||
<Button selected={generationInfoMenuIndex === 0} size="sm" onclick={() => {generationInfoMenuIndex = 0}}>
|
<Button selected={generationInfoMenuIndex === 0} size="sm" onclick={() => {generationInfoMenuIndex = 0}}>
|
||||||
|
|||||||
@@ -190,6 +190,17 @@
|
|||||||
<Check bind:check={DBState.db.enableDevTools} name={language.enableDevTools}>
|
<Check bind:check={DBState.db.enableDevTools} name={language.enableDevTools}>
|
||||||
</Check>
|
</Check>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center mt-4">
|
||||||
|
<Check bind:check={DBState.db.promptInfoInsideChat} name={language.promptInfoInsideChat}>
|
||||||
|
<Help key="promptInfoInsideChatDesc"/>
|
||||||
|
</Check>
|
||||||
|
</div>
|
||||||
|
{#if DBState.db.promptInfoInsideChat}
|
||||||
|
<div class="flex items-center mt-4">
|
||||||
|
<Check bind:check={DBState.db.promptTextInfoInsideChat} name={language.promptTextInfoInsideChat}>
|
||||||
|
</Check>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="flex items-center mt-4">
|
<div class="flex items-center mt-4">
|
||||||
<Check bind:check={DBState.db.dynamicAssets} name={language.dynamicAssets}>
|
<Check bind:check={DBState.db.dynamicAssets} name={language.dynamicAssets}>
|
||||||
<Help key="dynamicAssets"/>
|
<Help key="dynamicAssets"/>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable } from "svelte/store";
|
||||||
import { type character, type MessageGenerationInfo, type Chat, changeToPreset, setCurrentChat } from "../storage/database.svelte";
|
import { type character, type MessageGenerationInfo, type Chat, type MessagePresetInfo, changeToPreset, setCurrentChat } from "../storage/database.svelte";
|
||||||
import { DBState } from '../stores.svelte';
|
import { DBState } from '../stores.svelte';
|
||||||
import { CharEmotion, selectedCharID } from "../stores.svelte";
|
import { CharEmotion, selectedCharID } from "../stores.svelte";
|
||||||
import { ChatTokenizer, tokenize, tokenizeNum } from "../tokenizer";
|
import { ChatTokenizer, tokenize, tokenizeNum } from "../tokenizer";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { alertError, alertToast } from "../alert";
|
import { alertError, alertToast } from "../alert";
|
||||||
import { loadLoreBookV3Prompt } from "./lorebook.svelte";
|
import { loadLoreBookV3Prompt } from "./lorebook.svelte";
|
||||||
import { findCharacterbyId, getAuthorNoteDefaultText, getPersonaPrompt, getUserName, isLastCharPunctuation, trimUntilPunctuation } from "../util";
|
import { findCharacterbyId, getAuthorNoteDefaultText, getPersonaPrompt, getUserName, isLastCharPunctuation, trimUntilPunctuation, parseToggleSyntax } from "../util";
|
||||||
import { requestChatData } from "./request";
|
import { requestChatData } from "./request";
|
||||||
import { stableDiff } from "./stableDiff";
|
import { stableDiff } from "./stableDiff";
|
||||||
import { processScript, processScriptFull, risuChatParser } from "./scripts";
|
import { processScript, processScriptFull, risuChatParser } from "./scripts";
|
||||||
@@ -30,7 +30,7 @@ import { runLuaEditTrigger } from "./lua";
|
|||||||
import { getGlobalChatVar, parseChatML } from "../parser.svelte";
|
import { getGlobalChatVar, parseChatML } from "../parser.svelte";
|
||||||
import { getModelInfo, LLMFlags } from "../model/modellist";
|
import { getModelInfo, LLMFlags } from "../model/modellist";
|
||||||
import { hypaMemoryV3 } from "./memory/hypav3";
|
import { hypaMemoryV3 } from "./memory/hypav3";
|
||||||
import { getModuleAssets } from "./modules";
|
import { getModuleAssets, getModuleToggles } from "./modules";
|
||||||
import { getFileSrc, readImage } from "../globalApi.svelte";
|
import { getFileSrc, readImage } from "../globalApi.svelte";
|
||||||
|
|
||||||
export interface OpenAIChat{
|
export interface OpenAIChat{
|
||||||
@@ -186,6 +186,39 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
return v
|
return v
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────
|
||||||
|
// Snapshot preset name & toggles before sending a message.
|
||||||
|
// Ensures correct metadata is recorded, even if presets
|
||||||
|
// change immediately after clicking "send".
|
||||||
|
//
|
||||||
|
// Used later in promptInfo assembly (e.g. promptInfo.promptText)
|
||||||
|
// ─────────────────────────────────────────────────────────
|
||||||
|
let promptInfo: MessagePresetInfo = {}
|
||||||
|
let initialPresetNameForPromptInfo = null
|
||||||
|
let initialPromptTogglesForPromptInfo: {
|
||||||
|
key: string,
|
||||||
|
value: string,
|
||||||
|
}[] = []
|
||||||
|
if(DBState.db.promptInfoInsideChat){
|
||||||
|
initialPresetNameForPromptInfo = DBState.db.botPresets[DBState.db.botPresetsId]?.name ?? ''
|
||||||
|
initialPromptTogglesForPromptInfo = parseToggleSyntax(DBState.db.customPromptTemplateToggle + getModuleToggles())
|
||||||
|
.flatMap(toggle => {
|
||||||
|
const raw = DBState.db.globalChatVariables[`toggle_${toggle.key}`]
|
||||||
|
if (toggle.type === 'select' || toggle.type === 'text') {
|
||||||
|
return [{ key: toggle.value, value: toggle.options[raw] }];
|
||||||
|
}
|
||||||
|
if (raw === '1') {
|
||||||
|
return [{ key: toggle.value, value: 'ON' }];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
})
|
||||||
|
|
||||||
|
promptInfo = {
|
||||||
|
promptName: initialPresetNameForPromptInfo,
|
||||||
|
promptToggles: initialPromptTogglesForPromptInfo,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
let currentChar:character
|
let currentChar:character
|
||||||
let caculatedChatTokens = 0
|
let caculatedChatTokens = 0
|
||||||
@@ -367,13 +400,15 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(currentChat.note){
|
if(currentChat.note){
|
||||||
unformated.authorNote.push({
|
unformated.authorNote.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(currentChat.note, {chara: currentChar})
|
content: risuChatParser(currentChat.note, {chara: currentChar}),
|
||||||
|
memo: 'authornote'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else if(getAuthorNoteDefaultText() !== ''){
|
else if(getAuthorNoteDefaultText() !== ''){
|
||||||
unformated.authorNote.push({
|
unformated.authorNote.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar})
|
content: risuChatParser(getAuthorNoteDefaultText(), {chara: currentChar}),
|
||||||
|
memo: 'authornote'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +438,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
|
|
||||||
unformated.description.push({
|
unformated.description.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: description
|
content: description,
|
||||||
|
memo: 'description',
|
||||||
})
|
})
|
||||||
|
|
||||||
if(nowChatroom.type === 'group'){
|
if(nowChatroom.type === 'group'){
|
||||||
@@ -424,7 +460,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const lorebook of normalActives){
|
for(const lorebook of normalActives){
|
||||||
unformated.lorebook.push({
|
unformated.lorebook.push({
|
||||||
role: lorebook.role,
|
role: lorebook.role,
|
||||||
content: risuChatParser(lorebook.prompt, {chara: currentChar})
|
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
|
||||||
|
memo: 'lore',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +485,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(DBState.db.personaPrompt){
|
if(DBState.db.personaPrompt){
|
||||||
unformated.personaPrompt.push({
|
unformated.personaPrompt.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: risuChatParser(getPersonaPrompt(), {chara: currentChar})
|
content: risuChatParser(getPersonaPrompt(), {chara: currentChar}),
|
||||||
|
memo: 'persona',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +511,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
for(const lorebook of postEverythingLorebooks){
|
for(const lorebook of postEverythingLorebooks){
|
||||||
unformated.postEverything.push({
|
unformated.postEverything.push({
|
||||||
role: lorebook.role,
|
role: lorebook.role,
|
||||||
content: risuChatParser(lorebook.prompt, {chara: currentChar})
|
content: risuChatParser(lorebook.prompt, {chara: currentChar}),
|
||||||
|
memo: 'postEverything',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1061,6 +1100,12 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MemoType = 'persona' | 'description' | 'authornote' | 'supaMemory';
|
||||||
|
const promptBodyMap: Record<MemoType, string[]> = { persona: [], description: [], authornote: [], supaMemory: [] };
|
||||||
|
function pushPromptInfoBody(memo: MemoType, fmt: string) {
|
||||||
|
promptBodyMap[memo].push(risuChatParser(fmt));
|
||||||
|
}
|
||||||
|
|
||||||
if(promptTemplate){
|
if(promptTemplate){
|
||||||
const template = promptTemplate
|
const template = promptTemplate
|
||||||
|
|
||||||
@@ -1071,6 +1116,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
|
pushPromptInfoBody(card.type, card.innerFormat)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1082,6 +1131,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
|
pushPromptInfoBody(card.type, card.innerFormat)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,6 +1146,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
pmt[i].content = risuChatParser(positionParser(card.innerFormat), {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||||
|
|
||||||
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
|
pushPromptInfoBody(card.type, card.innerFormat)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1208,6 +1265,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
if(card.innerFormat && pmt.length > 0){
|
if(card.innerFormat && pmt.length > 0){
|
||||||
for(let i=0;i<pmt.length;i++){
|
for(let i=0;i<pmt.length;i++){
|
||||||
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content)
|
||||||
|
|
||||||
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
|
pushPromptInfoBody('supaMemory', card.innerFormat)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,6 +1388,29 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function isPromptMemo(m: string): m is MemoType {
|
||||||
|
return ['persona', 'description', 'authornote', 'supaMemory'].includes(m);
|
||||||
|
}
|
||||||
|
if(DBState.db.promptInfoInsideChat && DBState.db.promptTextInfoInsideChat){
|
||||||
|
const promptBodyInfo: OpenAIChat[] = formated.flatMap(format => {
|
||||||
|
if (isPromptMemo(format.memo)) {
|
||||||
|
return promptBodyMap[format.memo].map(content => ({
|
||||||
|
role: format.role,
|
||||||
|
content,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format.memo == null) {
|
||||||
|
return [format]
|
||||||
|
}
|
||||||
|
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
|
||||||
|
promptInfo.promptText = promptBodyInfo
|
||||||
|
}
|
||||||
|
|
||||||
let result = ''
|
let result = ''
|
||||||
let emoChanged = false
|
let emoChanged = false
|
||||||
let resendChat = false
|
let resendChat = false
|
||||||
@@ -1353,6 +1437,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
saying: currentChar.chaId,
|
saying: currentChar.chaId,
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
generationInfo,
|
generationInfo,
|
||||||
|
promptInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
DBState.db.characters[selectedChar].chats[selectedChat].isStreaming = true
|
DBState.db.characters[selectedChar].chats[selectedChat].isStreaming = true
|
||||||
@@ -1432,7 +1517,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
data: result,
|
data: result,
|
||||||
saying: currentChar.chaId,
|
saying: currentChar.chaId,
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
generationInfo
|
generationInfo,
|
||||||
|
promptInfo,
|
||||||
}
|
}
|
||||||
if(inlayResult.promise){
|
if(inlayResult.promise){
|
||||||
const p = await inlayResult.promise
|
const p = await inlayResult.promise
|
||||||
@@ -1445,7 +1531,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
data: result,
|
data: result,
|
||||||
saying: currentChar.chaId,
|
saying: currentChar.chaId,
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
generationInfo
|
generationInfo,
|
||||||
|
promptInfo,
|
||||||
})
|
})
|
||||||
const ind = DBState.db.characters[selectedChar].chats[selectedChat].message.length - 1
|
const ind = DBState.db.characters[selectedChar].chats[selectedChat].message.length - 1
|
||||||
if(inlayResult.promise){
|
if(inlayResult.promise){
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getChatVar, hasher, setChatVar, getGlobalChatVar, type simpleCharacterArgument } from "../parser.svelte";
|
import { getChatVar, hasher, setChatVar, getGlobalChatVar, type simpleCharacterArgument, risuChatParser } from "../parser.svelte";
|
||||||
import { LuaEngine, LuaFactory } from "wasmoon";
|
import { LuaEngine, LuaFactory } from "wasmoon";
|
||||||
import { getCurrentCharacter, getCurrentChat, getDatabase, setCurrentChat, setDatabase, type Chat, type character, type groupChat } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setDatabase, type Chat, type character, type groupChat } from "../storage/database.svelte";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
import { ReloadGUIPointer, selectedCharID } from "../stores.svelte";
|
import { ReloadGUIPointer, selectedCharID } from "../stores.svelte";
|
||||||
import { alertSelect, alertError, alertInput, alertNormal } from "../alert";
|
import { alertSelect, alertError, alertInput, alertNormal } from "../alert";
|
||||||
@@ -14,6 +14,7 @@ import { getModuleTriggers } from "./modules";
|
|||||||
import { Mutex } from "../mutex";
|
import { Mutex } from "../mutex";
|
||||||
import { tokenize } from "../tokenizer";
|
import { tokenize } from "../tokenizer";
|
||||||
import { fetchNative } from "../globalApi.svelte";
|
import { fetchNative } from "../globalApi.svelte";
|
||||||
|
import { getPersonaPrompt, getUserName } from '../util';
|
||||||
|
|
||||||
let luaFactory:LuaFactory
|
let luaFactory:LuaFactory
|
||||||
let LuaSafeIds = new Set<string>()
|
let LuaSafeIds = new Set<string>()
|
||||||
@@ -460,6 +461,26 @@ export async function runLua(code:string, arg:{
|
|||||||
return char.firstMessage
|
return char.firstMessage
|
||||||
})
|
})
|
||||||
|
|
||||||
|
luaEngine.global.set('getPersonaName', (id:string) => {
|
||||||
|
if(!LuaSafeIds.has(id)){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return getUserName()
|
||||||
|
})
|
||||||
|
|
||||||
|
luaEngine.global.set('getPersonaDescription', (id:string) => {
|
||||||
|
if(!LuaSafeIds.has(id)){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = getDatabase()
|
||||||
|
const selectedChar = get(selectedCharID)
|
||||||
|
const char = db.characters[selectedChar]
|
||||||
|
|
||||||
|
return risuChatParser(getPersonaPrompt(), { chara: char })
|
||||||
|
})
|
||||||
|
|
||||||
luaEngine.global.set('getBackgroundEmbedding', async (id:string) => {
|
luaEngine.global.set('getBackgroundEmbedding', async (id:string) => {
|
||||||
if(!LuaSafeIds.has(id)){
|
if(!LuaSafeIds.has(id)){
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1023,6 +1023,9 @@ export interface Database{
|
|||||||
}[]
|
}[]
|
||||||
igpPrompt:string
|
igpPrompt:string
|
||||||
useTokenizerCaching:boolean
|
useTokenizerCaching:boolean
|
||||||
|
showMenuHypaMemoryModal:boolean
|
||||||
|
promptInfoInsideChat:boolean
|
||||||
|
promptTextInfoInsideChat:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SeparateParameters{
|
interface SeparateParameters{
|
||||||
@@ -1501,6 +1504,7 @@ export interface Message{
|
|||||||
chatId?:string
|
chatId?:string
|
||||||
time?: number
|
time?: number
|
||||||
generationInfo?: MessageGenerationInfo
|
generationInfo?: MessageGenerationInfo
|
||||||
|
promptInfo?: MessagePresetInfo
|
||||||
name?:string
|
name?:string
|
||||||
otherUser?:boolean
|
otherUser?:boolean
|
||||||
}
|
}
|
||||||
@@ -1513,6 +1517,12 @@ export interface MessageGenerationInfo{
|
|||||||
maxContext?: number
|
maxContext?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MessagePresetInfo{
|
||||||
|
promptName?: string,
|
||||||
|
promptToggles?: {key: string, value: string}[],
|
||||||
|
promptText?: OpenAIChat[],
|
||||||
|
}
|
||||||
|
|
||||||
interface AINsettings{
|
interface AINsettings{
|
||||||
top_p: number,
|
top_p: number,
|
||||||
rep_pen: number,
|
rep_pen: number,
|
||||||
@@ -1879,6 +1889,7 @@ import type { Parameter } from '../process/request';
|
|||||||
import type { HypaModel } from '../process/memory/hypamemory';
|
import type { HypaModel } from '../process/memory/hypamemory';
|
||||||
import type { SerializableHypaV3Data } from '../process/memory/hypav3';
|
import type { SerializableHypaV3Data } from '../process/memory/hypav3';
|
||||||
import { defaultHotkeys, type Hotkey } from '../defaulthotkeys';
|
import { defaultHotkeys, type Hotkey } from '../defaulthotkeys';
|
||||||
|
import type { OpenAIChat } from '../process/index.svelte';
|
||||||
|
|
||||||
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
export async function downloadPreset(id:number, type:'json'|'risupreset'|'return' = 'json'){
|
||||||
saveCurrentPreset()
|
saveCurrentPreset()
|
||||||
|
|||||||
Reference in New Issue
Block a user