[feat] nai improvements, better authornote
This commit is contained in:
@@ -304,7 +304,14 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
break
|
||||
}
|
||||
case 'authornote':{
|
||||
await tokenizeChatArray(unformated.authorNote)
|
||||
let pmt = cloneDeep(unformated.authorNote)
|
||||
if(card.innerFormat && pmt.length > 0){
|
||||
for(let i=0;i<pmt.length;i++){
|
||||
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||
}
|
||||
}
|
||||
|
||||
await tokenizeChatArray(pmt)
|
||||
break
|
||||
}
|
||||
case 'lorebook':{
|
||||
@@ -588,7 +595,14 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
break
|
||||
}
|
||||
case 'authornote':{
|
||||
pushPrompts(unformated.authorNote)
|
||||
let pmt = cloneDeep(unformated.authorNote)
|
||||
if(card.innerFormat && pmt.length > 0){
|
||||
for(let i=0;i<pmt.length;i++){
|
||||
pmt[i].content = risuChatParser(card.innerFormat, {chara: currentChar}).replace('{{slot}}', pmt[i].content || card.defaultText || '')
|
||||
}
|
||||
}
|
||||
|
||||
pushPrompts(pmt)
|
||||
break
|
||||
}
|
||||
case 'lorebook':{
|
||||
@@ -705,6 +719,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
useStreaming: true,
|
||||
isGroupChat: nowChatroom.type === 'group',
|
||||
bias: {},
|
||||
continue: arg.continue,
|
||||
}, 'model', abortSignal)
|
||||
|
||||
let result = ''
|
||||
|
||||
@@ -6,8 +6,6 @@ import { alertError, alertInput, alertNormal, alertWait } from "src/ts/alert"
|
||||
import { sleep } from "src/ts/util"
|
||||
|
||||
export function stringlizeNAIChat(formated:OpenAIChat[], char:string, continued: boolean){
|
||||
|
||||
|
||||
const db = get(DataBase)
|
||||
let seperator = db.NAIsettings.seperator.replaceAll("\\n","\n") || '\n'
|
||||
let starter = db.NAIsettings.starter.replaceAll("\\n","\n") || '⁂'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type Proompt = ProomptPlain|ProomptTyped|ProomptChat;
|
||||
export type Proompt = ProomptPlain|ProomptTyped|ProomptChat|ProomptAuthorNote;
|
||||
|
||||
export interface ProomptPlain {
|
||||
type: 'plain'|'jailbreak';
|
||||
@@ -8,10 +8,16 @@ export interface ProomptPlain {
|
||||
}
|
||||
|
||||
export interface ProomptTyped {
|
||||
type: 'persona'|'description'|'authornote'|'lorebook'|'postEverything'
|
||||
type: 'persona'|'description'|'lorebook'|'postEverything'
|
||||
innerFormat?: string
|
||||
}
|
||||
|
||||
export interface ProomptAuthorNote {
|
||||
type : 'authornote'
|
||||
innerFormat?: string
|
||||
defaultText?: string
|
||||
}
|
||||
|
||||
|
||||
export interface ProomptChat {
|
||||
type: 'chat';
|
||||
|
||||
@@ -471,17 +471,17 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
]
|
||||
},
|
||||
"NAI2": {
|
||||
"name": "New Preset",
|
||||
"name": "Carefree",
|
||||
"apiType": "gpt35",
|
||||
"openAIKey": "",
|
||||
"mainPrompt": "",
|
||||
"jailbreak": "",
|
||||
"globalNote": "",
|
||||
"temperature": 136,
|
||||
"temperature": 135,
|
||||
"maxContext": 4000,
|
||||
"maxResponse": 500,
|
||||
"frequencyPenalty": 70,
|
||||
"PresensePenalty": 70,
|
||||
"PresensePenalty": 0,
|
||||
"formatingOrder": [
|
||||
"main",
|
||||
"description",
|
||||
@@ -501,32 +501,7 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"forceReplaceUrl": "",
|
||||
"forceReplaceUrl2": "",
|
||||
"promptPreprocess": false,
|
||||
"bias": [
|
||||
[
|
||||
"{{char}}:",
|
||||
-10
|
||||
],
|
||||
[
|
||||
"{{user}}:",
|
||||
-10
|
||||
],
|
||||
[
|
||||
"\\n{{char}}:",
|
||||
-10
|
||||
],
|
||||
[
|
||||
"\\n{{user}}:",
|
||||
-10
|
||||
],
|
||||
[
|
||||
"\\n{{char}} :",
|
||||
-10
|
||||
],
|
||||
[
|
||||
"\\n{{user}} :",
|
||||
-10
|
||||
]
|
||||
],
|
||||
"bias": [],
|
||||
"koboldURL": null,
|
||||
"proxyKey": "",
|
||||
"ooba": {
|
||||
@@ -576,7 +551,7 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"proxyRequestModel": "",
|
||||
"openrouterRequestModel": "openai/gpt-3.5-turbo",
|
||||
"NAISettings": {
|
||||
"topK": 12,
|
||||
"topK": 15,
|
||||
"topP": 0.85,
|
||||
"topA": 0.1,
|
||||
"tailFreeSampling": 0.915,
|
||||
@@ -585,9 +560,9 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"repetitionPenaltySlope": 0.02,
|
||||
"repostitionPenaltyPresence": 0,
|
||||
"seperator": "",
|
||||
"frequencyPenalty": 0.03,
|
||||
"frequencyPenalty": 0.02,
|
||||
"presencePenalty": 0,
|
||||
"typicalp": 0.81,
|
||||
"typicalp": 1,
|
||||
"starter": "",
|
||||
"cfg_scale": 1,
|
||||
"mirostat_tau": 0,
|
||||
@@ -610,22 +585,16 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"rangeStart": -6,
|
||||
"rangeEnd": -4
|
||||
},
|
||||
{
|
||||
"type": "plain",
|
||||
"text": "----",
|
||||
"role": "system",
|
||||
"type2": "normal"
|
||||
},
|
||||
{
|
||||
"type": "persona",
|
||||
"innerFormat": null
|
||||
"innerFormat": "----\n{{slot}}"
|
||||
},
|
||||
{
|
||||
"type": "lorebook"
|
||||
},
|
||||
{
|
||||
"type": "description",
|
||||
"innerFormat": null
|
||||
"innerFormat": "----\n{{slot}}"
|
||||
},
|
||||
{
|
||||
"type": "plain",
|
||||
@@ -648,7 +617,7 @@ export const prebuiltPresets:{OAI:botPreset,ooba:botPreset,NAI:botPreset,oobaRp:
|
||||
"rangeEnd": "end"
|
||||
}
|
||||
],
|
||||
"NAIadventure": true,
|
||||
"NAIadventure": false,
|
||||
"NAIappendName": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { clone, cloneDeep } from 'lodash';
|
||||
import { defaultAutoSuggestPrompt, defaultJailbreak, defaultMainPrompt } from './defaultPrompts';
|
||||
import { alertNormal } from '../alert';
|
||||
import type { NAISettings } from '../process/models/nai';
|
||||
import { prebuiltNAIpresets } from '../process/templates/templates';
|
||||
import { prebuiltNAIpresets, prebuiltPresets } from '../process/templates/templates';
|
||||
import { defaultColorScheme, type ColorScheme } from '../gui/colorscheme';
|
||||
import type { Proompt } from '../process/proompt';
|
||||
|
||||
@@ -955,12 +955,36 @@ export function downloadPreset(id:number){
|
||||
}
|
||||
|
||||
export async function importPreset(){
|
||||
const f = await selectSingleFile(["json"])
|
||||
const f = await selectSingleFile(["json", "preset"])
|
||||
if(!f){
|
||||
return
|
||||
}
|
||||
let db = get(DataBase)
|
||||
const pre = (JSON.parse(Buffer.from(f.data).toString('utf-8')))
|
||||
if(pre.presetVersion && pre.presetVersion >= 3){
|
||||
//NAI preset
|
||||
const pr = cloneDeep(prebuiltPresets.NAI2)
|
||||
pr.temperature = pre.parameters.temperature * 100
|
||||
pr.maxResponse = pre.parameters.max_length
|
||||
pr.NAISettings.topK = pre.parameters.top_k
|
||||
pr.NAISettings.topP = pre.parameters.top_p
|
||||
pr.NAISettings.topA = pre.parameters.top_a
|
||||
pr.NAISettings.typicalp = pre.parameters.typical_p
|
||||
pr.NAISettings.tailFreeSampling = pre.parameters.tail_free_sampling
|
||||
pr.NAISettings.repetitionPenalty = pre.parameters.repetition_penalty
|
||||
pr.NAISettings.repetitionPenaltyRange = pre.parameters.repetition_penalty_range
|
||||
pr.NAISettings.repetitionPenaltySlope = pre.parameters.repetition_penalty_slope
|
||||
pr.NAISettings.frequencyPenalty = pre.parameters.repetition_penalty_frequency
|
||||
pr.NAISettings.repostitionPenaltyPresence = pre.parameters.repetition_penalty_presence
|
||||
pr.PresensePenalty = pre.parameters.repetition_penalty_presence * 100
|
||||
pr.NAISettings.cfg_scale = pre.parameters.cfg_scale
|
||||
pr.NAISettings.mirostat_lr = pre.parameters.mirostat_lr
|
||||
pr.NAISettings.mirostat_tau = pre.parameters.mirostat_tau
|
||||
pr.name = pre.name ?? "Imported"
|
||||
db.botPresets.push(pr)
|
||||
setDatabase(db)
|
||||
return
|
||||
}
|
||||
pre.name ??= "Imported"
|
||||
db.botPresets.push(pre)
|
||||
setDatabase(db)
|
||||
|
||||
@@ -293,4 +293,20 @@ export async function getEmotion(db:Database,chaEmotion:{[key:string]: [string,
|
||||
}
|
||||
}
|
||||
return datas
|
||||
}
|
||||
|
||||
export function getAuthorNoteDefaultText(){
|
||||
const db = get(DataBase)
|
||||
const template = db.promptTemplate
|
||||
if(!template){
|
||||
return ''
|
||||
}
|
||||
|
||||
for(const v of template){
|
||||
if(v.type === 'authornote'){
|
||||
return v.defaultText ?? ''
|
||||
}
|
||||
}
|
||||
return ''
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user