Fix typo
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ArrowLeft, PlusIcon } from "lucide-svelte";
|
import { ArrowLeft, PlusIcon } from "lucide-svelte";
|
||||||
import { language } from "src/lang";
|
import { language } from "src/lang";
|
||||||
import ProomptItem from "src/lib/UI/ProomptItem.svelte";
|
import PromptDataItem from "src/lib/UI/PromptDataItem.svelte";
|
||||||
import { tokenizePreset, type Proompt } from "src/ts/process/proompt";
|
import { tokenizePreset, type PromptItem } from "src/ts/process/prompt";
|
||||||
import { templateCheck } from "src/ts/process/templates/templateCheck";
|
import { templateCheck } from "src/ts/process/templates/templateCheck";
|
||||||
import { DataBase } from "src/ts/storage/database";
|
import { DataBase } from "src/ts/storage/database";
|
||||||
import Check from "src/lib/UI/GUI/CheckInput.svelte";
|
import Check from "src/lib/UI/GUI/CheckInput.svelte";
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
executeTokenize($DataBase.promptTemplate)
|
executeTokenize($DataBase.promptTemplate)
|
||||||
let subMenu = 0
|
let subMenu = 0
|
||||||
|
|
||||||
async function executeTokenize(prest: Proompt[]){
|
async function executeTokenize(prest: PromptItem[]){
|
||||||
tokens = await tokenizePreset(prest, true)
|
tokens = await tokenizePreset(prest, true)
|
||||||
extokens = await tokenizePreset(prest, false)
|
extokens = await tokenizePreset(prest, false)
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#key sorted}
|
{#key sorted}
|
||||||
{#each $DataBase.promptTemplate as proompt, i}
|
{#each $DataBase.promptTemplate as proompt, i}
|
||||||
<ProomptItem bind:proompt={proompt} onRemove={() => {
|
<PromptDataItem bind:promptItem={proompt} onRemove={() => {
|
||||||
let templates = $DataBase.promptTemplate
|
let templates = $DataBase.promptTemplate
|
||||||
templates.splice(i, 1)
|
templates.splice(i, 1)
|
||||||
$DataBase.promptTemplate = templates
|
$DataBase.promptTemplate = templates
|
||||||
@@ -103,18 +103,15 @@
|
|||||||
<span class="text-textcolor2 text-sm mt-2">{tokens} {language.fixedTokens}</span>
|
<span class="text-textcolor2 text-sm mt-2">{tokens} {language.fixedTokens}</span>
|
||||||
<span class="text-textcolor2 mb-6 text-sm mt-2">{extokens} {language.exactTokens}</span>
|
<span class="text-textcolor2 mb-6 text-sm mt-2">{extokens} {language.exactTokens}</span>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
||||||
<!-- <span class="text-textcolor mt-4">{language.assistantPrefill}</span>
|
|
||||||
<TextInput bind:value={$DataBase.proomptSettings.assistantPrefill}/> -->
|
|
||||||
<span class="text-textcolor mt-4">{language.postEndInnerFormat}</span>
|
<span class="text-textcolor mt-4">{language.postEndInnerFormat}</span>
|
||||||
<TextInput bind:value={$DataBase.proomptSettings.postEndInnerFormat}/>
|
<TextInput bind:value={$DataBase.promptSettings.postEndInnerFormat}/>
|
||||||
|
|
||||||
<Check bind:check={$DataBase.proomptSettings.sendChatAsSystem} name={language.sendChatAsSystem} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.sendChatAsSystem} name={language.sendChatAsSystem} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.proomptSettings.sendName} name={language.sendName} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.sendName} name={language.sendName} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.proomptSettings.utilOverride} name={language.utilOverride} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.utilOverride} name={language.utilOverride} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.proomptSettings.customChainOfThought} name={language.customChainOfThought} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.customChainOfThought} name={language.customChainOfThought} className="mt-4"/>
|
||||||
{#if $DataBase.proomptSettings.customChainOfThought}
|
{#if $DataBase.promptSettings.customChainOfThought}
|
||||||
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
|
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
|
||||||
<NumberInput bind:value={$DataBase.proomptSettings.maxThoughtTagDepth}/>
|
<NumberInput bind:value={$DataBase.promptSettings.maxThoughtTagDepth}/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
126
src/lib/UI/PromptDataItem.svelte
Normal file
126
src/lib/UI/PromptDataItem.svelte
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PromptItem, PromptItemChat } from "src/ts/process/prompt";
|
||||||
|
import OptionInput from "./GUI/OptionInput.svelte";
|
||||||
|
import TextAreaInput from "./GUI/TextAreaInput.svelte";
|
||||||
|
import SelectInput from "./GUI/SelectInput.svelte";
|
||||||
|
import { language } from "src/lang";
|
||||||
|
import NumberInput from "./GUI/NumberInput.svelte";
|
||||||
|
import CheckInput from "./GUI/CheckInput.svelte";
|
||||||
|
import { ArrowDown, ArrowUp, XIcon } from "lucide-svelte";
|
||||||
|
import TextInput from "./GUI/TextInput.svelte";
|
||||||
|
import { DataBase } from "src/ts/storage/database";
|
||||||
|
export let promptItem:PromptItem
|
||||||
|
export let onRemove:() => void = () => {}
|
||||||
|
export let moveUp:() => void = () => {}
|
||||||
|
export let moveDown:() => void = () => {}
|
||||||
|
|
||||||
|
const chatPromptChange = () => {
|
||||||
|
const currentprompt = promptItem as PromptItemChat
|
||||||
|
if(currentprompt.rangeStart === -2){
|
||||||
|
currentprompt.rangeStart = 0
|
||||||
|
currentprompt.rangeEnd = 'end'
|
||||||
|
}else{
|
||||||
|
currentprompt.rangeStart = -2
|
||||||
|
currentprompt.rangeEnd = 'end'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-col first:mt-0 mt-2 border border-selected p-4 rounded-md bg-darkbg">
|
||||||
|
<span class="mb-2">
|
||||||
|
<button class="float-right" on:click={onRemove}><XIcon /></button>
|
||||||
|
<button class="float-right" on:click={moveDown}><ArrowDown /></button>
|
||||||
|
<button class="float-right" on:click={moveUp}><ArrowUp /></button>
|
||||||
|
</span>
|
||||||
|
<span>{language.type}
|
||||||
|
</span>
|
||||||
|
<SelectInput bind:value={promptItem.type} on:change={() => {
|
||||||
|
if(promptItem.type === 'plain' || promptItem.type === 'jailbreak' || promptItem.type === 'cot'){
|
||||||
|
promptItem.text = ""
|
||||||
|
promptItem.role = "system"
|
||||||
|
}
|
||||||
|
if(promptItem.type === 'chat'){
|
||||||
|
promptItem.rangeStart = -2
|
||||||
|
promptItem.rangeEnd = 'end'
|
||||||
|
}
|
||||||
|
}} >
|
||||||
|
<OptionInput value="plain">{language.formating.plain}</OptionInput>
|
||||||
|
<OptionInput value="jailbreak">{language.formating.jailbreak}</OptionInput>
|
||||||
|
<OptionInput value="chat">{language.Chat}</OptionInput>
|
||||||
|
<OptionInput value="persona">{language.formating.personaPrompt}</OptionInput>
|
||||||
|
<OptionInput value="description">{language.formating.description}</OptionInput>
|
||||||
|
<OptionInput value="authornote">{language.formating.authorNote}</OptionInput>
|
||||||
|
<OptionInput value="lorebook">{language.formating.lorebook}</OptionInput>
|
||||||
|
<OptionInput value="memory">{language.formating.memory}</OptionInput>
|
||||||
|
<OptionInput value="postEverything">{language.formating.postEverything}</OptionInput>
|
||||||
|
{#if $DataBase.promptSettings.customChainOfThought}
|
||||||
|
<OptionInput value="cot">{language.cot}</OptionInput>
|
||||||
|
{/if}
|
||||||
|
</SelectInput>
|
||||||
|
|
||||||
|
{#if promptItem.type === 'plain' || promptItem.type === 'jailbreak' || promptItem.type === 'cot'}
|
||||||
|
<span>{language.specialType}</span>
|
||||||
|
<SelectInput bind:value={promptItem.type2}>
|
||||||
|
<OptionInput value="normal">{language.noSpecialType}</OptionInput>
|
||||||
|
<OptionInput value="main">{language.mainPrompt}</OptionInput>
|
||||||
|
<OptionInput value="globalNote">{language.globalNote}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<span>{language.prompt}</span>
|
||||||
|
<TextAreaInput bind:value={promptItem.text} />
|
||||||
|
<span>{language.role}</span>
|
||||||
|
<SelectInput bind:value={promptItem.role}>
|
||||||
|
<OptionInput value="user">{language.user}</OptionInput>
|
||||||
|
<OptionInput value="bot">{language.character}</OptionInput>
|
||||||
|
<OptionInput value="system">{language.systemPrompt}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
{/if}
|
||||||
|
{#if promptItem.type === 'chat'}
|
||||||
|
<CheckInput name={language.advanced} check={promptItem.rangeStart !== -2} onChange={chatPromptChange}/>
|
||||||
|
|
||||||
|
|
||||||
|
{#if promptItem.rangeStart !== -2}
|
||||||
|
<span>{language.rangeStart}</span>
|
||||||
|
<NumberInput bind:value={promptItem.rangeStart} />
|
||||||
|
<span>{language.rangeEnd}</span>
|
||||||
|
{#if promptItem.rangeEnd === 'end'}
|
||||||
|
<CheckInput name={language.untilChatEnd} check={true} onChange={() => {
|
||||||
|
if(promptItem.type === 'chat'){
|
||||||
|
promptItem.rangeEnd = 0
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
{:else}
|
||||||
|
<NumberInput bind:value={promptItem.rangeEnd} marginBottom />
|
||||||
|
<CheckInput name={language.untilChatEnd} check={false} onChange={() => {
|
||||||
|
if(promptItem.type === 'chat'){
|
||||||
|
promptItem.rangeEnd = 'end'
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
{/if}
|
||||||
|
{#if $DataBase.promptSettings.sendChatAsSystem}
|
||||||
|
<CheckInput name={language.chatAsOriginalOnSystem} bind:check={promptItem.chatAsOriginalOnSystem}/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
{#if promptItem.type === 'authornote'}
|
||||||
|
<span>{language.defaultPrompt}</span>
|
||||||
|
<TextInput bind:value={promptItem.defaultText} />
|
||||||
|
{/if}
|
||||||
|
{#if promptItem.type === 'persona' || promptItem.type === 'description' || promptItem.type === 'authornote' || promptItem.type === 'memory'}
|
||||||
|
{#if !promptItem.innerFormat}
|
||||||
|
<CheckInput name={language.customInnerFormat} check={false} className="mt-2" onChange={() => {
|
||||||
|
if(promptItem.type === 'persona' || promptItem.type === 'description' || promptItem.type === 'authornote' || promptItem.type === 'memory'){
|
||||||
|
promptItem.innerFormat = "{{slot}}"
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
{:else}
|
||||||
|
<span>{language.innerFormat}</span>
|
||||||
|
<TextAreaInput bind:value={promptItem.innerFormat}/>
|
||||||
|
<CheckInput name={language.customInnerFormat} check={true} className="mt-2" onChange={() => {
|
||||||
|
if(promptItem.type === 'persona' || promptItem.type === 'description' || promptItem.type === 'authornote' || promptItem.type === 'memory'){
|
||||||
|
promptItem.innerFormat = null
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import type { Proompt } from "src/ts/process/proompt";
|
|
||||||
import OptionInput from "./GUI/OptionInput.svelte";
|
|
||||||
import TextAreaInput from "./GUI/TextAreaInput.svelte";
|
|
||||||
import SelectInput from "./GUI/SelectInput.svelte";
|
|
||||||
import { language } from "src/lang";
|
|
||||||
import NumberInput from "./GUI/NumberInput.svelte";
|
|
||||||
import CheckInput from "./GUI/CheckInput.svelte";
|
|
||||||
import { ArrowDown, ArrowUp, XIcon } from "lucide-svelte";
|
|
||||||
import TextInput from "./GUI/TextInput.svelte";
|
|
||||||
import { DataBase } from "src/ts/storage/database";
|
|
||||||
export let proompt:Proompt
|
|
||||||
export let onRemove:() => void = () => {}
|
|
||||||
export let moveUp:() => void = () => {}
|
|
||||||
export let moveDown:() => void = () => {}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex flex-col first:mt-0 mt-2 border border-selected p-4 rounded-md bg-darkbg">
|
|
||||||
<span class="mb-2">
|
|
||||||
<button class="float-right" on:click={onRemove}><XIcon /></button>
|
|
||||||
<button class="float-right" on:click={moveDown}><ArrowDown /></button>
|
|
||||||
<button class="float-right" on:click={moveUp}><ArrowUp /></button>
|
|
||||||
</span>
|
|
||||||
<span>{language.type}
|
|
||||||
</span>
|
|
||||||
<SelectInput bind:value={proompt.type} on:change={() => {
|
|
||||||
if(proompt.type === 'plain' || proompt.type === 'jailbreak' || proompt.type === 'cot'){
|
|
||||||
proompt.text = ""
|
|
||||||
proompt.role = "system"
|
|
||||||
}
|
|
||||||
if(proompt.type === 'chat'){
|
|
||||||
proompt.rangeStart = 0
|
|
||||||
proompt.rangeEnd = 'end'
|
|
||||||
}
|
|
||||||
}} >
|
|
||||||
<OptionInput value="plain">{language.formating.plain}</OptionInput>
|
|
||||||
<OptionInput value="jailbreak">{language.formating.jailbreak}</OptionInput>
|
|
||||||
<OptionInput value="chat">{language.Chat}</OptionInput>
|
|
||||||
<OptionInput value="persona">{language.formating.personaPrompt}</OptionInput>
|
|
||||||
<OptionInput value="description">{language.formating.description}</OptionInput>
|
|
||||||
<OptionInput value="authornote">{language.formating.authorNote}</OptionInput>
|
|
||||||
<OptionInput value="lorebook">{language.formating.lorebook}</OptionInput>
|
|
||||||
<OptionInput value="memory">{language.formating.memory}</OptionInput>
|
|
||||||
<OptionInput value="postEverything">{language.formating.postEverything}</OptionInput>
|
|
||||||
{#if $DataBase.proomptSettings.customChainOfThought}
|
|
||||||
<OptionInput value="cot">{language.cot}</OptionInput>
|
|
||||||
{/if}
|
|
||||||
</SelectInput>
|
|
||||||
|
|
||||||
{#if proompt.type === 'plain' || proompt.type === 'jailbreak' || proompt.type === 'cot'}
|
|
||||||
<span>{language.specialType}</span>
|
|
||||||
<SelectInput bind:value={proompt.type2}>
|
|
||||||
<OptionInput value="normal">{language.noSpecialType}</OptionInput>
|
|
||||||
<OptionInput value="main">{language.mainPrompt}</OptionInput>
|
|
||||||
<OptionInput value="globalNote">{language.globalNote}</OptionInput>
|
|
||||||
</SelectInput>
|
|
||||||
<span>{language.prompt}</span>
|
|
||||||
<TextAreaInput bind:value={proompt.text} />
|
|
||||||
<span>{language.role}</span>
|
|
||||||
<SelectInput bind:value={proompt.role}>
|
|
||||||
<OptionInput value="user">{language.user}</OptionInput>
|
|
||||||
<OptionInput value="bot">{language.character}</OptionInput>
|
|
||||||
<OptionInput value="system">{language.systemPrompt}</OptionInput>
|
|
||||||
</SelectInput>
|
|
||||||
{/if}
|
|
||||||
{#if proompt.type === 'chat'}
|
|
||||||
<span>{language.rangeStart}</span>
|
|
||||||
<NumberInput bind:value={proompt.rangeStart} />
|
|
||||||
<span>{language.rangeEnd}</span>
|
|
||||||
{#if proompt.rangeEnd === 'end'}
|
|
||||||
<CheckInput name={language.untilChatEnd} check={true} onChange={() => {
|
|
||||||
if(proompt.type === 'chat'){
|
|
||||||
proompt.rangeEnd = 0
|
|
||||||
}
|
|
||||||
}} />
|
|
||||||
{:else}
|
|
||||||
<NumberInput bind:value={proompt.rangeEnd} marginBottom />
|
|
||||||
<CheckInput name={language.untilChatEnd} check={false} onChange={() => {
|
|
||||||
if(proompt.type === 'chat'){
|
|
||||||
proompt.rangeEnd = 'end'
|
|
||||||
}
|
|
||||||
}} />
|
|
||||||
{/if}
|
|
||||||
{#if $DataBase.proomptSettings.sendChatAsSystem}
|
|
||||||
<CheckInput name={language.chatAsOriginalOnSystem} bind:check={proompt.chatAsOriginalOnSystem}/>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
{#if proompt.type === 'authornote'}
|
|
||||||
<span>{language.defaultPrompt}</span>
|
|
||||||
<TextInput bind:value={proompt.defaultText} />
|
|
||||||
{/if}
|
|
||||||
{#if proompt.type === 'persona' || proompt.type === 'description' || proompt.type === 'authornote' || proompt.type === 'memory'}
|
|
||||||
{#if !proompt.innerFormat}
|
|
||||||
<CheckInput name={language.customInnerFormat} check={false} className="mt-2" onChange={() => {
|
|
||||||
if(proompt.type === 'persona' || proompt.type === 'description' || proompt.type === 'authornote' || proompt.type === 'memory'){
|
|
||||||
proompt.innerFormat = "{{slot}}"
|
|
||||||
}
|
|
||||||
}} />
|
|
||||||
{:else}
|
|
||||||
<span>{language.innerFormat}</span>
|
|
||||||
<TextAreaInput bind:value={proompt.innerFormat}/>
|
|
||||||
<CheckInput name={language.customInnerFormat} check={true} className="mt-2" onChange={() => {
|
|
||||||
if(proompt.type === 'persona' || proompt.type === 'description' || proompt.type === 'authornote' || proompt.type === 'memory'){
|
|
||||||
proompt.innerFormat = null
|
|
||||||
}
|
|
||||||
}} />
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -224,7 +224,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(currentChar.utilityBot && (!(usingPromptTemplate && db.proomptSettings.utilOverride))){
|
if(currentChar.utilityBot && (!(usingPromptTemplate && db.promptSettings.utilOverride))){
|
||||||
promptTemplate = [
|
promptTemplate = [
|
||||||
{
|
{
|
||||||
"type": "plain",
|
"type": "plain",
|
||||||
@@ -300,7 +300,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if(db.chainOfThought && (!(usingPromptTemplate && db.proomptSettings.customChainOfThought))){
|
if(db.chainOfThought && (!(usingPromptTemplate && db.promptSettings.customChainOfThought))){
|
||||||
unformated.postEverything.push({
|
unformated.postEverything.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: `<instruction> - before respond everything, Think step by step as a ai assistant how would you respond inside <Thoughts> xml tag. this must be less than 5 paragraphs.</instruction>`
|
content: `<instruction> - before respond everything, Think step by step as a ai assistant how would you respond inside <Thoughts> xml tag. this must be less than 5 paragraphs.</instruction>`
|
||||||
@@ -432,10 +432,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
case 'postEverything':{
|
case 'postEverything':{
|
||||||
await tokenizeChatArray(unformated.postEverything)
|
await tokenizeChatArray(unformated.postEverything)
|
||||||
if(usingPromptTemplate && db.proomptSettings.postEndInnerFormat){
|
if(usingPromptTemplate && db.promptSettings.postEndInnerFormat){
|
||||||
await tokenizeChatArray([{
|
await tokenizeChatArray([{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: db.proomptSettings.postEndInnerFormat
|
content: db.promptSettings.postEndInnerFormat
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -497,7 +497,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
let chats = unformated.chats.slice(start, end)
|
let chats = unformated.chats.slice(start, end)
|
||||||
|
|
||||||
if(usingPromptTemplate && db.proomptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
if(usingPromptTemplate && db.promptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||||
chats = systemizeChat(chats)
|
chats = systemizeChat(chats)
|
||||||
}
|
}
|
||||||
await tokenizeChatArray(chats)
|
await tokenizeChatArray(chats)
|
||||||
@@ -545,7 +545,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
'editprocess'))
|
'editprocess'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usingPromptTemplate && db.proomptSettings.sendName){
|
if(usingPromptTemplate && db.promptSettings.sendName){
|
||||||
chat.content = `${currentChar.name}: ${chat.content}`
|
chat.content = `${currentChar.name}: ${chat.content}`
|
||||||
chat.attr = ['nameAdded']
|
chat.attr = ['nameAdded']
|
||||||
}
|
}
|
||||||
@@ -622,13 +622,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
|
|
||||||
let attr:string[] = []
|
let attr:string[] = []
|
||||||
|
|
||||||
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.proomptSettings.sendName)){
|
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.promptSettings.sendName)){
|
||||||
formatedChat = name + ': ' + formatedChat
|
formatedChat = name + ': ' + formatedChat
|
||||||
attr.push('nameAdded')
|
attr.push('nameAdded')
|
||||||
}
|
}
|
||||||
if(usingPromptTemplate && db.proomptSettings.customChainOfThought && db.proomptSettings.maxThoughtTagDepth !== -1){
|
if(usingPromptTemplate && db.promptSettings.customChainOfThought && db.promptSettings.maxThoughtTagDepth !== -1){
|
||||||
const depth = ms.length - index
|
const depth = ms.length - index
|
||||||
if(depth >= db.proomptSettings.maxThoughtTagDepth){
|
if(depth >= db.promptSettings.maxThoughtTagDepth){
|
||||||
formatedChat = formatedChat.replace(/<Thoughts>(.+?)<\/Thoughts>/gm, '')
|
formatedChat = formatedChat.replace(/<Thoughts>(.+?)<\/Thoughts>/gm, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -837,10 +837,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
case 'postEverything':{
|
case 'postEverything':{
|
||||||
pushPrompts(unformated.postEverything)
|
pushPrompts(unformated.postEverything)
|
||||||
if(usingPromptTemplate && db.proomptSettings.postEndInnerFormat){
|
if(usingPromptTemplate && db.promptSettings.postEndInnerFormat){
|
||||||
pushPrompts([{
|
pushPrompts([{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: db.proomptSettings.postEndInnerFormat
|
content: db.promptSettings.postEndInnerFormat
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -902,7 +902,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
}
|
}
|
||||||
|
|
||||||
let chats = unformated.chats.slice(start, end)
|
let chats = unformated.chats.slice(start, end)
|
||||||
if(usingPromptTemplate && db.proomptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
if(usingPromptTemplate && db.promptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||||
chats = systemizeChat(chats)
|
chats = systemizeChat(chats)
|
||||||
}
|
}
|
||||||
pushPrompts(chats)
|
pushPrompts(chats)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { tokenizeAccurate } from "../tokenizer";
|
import { tokenizeAccurate } from "../tokenizer";
|
||||||
|
|
||||||
export type Proompt = ProomptPlain|ProomptTyped|ProomptChat|ProomptAuthorNote;
|
export type PromptItem = PromptItemPlain|PromptItemTyped|PromptItemChat|PromptItemAuthorNote;
|
||||||
export type ProomptType = Proompt['type'];
|
export type PromptType = PromptItem['type'];
|
||||||
export type ProomptSettings = {
|
export type PromptSettings = {
|
||||||
assistantPrefill: string
|
assistantPrefill: string
|
||||||
postEndInnerFormat: string
|
postEndInnerFormat: string
|
||||||
sendChatAsSystem: boolean
|
sendChatAsSystem: boolean
|
||||||
@@ -12,39 +12,39 @@ export type ProomptSettings = {
|
|||||||
maxThoughtTagDepth?: number
|
maxThoughtTagDepth?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProomptPlain {
|
export interface PromptItemPlain {
|
||||||
type: 'plain'|'jailbreak'|'cot';
|
type: 'plain'|'jailbreak'|'cot';
|
||||||
type2: 'normal'|'globalNote'|'main'
|
type2: 'normal'|'globalNote'|'main'
|
||||||
text: string;
|
text: string;
|
||||||
role: 'user'|'bot'|'system';
|
role: 'user'|'bot'|'system';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProomptTyped {
|
export interface PromptItemTyped {
|
||||||
type: 'persona'|'description'|'lorebook'|'postEverything'|'memory'
|
type: 'persona'|'description'|'lorebook'|'postEverything'|'memory'
|
||||||
innerFormat?: string
|
innerFormat?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProomptAuthorNote {
|
export interface PromptItemAuthorNote {
|
||||||
type : 'authornote'
|
type : 'authornote'
|
||||||
innerFormat?: string
|
innerFormat?: string
|
||||||
defaultText?: string
|
defaultText?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface ProomptChat {
|
export interface PromptItemChat {
|
||||||
type: 'chat';
|
type: 'chat';
|
||||||
rangeStart: number;
|
rangeStart: number;
|
||||||
rangeEnd: number|'end';
|
rangeEnd: number|'end';
|
||||||
chatAsOriginalOnSystem?: boolean;
|
chatAsOriginalOnSystem?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function tokenizePreset(proompts:Proompt[], consti:boolean = false){
|
export async function tokenizePreset(prompts:PromptItem[], consti:boolean = false){
|
||||||
let total = 0
|
let total = 0
|
||||||
for(const proompt of proompts){
|
for(const prompt of prompts){
|
||||||
switch(proompt.type){
|
switch(prompt.type){
|
||||||
case 'plain':
|
case 'plain':
|
||||||
case 'jailbreak':{
|
case 'jailbreak':{
|
||||||
total += await tokenizeAccurate(proompt.text, consti)
|
total += await tokenizeAccurate(prompt.text, consti)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'persona':
|
case 'persona':
|
||||||
@@ -53,8 +53,8 @@ export async function tokenizePreset(proompts:Proompt[], consti:boolean = false)
|
|||||||
case 'postEverything':
|
case 'postEverything':
|
||||||
case 'authornote':
|
case 'authornote':
|
||||||
case 'memory':{
|
case 'memory':{
|
||||||
if(proompt.innerFormat){
|
if(prompt.innerFormat){
|
||||||
total += await tokenizeAccurate(proompt.innerFormat, consti)
|
total += await tokenizeAccurate(prompt.innerFormat, consti)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -742,7 +742,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
case 'novelai':
|
case 'novelai':
|
||||||
case 'novelai_kayra':{
|
case 'novelai_kayra':{
|
||||||
console.log(arg.continue)
|
console.log(arg.continue)
|
||||||
const proompt = stringlizeNAIChat(formated, currentChar?.name ?? '', arg.continue)
|
const prompt = stringlizeNAIChat(formated, currentChar?.name ?? '', arg.continue)
|
||||||
let logit_bias_exp:{
|
let logit_bias_exp:{
|
||||||
sequence: number[], bias: number, ensure_sequence_finish: false, generate_once: true
|
sequence: number[], bias: number, ensure_sequence_finish: false, generate_once: true
|
||||||
}[] = []
|
}[] = []
|
||||||
@@ -805,7 +805,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
|
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
"input": proompt,
|
"input": prompt,
|
||||||
"model": aiModel === 'novelai_kayra' ? 'kayra-v1' : 'clio-v1',
|
"model": aiModel === 'novelai_kayra' ? 'kayra-v1' : 'clio-v1',
|
||||||
"parameters":payload
|
"parameters":payload
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
let blockingUrl = db.textgenWebUIBlockingURL.replace(/\/api.*/, "/api/v1/generate")
|
let blockingUrl = db.textgenWebUIBlockingURL.replace(/\/api.*/, "/api/v1/generate")
|
||||||
let bodyTemplate:any
|
let bodyTemplate:any
|
||||||
const suggesting = model === "submodel"
|
const suggesting = model === "submodel"
|
||||||
const proompt = applyChatTemplate(formated)
|
const prompt = applyChatTemplate(formated)
|
||||||
let stopStrings = getStopStrings(suggesting)
|
let stopStrings = getStopStrings(suggesting)
|
||||||
if(db.localStopStrings){
|
if(db.localStopStrings){
|
||||||
stopStrings = db.localStopStrings.map((v) => {
|
stopStrings = db.localStopStrings.map((v) => {
|
||||||
@@ -915,7 +915,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
'seed': -1,
|
'seed': -1,
|
||||||
add_bos_token: db.ooba.add_bos_token,
|
add_bos_token: db.ooba.add_bos_token,
|
||||||
topP: db.top_p,
|
topP: db.top_p,
|
||||||
prompt: proompt
|
prompt: prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
const headers = (aiModel === 'textgen_webui') ? {} : {
|
const headers = (aiModel === 'textgen_webui') ? {} : {
|
||||||
@@ -1006,7 +1006,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
|
|
||||||
case 'ooba': {
|
case 'ooba': {
|
||||||
const suggesting = model === "submodel"
|
const suggesting = model === "submodel"
|
||||||
const proompt = applyChatTemplate(formated)
|
const prompt = applyChatTemplate(formated)
|
||||||
let stopStrings = getStopStrings(suggesting)
|
let stopStrings = getStopStrings(suggesting)
|
||||||
if(db.localStopStrings){
|
if(db.localStopStrings){
|
||||||
stopStrings = db.localStopStrings.map((v) => {
|
stopStrings = db.localStopStrings.map((v) => {
|
||||||
@@ -1014,7 +1014,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
let bodyTemplate:Record<string, any> = {
|
let bodyTemplate:Record<string, any> = {
|
||||||
'prompt': proompt,
|
'prompt': prompt,
|
||||||
presence_penalty: arg.PresensePenalty || (db.PresensePenalty / 100),
|
presence_penalty: arg.PresensePenalty || (db.PresensePenalty / 100),
|
||||||
frequency_penalty: arg.frequencyPenalty || (db.frequencyPenalty / 100),
|
frequency_penalty: arg.frequencyPenalty || (db.frequencyPenalty / 100),
|
||||||
logit_bias: {},
|
logit_bias: {},
|
||||||
@@ -1355,7 +1355,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
|
|
||||||
}
|
}
|
||||||
case "kobold":{
|
case "kobold":{
|
||||||
const proompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
const prompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||||
const url = new URL(db.koboldURL)
|
const url = new URL(db.koboldURL)
|
||||||
if(url.pathname.length < 3){
|
if(url.pathname.length < 3){
|
||||||
url.pathname = 'api/v1/generate'
|
url.pathname = 'api/v1/generate'
|
||||||
@@ -1364,7 +1364,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
const da = await globalFetch(url.toString(), {
|
const da = await globalFetch(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: {
|
body: {
|
||||||
"prompt": proompt,
|
"prompt": prompt,
|
||||||
"temperature": (db.temperature / 100),
|
"temperature": (db.temperature / 100),
|
||||||
"top_p": 0.9
|
"top_p": 0.9
|
||||||
},
|
},
|
||||||
@@ -2199,12 +2199,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(aiModel.startsWith("horde:::")){
|
if(aiModel.startsWith("horde:::")){
|
||||||
const proompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
const prompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||||
|
|
||||||
const realModel = aiModel.split(":::")[1]
|
const realModel = aiModel.split(":::")[1]
|
||||||
|
|
||||||
const argument = {
|
const argument = {
|
||||||
"prompt": proompt,
|
"prompt": prompt,
|
||||||
"params": {
|
"params": {
|
||||||
"n": 1,
|
"n": 1,
|
||||||
"max_context_length": db.maxContext + 100,
|
"max_context_length": db.maxContext + 100,
|
||||||
@@ -2292,8 +2292,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
if(aiModel.startsWith('hf:::')){
|
if(aiModel.startsWith('hf:::')){
|
||||||
const realModel = aiModel.split(":::")[1]
|
const realModel = aiModel.split(":::")[1]
|
||||||
const suggesting = model === "submodel"
|
const suggesting = model === "submodel"
|
||||||
const proompt = applyChatTemplate(formated)
|
const prompt = applyChatTemplate(formated)
|
||||||
const v = await runTransformers(proompt, realModel, {
|
const v = await runTransformers(prompt, realModel, {
|
||||||
temperature: temperature,
|
temperature: temperature,
|
||||||
max_new_tokens: maxTokens,
|
max_new_tokens: maxTokens,
|
||||||
top_k: db.ooba.top_k,
|
top_k: db.ooba.top_k,
|
||||||
@@ -2309,12 +2309,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
if(aiModel.startsWith('local_')){
|
if(aiModel.startsWith('local_')){
|
||||||
console.log('running local model')
|
console.log('running local model')
|
||||||
const suggesting = model === "submodel"
|
const suggesting = model === "submodel"
|
||||||
const proompt = applyChatTemplate(formated)
|
const prompt = applyChatTemplate(formated)
|
||||||
const stopStrings = getStopStrings(suggesting)
|
const stopStrings = getStopStrings(suggesting)
|
||||||
console.log(stopStrings)
|
console.log(stopStrings)
|
||||||
const modelPath = aiModel.replace('local_', '')
|
const modelPath = aiModel.replace('local_', '')
|
||||||
const res = await runGGUFModel({
|
const res = await runGGUFModel({
|
||||||
prompt: proompt,
|
prompt: prompt,
|
||||||
modelPath: modelPath,
|
modelPath: modelPath,
|
||||||
temperature: temperature,
|
temperature: temperature,
|
||||||
top_p: db.top_p,
|
top_p: db.top_p,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const proompt = `Chat:\n${prompt}`
|
const promptItem = `Chat:\n${prompt}`
|
||||||
|
|
||||||
const promptbody:OpenAIChat[] = [
|
const promptbody:OpenAIChat[] = [
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ export async function stableDiff(currentChar:character,prompt:string){
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: proompt
|
content: promptItem
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
|||||||
"mode": "instruct"
|
"mode": "instruct"
|
||||||
},
|
},
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"proomptSettings": {
|
"promptSettings": {
|
||||||
"assistantPrefill": "",
|
"assistantPrefill": "",
|
||||||
"postEndInnerFormat": "",
|
"postEndInnerFormat": "",
|
||||||
"sendChatAsSystem": false,
|
"sendChatAsSystem": false,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { alertNormal, alertSelect } from '../alert';
|
|||||||
import type { NAISettings } from '../process/models/nai';
|
import type { NAISettings } from '../process/models/nai';
|
||||||
import { prebuiltNAIpresets, prebuiltPresets } from '../process/templates/templates';
|
import { prebuiltNAIpresets, prebuiltPresets } from '../process/templates/templates';
|
||||||
import { defaultColorScheme, type ColorScheme } from '../gui/colorscheme';
|
import { defaultColorScheme, type ColorScheme } from '../gui/colorscheme';
|
||||||
import type { Proompt, ProomptSettings } from '../process/proompt';
|
import type { PromptItem, PromptSettings } from '../process/prompt';
|
||||||
import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
import type { OobaChatCompletionRequestParams } from '../model/ooba';
|
||||||
|
|
||||||
export const DataBase = writable({} as any as Database)
|
export const DataBase = writable({} as any as Database)
|
||||||
@@ -361,7 +361,7 @@ export function setDatabase(data:Database){
|
|||||||
data.google.accessToken ??= ''
|
data.google.accessToken ??= ''
|
||||||
data.google.projectId ??= ''
|
data.google.projectId ??= ''
|
||||||
data.genTime ??= 1
|
data.genTime ??= 1
|
||||||
data.proomptSettings ??= {
|
data.promptSettings ??= {
|
||||||
assistantPrefill: '',
|
assistantPrefill: '',
|
||||||
postEndInnerFormat: '',
|
postEndInnerFormat: '',
|
||||||
sendChatAsSystem: false,
|
sendChatAsSystem: false,
|
||||||
@@ -372,7 +372,7 @@ export function setDatabase(data:Database){
|
|||||||
}
|
}
|
||||||
data.keiServerURL ??= ''
|
data.keiServerURL ??= ''
|
||||||
data.top_k ??= 0
|
data.top_k ??= 0
|
||||||
data.proomptSettings.maxThoughtTagDepth ??= -1
|
data.promptSettings.maxThoughtTagDepth ??= -1
|
||||||
data.openrouterFallback ??= true
|
data.openrouterFallback ??= true
|
||||||
data.openrouterMiddleOut ??= false
|
data.openrouterMiddleOut ??= false
|
||||||
data.removePunctuationHypa ??= true
|
data.removePunctuationHypa ??= true
|
||||||
@@ -568,7 +568,7 @@ export interface Database{
|
|||||||
hideRealm:boolean
|
hideRealm:boolean
|
||||||
colorScheme:ColorScheme
|
colorScheme:ColorScheme
|
||||||
colorSchemeName:string
|
colorSchemeName:string
|
||||||
promptTemplate?:Proompt[]
|
promptTemplate?:PromptItem[]
|
||||||
forceProxyAsOpenAI?:boolean
|
forceProxyAsOpenAI?:boolean
|
||||||
hypaModel:'ada'|'MiniLM'
|
hypaModel:'ada'|'MiniLM'
|
||||||
saveTime?:number
|
saveTime?:number
|
||||||
@@ -609,7 +609,7 @@ export interface Database{
|
|||||||
mistralKey?:string
|
mistralKey?:string
|
||||||
chainOfThought?:boolean
|
chainOfThought?:boolean
|
||||||
genTime:number
|
genTime:number
|
||||||
proomptSettings: ProomptSettings
|
promptSettings: PromptSettings
|
||||||
keiServerURL:string
|
keiServerURL:string
|
||||||
statistics: {
|
statistics: {
|
||||||
newYear2024?: {
|
newYear2024?: {
|
||||||
@@ -840,14 +840,14 @@ export interface botPreset{
|
|||||||
autoSuggestPrompt?: string
|
autoSuggestPrompt?: string
|
||||||
autoSuggestPrefix?: string
|
autoSuggestPrefix?: string
|
||||||
autoSuggestClean?: boolean
|
autoSuggestClean?: boolean
|
||||||
promptTemplate?:Proompt[]
|
promptTemplate?:PromptItem[]
|
||||||
NAIadventure?: boolean
|
NAIadventure?: boolean
|
||||||
NAIappendName?: boolean
|
NAIappendName?: boolean
|
||||||
localStopStrings?: string[]
|
localStopStrings?: string[]
|
||||||
customProxyRequestModel?: string
|
customProxyRequestModel?: string
|
||||||
reverseProxyOobaArgs?: OobaChatCompletionRequestParams
|
reverseProxyOobaArgs?: OobaChatCompletionRequestParams
|
||||||
top_p?: number
|
top_p?: number
|
||||||
proomptSettings?: ProomptSettings
|
promptSettings?: PromptSettings
|
||||||
repetition_penalty?:number
|
repetition_penalty?:number
|
||||||
min_p?:number
|
min_p?:number
|
||||||
top_a?:number
|
top_a?:number
|
||||||
@@ -1113,7 +1113,7 @@ export function saveCurrentPreset(){
|
|||||||
customProxyRequestModel: db.customProxyRequestModel,
|
customProxyRequestModel: db.customProxyRequestModel,
|
||||||
reverseProxyOobaArgs: cloneDeep(db.reverseProxyOobaArgs) ?? null,
|
reverseProxyOobaArgs: cloneDeep(db.reverseProxyOobaArgs) ?? null,
|
||||||
top_p: db.top_p ?? 1,
|
top_p: db.top_p ?? 1,
|
||||||
proomptSettings: cloneDeep(db.proomptSettings) ?? null,
|
promptSettings: cloneDeep(db.promptSettings) ?? null,
|
||||||
repetition_penalty: db.repetition_penalty,
|
repetition_penalty: db.repetition_penalty,
|
||||||
min_p: db.min_p,
|
min_p: db.min_p,
|
||||||
top_a: db.top_a,
|
top_a: db.top_a,
|
||||||
@@ -1188,7 +1188,8 @@ export function setPreset(db:Database, newPres: botPreset){
|
|||||||
mode: 'instruct'
|
mode: 'instruct'
|
||||||
}
|
}
|
||||||
db.top_p = newPres.top_p ?? 1
|
db.top_p = newPres.top_p ?? 1
|
||||||
db.proomptSettings = cloneDeep(newPres.proomptSettings) ?? {
|
//@ts-ignore //for legacy mistpings
|
||||||
|
db.promptSettings = cloneDeep(newPres.promptSettings) ?? cloneDeep(newPres.proomptSettings) ?? {
|
||||||
assistantPrefill: '',
|
assistantPrefill: '',
|
||||||
postEndInnerFormat: '',
|
postEndInnerFormat: '',
|
||||||
sendChatAsSystem: false,
|
sendChatAsSystem: false,
|
||||||
|
|||||||
@@ -960,6 +960,8 @@ async function checkNewFormat() {
|
|||||||
if(db.mainPrompt === oldJailbreak){
|
if(db.mainPrompt === oldJailbreak){
|
||||||
db.mainPrompt = defaultJailbreak
|
db.mainPrompt = defaultJailbreak
|
||||||
}
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
if(db.proomptSettings){ db.promptSettings = db.proomptSettingsdelete; delete db.proomptSettings }
|
||||||
|
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
checkCharOrder()
|
checkCharOrder()
|
||||||
|
|||||||
Reference in New Issue
Block a user