Merge branch 'kwaroran:dev' into dev
This commit is contained in:
@@ -382,7 +382,8 @@ async function importSpecv2(card:CharacterCardV2, img?:Uint8Array):Promise<boole
|
||||
mode: "normal",
|
||||
alwaysActive: book.constant ?? false,
|
||||
selective: book.selective ?? false,
|
||||
extentions: {...book.extensions, risu_case_sensitive: book.case_sensitive}
|
||||
extentions: {...book.extensions, risu_case_sensitive: book.case_sensitive},
|
||||
activationPercent: book.extensions?.risu_activationPercent
|
||||
})
|
||||
}
|
||||
|
||||
@@ -450,18 +451,26 @@ export async function exportSpecV2(char:character) {
|
||||
|
||||
let charBook:charBookEntry[] = []
|
||||
for(const lore of char.globalLore){
|
||||
let ext:{
|
||||
risu_case_sensitive?: boolean;
|
||||
risu_activationPercent?: number
|
||||
} = cloneDeep(lore.extentions ?? {})
|
||||
|
||||
let caseSensitive = ext.risu_case_sensitive ?? false
|
||||
ext.risu_activationPercent = lore.activationPercent
|
||||
|
||||
charBook.push({
|
||||
keys: lore.key.split(',').map(r => r.trim()),
|
||||
secondary_keys: lore.selective ? lore.secondkey.split(',').map(r => r.trim()) : undefined,
|
||||
content: lore.content,
|
||||
extensions: lore.extentions ?? {},
|
||||
extensions: ext,
|
||||
enabled: true,
|
||||
insertion_order: lore.insertorder,
|
||||
constant: lore.alwaysActive,
|
||||
selective:lore.selective,
|
||||
name: lore.comment,
|
||||
comment: lore.comment,
|
||||
case_sensitive: lore.extentions?.risu_case_sensitive
|
||||
case_sensitive: caseSensitive,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ export type GroupOrder = {
|
||||
|
||||
export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] {
|
||||
let order:GroupOrder[] = [];
|
||||
let ids:string[] = []
|
||||
if (input) {
|
||||
const words = getWords(input)
|
||||
|
||||
@@ -66,6 +67,7 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] {
|
||||
|
||||
if (charNameChunks.includes(word)) {
|
||||
order.push(char);
|
||||
ids.push(char.id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -74,15 +76,15 @@ export function groupOrder(chars:GroupOrder[], input:string):GroupOrder[] {
|
||||
|
||||
const shuffled = shuffle(chars)
|
||||
for (const char of shuffled) {
|
||||
if(order.includes(char)){
|
||||
if(ids.includes(char.id)){
|
||||
continue
|
||||
}
|
||||
|
||||
//TODO
|
||||
const chance = 0.5
|
||||
const chance = char.talkness ?? 0.5
|
||||
|
||||
if (chance >= Math.random()) {
|
||||
order.push(char);
|
||||
ids.push(char.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
talkness: nowChatroom.characterActive[i] ? nowChatroom.characterTalks[i] : -1,
|
||||
index: i
|
||||
}
|
||||
}).filter((v) => {
|
||||
return v.talkness > 0
|
||||
})
|
||||
if(!nowChatroom.orderByOrder){
|
||||
order = groupOrder(order, lastMessage?.data).filter((v) => {
|
||||
@@ -207,7 +209,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
return (unformated[key] as OpenAIChat[]).map((d) => {
|
||||
return d.content
|
||||
}).join('\n\n')
|
||||
}).join('\n\n')) + db.maxResponse) + 100
|
||||
}).join('\n\n')) + db.maxResponse) + 130
|
||||
|
||||
|
||||
const examples = exampleMessage(currentChar)
|
||||
|
||||
@@ -2,7 +2,7 @@ import { get } from "svelte/store";
|
||||
import {selectedCharID} from '../stores'
|
||||
import { DataBase, setDatabase, type loreBook } from "../storage/database";
|
||||
import { tokenize } from "../tokenizer";
|
||||
import { selectSingleFile } from "../util";
|
||||
import { checkNullish, selectSingleFile } from "../util";
|
||||
import { alertError, alertNormal } from "../alert";
|
||||
import { language } from "../../lang";
|
||||
import { downloadFile } from "../storage/globalApi";
|
||||
@@ -80,6 +80,16 @@ export async function loadLoreBookPrompt(){
|
||||
for (const lore of fullLore){
|
||||
if(lore){
|
||||
if(lore.key.length > 1 || lore.alwaysActive){
|
||||
if(!checkNullish(lore.activationPercent)){
|
||||
let activationPercent = lore.activationPercent
|
||||
if(isNaN(activationPercent) || !activationPercent || activationPercent < 0){
|
||||
activationPercent = 0
|
||||
}
|
||||
if(activationPercent < (Math.random() * 100)){
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
formatedLore.push({
|
||||
keys: lore.alwaysActive ? 'always' : (lore.key ?? '').replace(rmRegex, '').toLocaleLowerCase().split(',').filter((a) => {
|
||||
return a.length > 1
|
||||
|
||||
@@ -8,7 +8,7 @@ import { defaultAutoSuggestPrompt, defaultJailbreak, defaultMainPrompt } from '.
|
||||
|
||||
export const DataBase = writable({} as any as Database)
|
||||
export const loadedStore = writable(false)
|
||||
export let appVer = '1.21.2'
|
||||
export let appVer = '1.22.2'
|
||||
|
||||
export function setDatabase(data:Database){
|
||||
if(checkNullish(data.characters)){
|
||||
@@ -283,6 +283,7 @@ export interface loreBook{
|
||||
extentions?:{
|
||||
risu_case_sensitive:boolean
|
||||
}
|
||||
activationPercent?:number
|
||||
}
|
||||
|
||||
export interface character{
|
||||
|
||||
Reference in New Issue
Block a user