Fix typo
This commit is contained in:
@@ -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 = [
|
||||
{
|
||||
"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({
|
||||
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>`
|
||||
@@ -432,10 +432,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
}
|
||||
case 'postEverything':{
|
||||
await tokenizeChatArray(unformated.postEverything)
|
||||
if(usingPromptTemplate && db.proomptSettings.postEndInnerFormat){
|
||||
if(usingPromptTemplate && db.promptSettings.postEndInnerFormat){
|
||||
await tokenizeChatArray([{
|
||||
role: 'system',
|
||||
content: db.proomptSettings.postEndInnerFormat
|
||||
content: db.promptSettings.postEndInnerFormat
|
||||
}])
|
||||
}
|
||||
break
|
||||
@@ -497,7 +497,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
}
|
||||
let chats = unformated.chats.slice(start, end)
|
||||
|
||||
if(usingPromptTemplate && db.proomptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||
if(usingPromptTemplate && db.promptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||
chats = systemizeChat(chats)
|
||||
}
|
||||
await tokenizeChatArray(chats)
|
||||
@@ -545,7 +545,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
'editprocess'))
|
||||
}
|
||||
|
||||
if(usingPromptTemplate && db.proomptSettings.sendName){
|
||||
if(usingPromptTemplate && db.promptSettings.sendName){
|
||||
chat.content = `${currentChar.name}: ${chat.content}`
|
||||
chat.attr = ['nameAdded']
|
||||
}
|
||||
@@ -622,13 +622,13 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
|
||||
let attr:string[] = []
|
||||
|
||||
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.proomptSettings.sendName)){
|
||||
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.promptSettings.sendName)){
|
||||
formatedChat = name + ': ' + formatedChat
|
||||
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
|
||||
if(depth >= db.proomptSettings.maxThoughtTagDepth){
|
||||
if(depth >= db.promptSettings.maxThoughtTagDepth){
|
||||
formatedChat = formatedChat.replace(/<Thoughts>(.+?)<\/Thoughts>/gm, '')
|
||||
}
|
||||
}
|
||||
@@ -837,10 +837,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
}
|
||||
case 'postEverything':{
|
||||
pushPrompts(unformated.postEverything)
|
||||
if(usingPromptTemplate && db.proomptSettings.postEndInnerFormat){
|
||||
if(usingPromptTemplate && db.promptSettings.postEndInnerFormat){
|
||||
pushPrompts([{
|
||||
role: 'system',
|
||||
content: db.proomptSettings.postEndInnerFormat
|
||||
content: db.promptSettings.postEndInnerFormat
|
||||
}])
|
||||
}
|
||||
break
|
||||
@@ -902,7 +902,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
}
|
||||
|
||||
let chats = unformated.chats.slice(start, end)
|
||||
if(usingPromptTemplate && db.proomptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||
if(usingPromptTemplate && db.promptSettings.sendChatAsSystem && (!card.chatAsOriginalOnSystem)){
|
||||
chats = systemizeChat(chats)
|
||||
}
|
||||
pushPrompts(chats)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { tokenizeAccurate } from "../tokenizer";
|
||||
|
||||
export type Proompt = ProomptPlain|ProomptTyped|ProomptChat|ProomptAuthorNote;
|
||||
export type ProomptType = Proompt['type'];
|
||||
export type ProomptSettings = {
|
||||
export type PromptItem = PromptItemPlain|PromptItemTyped|PromptItemChat|PromptItemAuthorNote;
|
||||
export type PromptType = PromptItem['type'];
|
||||
export type PromptSettings = {
|
||||
assistantPrefill: string
|
||||
postEndInnerFormat: string
|
||||
sendChatAsSystem: boolean
|
||||
@@ -12,39 +12,39 @@ export type ProomptSettings = {
|
||||
maxThoughtTagDepth?: number
|
||||
}
|
||||
|
||||
export interface ProomptPlain {
|
||||
export interface PromptItemPlain {
|
||||
type: 'plain'|'jailbreak'|'cot';
|
||||
type2: 'normal'|'globalNote'|'main'
|
||||
text: string;
|
||||
role: 'user'|'bot'|'system';
|
||||
}
|
||||
|
||||
export interface ProomptTyped {
|
||||
export interface PromptItemTyped {
|
||||
type: 'persona'|'description'|'lorebook'|'postEverything'|'memory'
|
||||
innerFormat?: string
|
||||
}
|
||||
|
||||
export interface ProomptAuthorNote {
|
||||
export interface PromptItemAuthorNote {
|
||||
type : 'authornote'
|
||||
innerFormat?: string
|
||||
defaultText?: string
|
||||
}
|
||||
|
||||
|
||||
export interface ProomptChat {
|
||||
export interface PromptItemChat {
|
||||
type: 'chat';
|
||||
rangeStart: number;
|
||||
rangeEnd: number|'end';
|
||||
chatAsOriginalOnSystem?: boolean;
|
||||
}
|
||||
|
||||
export async function tokenizePreset(proompts:Proompt[], consti:boolean = false){
|
||||
export async function tokenizePreset(prompts:PromptItem[], consti:boolean = false){
|
||||
let total = 0
|
||||
for(const proompt of proompts){
|
||||
switch(proompt.type){
|
||||
for(const prompt of prompts){
|
||||
switch(prompt.type){
|
||||
case 'plain':
|
||||
case 'jailbreak':{
|
||||
total += await tokenizeAccurate(proompt.text, consti)
|
||||
total += await tokenizeAccurate(prompt.text, consti)
|
||||
break
|
||||
}
|
||||
case 'persona':
|
||||
@@ -53,8 +53,8 @@ export async function tokenizePreset(proompts:Proompt[], consti:boolean = false)
|
||||
case 'postEverything':
|
||||
case 'authornote':
|
||||
case 'memory':{
|
||||
if(proompt.innerFormat){
|
||||
total += await tokenizeAccurate(proompt.innerFormat, consti)
|
||||
if(prompt.innerFormat){
|
||||
total += await tokenizeAccurate(prompt.innerFormat, consti)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -742,7 +742,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
case 'novelai':
|
||||
case 'novelai_kayra':{
|
||||
console.log(arg.continue)
|
||||
const proompt = stringlizeNAIChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
const prompt = stringlizeNAIChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
let logit_bias_exp:{
|
||||
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 = {
|
||||
"input": proompt,
|
||||
"input": prompt,
|
||||
"model": aiModel === 'novelai_kayra' ? 'kayra-v1' : 'clio-v1',
|
||||
"parameters":payload
|
||||
}
|
||||
@@ -887,7 +887,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
let blockingUrl = db.textgenWebUIBlockingURL.replace(/\/api.*/, "/api/v1/generate")
|
||||
let bodyTemplate:any
|
||||
const suggesting = model === "submodel"
|
||||
const proompt = applyChatTemplate(formated)
|
||||
const prompt = applyChatTemplate(formated)
|
||||
let stopStrings = getStopStrings(suggesting)
|
||||
if(db.localStopStrings){
|
||||
stopStrings = db.localStopStrings.map((v) => {
|
||||
@@ -915,7 +915,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
'seed': -1,
|
||||
add_bos_token: db.ooba.add_bos_token,
|
||||
topP: db.top_p,
|
||||
prompt: proompt
|
||||
prompt: prompt
|
||||
}
|
||||
|
||||
const headers = (aiModel === 'textgen_webui') ? {} : {
|
||||
@@ -1006,7 +1006,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
|
||||
case 'ooba': {
|
||||
const suggesting = model === "submodel"
|
||||
const proompt = applyChatTemplate(formated)
|
||||
const prompt = applyChatTemplate(formated)
|
||||
let stopStrings = getStopStrings(suggesting)
|
||||
if(db.localStopStrings){
|
||||
stopStrings = db.localStopStrings.map((v) => {
|
||||
@@ -1014,7 +1014,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
})
|
||||
}
|
||||
let bodyTemplate:Record<string, any> = {
|
||||
'prompt': proompt,
|
||||
'prompt': prompt,
|
||||
presence_penalty: arg.PresensePenalty || (db.PresensePenalty / 100),
|
||||
frequency_penalty: arg.frequencyPenalty || (db.frequencyPenalty / 100),
|
||||
logit_bias: {},
|
||||
@@ -1355,7 +1355,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
|
||||
}
|
||||
case "kobold":{
|
||||
const proompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
const prompt = stringlizeChat(formated, currentChar?.name ?? '', arg.continue)
|
||||
const url = new URL(db.koboldURL)
|
||||
if(url.pathname.length < 3){
|
||||
url.pathname = 'api/v1/generate'
|
||||
@@ -1364,7 +1364,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
const da = await globalFetch(url.toString(), {
|
||||
method: "POST",
|
||||
body: {
|
||||
"prompt": proompt,
|
||||
"prompt": prompt,
|
||||
"temperature": (db.temperature / 100),
|
||||
"top_p": 0.9
|
||||
},
|
||||
@@ -2199,12 +2199,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
|
||||
}
|
||||
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 argument = {
|
||||
"prompt": proompt,
|
||||
"prompt": prompt,
|
||||
"params": {
|
||||
"n": 1,
|
||||
"max_context_length": db.maxContext + 100,
|
||||
@@ -2292,8 +2292,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
if(aiModel.startsWith('hf:::')){
|
||||
const realModel = aiModel.split(":::")[1]
|
||||
const suggesting = model === "submodel"
|
||||
const proompt = applyChatTemplate(formated)
|
||||
const v = await runTransformers(proompt, realModel, {
|
||||
const prompt = applyChatTemplate(formated)
|
||||
const v = await runTransformers(prompt, realModel, {
|
||||
temperature: temperature,
|
||||
max_new_tokens: maxTokens,
|
||||
top_k: db.ooba.top_k,
|
||||
@@ -2309,12 +2309,12 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
||||
if(aiModel.startsWith('local_')){
|
||||
console.log('running local model')
|
||||
const suggesting = model === "submodel"
|
||||
const proompt = applyChatTemplate(formated)
|
||||
const prompt = applyChatTemplate(formated)
|
||||
const stopStrings = getStopStrings(suggesting)
|
||||
console.log(stopStrings)
|
||||
const modelPath = aiModel.replace('local_', '')
|
||||
const res = await runGGUFModel({
|
||||
prompt: proompt,
|
||||
prompt: prompt,
|
||||
modelPath: modelPath,
|
||||
temperature: temperature,
|
||||
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[] = [
|
||||
{
|
||||
@@ -25,7 +25,7 @@ export async function stableDiff(currentChar:character,prompt:string){
|
||||
},
|
||||
{
|
||||
role: 'user',
|
||||
content: proompt
|
||||
content: promptItem
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -780,7 +780,7 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"mode": "instruct"
|
||||
},
|
||||
"top_p": 1,
|
||||
"proomptSettings": {
|
||||
"promptSettings": {
|
||||
"assistantPrefill": "",
|
||||
"postEndInnerFormat": "",
|
||||
"sendChatAsSystem": false,
|
||||
|
||||
Reference in New Issue
Block a user