[feat] depth promp

This commit is contained in:
kwaroran
2023-11-09 13:49:46 +09:00
parent d4fa526dab
commit 1d5edf710d
6 changed files with 47 additions and 4 deletions

View File

@@ -439,5 +439,6 @@ export const languageEnglish = {
defaultPrompt: "Default Prompt", defaultPrompt: "Default Prompt",
additionalText: 'Additional Description', additionalText: 'Additional Description',
seed: "Seed", seed: "Seed",
charjs: "CharacterJS" charjs: "CharacterJS",
depthPrompt: "Depth Prompt"
} }

View File

@@ -650,6 +650,12 @@
<span class="text-textcolor">{language.CharVersion}</span> <span class="text-textcolor">{language.CharVersion}</span>
<TextInput size="sm" bind:value={currentChar.data.additionalData.character_version}/> <TextInput size="sm" bind:value={currentChar.data.additionalData.character_version}/>
<span class="text-textcolor">{language.depthPrompt}</span>
<div class="flex justify-center items-center">
<NumberInput size="sm" bind:value={currentChar.data.depth_prompt.depth} additionalClass="w-12"/>
<TextInput size="sm" bind:value={currentChar.data.depth_prompt.prompt} additionalClass="flex-1"/>
</div>
<span class="text-textcolor mt-2">{language.altGreet}</span> <span class="text-textcolor mt-2">{language.altGreet}</span>
<div class="w-full max-w-full border border-selected rounded-md p-2"> <div class="w-full max-w-full border border-selected rounded-md p-2">
<table class="contain w-full max-w-full tabler mt-2"> <table class="contain w-full max-w-full tabler mt-2">

View File

@@ -301,6 +301,16 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array, mode?:'hub'|'
} }
let ext = cloneDeep(data?.extensions ?? {})
for(const key in ext){
if(key === 'risuai'){
delete ext[key]
}
if(key === 'depth_prompt'){
delete ext[key]
}
}
let char:character = { let char:character = {
name: data.name ?? '', name: data.name ?? '',
@@ -350,6 +360,7 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array, mode?:'hub'|'
private: data?.extensions?.risuai?.private ?? false, private: data?.extensions?.risuai?.private ?? false,
additionalText: data?.extensions?.risuai?.additionalText ?? '', additionalText: data?.extensions?.risuai?.additionalText ?? '',
virtualscript: data?.extensions?.risuai?.virtualscript ?? '', virtualscript: data?.extensions?.risuai?.virtualscript ?? '',
extentions: ext ?? {}
} }
db.characters.push(char) db.characters.push(char)
@@ -431,11 +442,20 @@ async function createBaseV2(char:character) {
triggerscript: char.triggerscript, triggerscript: char.triggerscript,
additionalText: char.additionalText, additionalText: char.additionalText,
virtualscript: char.virtualscript, virtualscript: char.virtualscript,
} },
depth_prompt: char.depth_prompt
} }
} }
} }
console.log(card)
if(char.extentions){
for(const key in char.extentions){
if(key === 'risuai' || key === 'depth_prompt'){
continue
}
card.data.extensions[key] = char.extentions[key]
}
}
return card return card
} }
@@ -703,6 +723,7 @@ type CharacterCardV2 = {
additionalText?:string additionalText?:string
virtualscript?:string virtualscript?:string
} }
depth_prompt?: { depth: number, prompt: string }
} }
} }
} }

View File

@@ -290,7 +290,10 @@ export function characterFormatUpdate(index:number|character){
cha.postHistoryInstructions = null cha.postHistoryInstructions = null
} }
cha.additionalText ??= '' cha.additionalText ??= ''
cha.depth_prompt ??= {
depth: 0,
prompt: ''
}
} }
else{ else{
if((!cha.characterTalks) || cha.characterTalks.length !== cha.characters.length){ if((!cha.characterTalks) || cha.characterTalks.length !== cha.characters.length){

View File

@@ -727,6 +727,16 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
formated = cipherChat(formated) formated = cipherChat(formated)
} }
if(currentChar.depth_prompt && currentChar.depth_prompt.prompt.length > 0){
//depth_prompt
const depthPrompt = currentChar.depth_prompt
formated.splice(formated.length - depthPrompt.depth, 0, {
role: 'system',
content: risuChatParser(depthPrompt.prompt, {chara: currentChar})
})
}
{ {
//token rechecking //token rechecking
let tokens = 0 let tokens = 0

View File

@@ -579,6 +579,8 @@ export interface character{
oaiVoice?:string oaiVoice?:string
virtualscript?:string virtualscript?:string
scriptstate?:{[key:string]:string|number|boolean} scriptstate?:{[key:string]:string|number|boolean}
depth_prompt?: { depth: number, prompt: string }
extentions?:{[key:string]:any}
} }