Add groupOtherBotRole and groupTemplate
This commit is contained in:
@@ -1782,9 +1782,14 @@ export function risuChatParser(da:string, arg:{
|
||||
|
||||
if(aChara){
|
||||
if(typeof(aChara) !== 'string' && aChara.type === 'group'){
|
||||
const gc = findCharacterbyId(aChara.chats[aChara.chatPage].message.at(-1).saying ?? '')
|
||||
if(gc.name !== 'Unknown Character'){
|
||||
chara = gc
|
||||
if(aChara.chats[aChara.chatPage].message.length > 0){
|
||||
const gc = findCharacterbyId(aChara.chats[aChara.chatPage].message.at(-1).saying ?? '')
|
||||
if(gc.name !== 'Unknown Character'){
|
||||
chara = gc
|
||||
}
|
||||
}
|
||||
else{
|
||||
chara = 'bot'
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
@@ -699,10 +699,25 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
}
|
||||
|
||||
let attr:string[] = []
|
||||
let role:'user'|'assistant'|'system' = msg.role === 'user' ? 'user' : 'assistant'
|
||||
|
||||
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.promptSettings.sendName)){
|
||||
formatedChat = name + ': ' + formatedChat
|
||||
attr.push('nameAdded')
|
||||
if(
|
||||
(nowChatroom.type === 'group' && findCharacterbyIdwithCache(msg.saying).chaId !== currentChar.chaId) ||
|
||||
(nowChatroom.type === 'group' && db.groupOtherBotRole === 'assistant') ||
|
||||
(usingPromptTemplate && db.promptSettings.sendName)
|
||||
){
|
||||
const form = db.groupTemplate || `<{{char}}\'s Message>\n{{slot}}\n</{{char}}\'s Message>`
|
||||
formatedChat = risuChatParser(form, {chara: findCharacterbyIdwithCache(msg.saying).name}).replace('{{slot}}', formatedChat)
|
||||
switch(db.groupOtherBotRole){
|
||||
case 'user':
|
||||
case 'assistant':
|
||||
case 'system':
|
||||
role = db.groupOtherBotRole
|
||||
break
|
||||
default:
|
||||
role = 'assistant'
|
||||
break
|
||||
}
|
||||
}
|
||||
if(usingPromptTemplate && db.promptSettings.maxThoughtTagDepth !== -1){
|
||||
const depth = ms.length - index
|
||||
@@ -712,7 +727,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
}
|
||||
|
||||
const chat:OpenAIChat = {
|
||||
role: msg.role === 'user' ? 'user' : 'assistant',
|
||||
role: role,
|
||||
content: formatedChat,
|
||||
memo: msg.chatId,
|
||||
attr: attr,
|
||||
@@ -725,6 +740,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
||||
currentTokens += await tokenizer.tokenizeChat(chat)
|
||||
index++
|
||||
}
|
||||
console.log(JSON.stringify(chats, null, 2))
|
||||
|
||||
const depthPrompts = lorepmt.actives.filter(v => {
|
||||
return (v.pos === 'depth' && v.depth > 0) || v.pos === 'reverse_depth'
|
||||
|
||||
@@ -442,6 +442,7 @@ export function setDatabase(data:Database){
|
||||
}
|
||||
data.customQuotes ??= false
|
||||
data.customQuotesData ??= ['“','”','‘','’']
|
||||
data.groupOtherBotRole ??= 'user'
|
||||
changeLanguage(data.language)
|
||||
DataBase.set(data)
|
||||
}
|
||||
@@ -747,6 +748,8 @@ export interface Database{
|
||||
}
|
||||
customQuotes:boolean
|
||||
customQuotesData?:[string, string, string, string]
|
||||
groupTemplate?:string
|
||||
groupOtherBotRole?:string
|
||||
}
|
||||
|
||||
export interface customscript{
|
||||
@@ -1008,6 +1011,8 @@ export interface botPreset{
|
||||
jsonSchema?:string
|
||||
strictJsonSchema?:boolean
|
||||
extractJson?:string
|
||||
groupTemplate?:string
|
||||
groupOtherBotRole?:string
|
||||
}
|
||||
|
||||
|
||||
@@ -1298,6 +1303,8 @@ export function saveCurrentPreset(){
|
||||
jsonSchema:db.jsonSchema ?? '',
|
||||
strictJsonSchema:db.strictJsonSchema ?? true,
|
||||
extractJson:db.extractJson ?? '',
|
||||
groupOtherBotRole: db.groupOtherBotRole ?? 'user',
|
||||
groupTemplate: db.groupTemplate ?? '',
|
||||
}
|
||||
db.botPresets = pres
|
||||
setDatabase(db)
|
||||
@@ -1390,6 +1397,8 @@ export function setPreset(db:Database, newPres: botPreset){
|
||||
db.jsonSchema = newPres.jsonSchema ?? ''
|
||||
db.strictJsonSchema = newPres.strictJsonSchema ?? true
|
||||
db.extractJson = newPres.extractJson ?? ''
|
||||
db.groupOtherBotRole = newPres.groupOtherBotRole ?? 'user'
|
||||
db.groupTemplate = newPres.groupTemplate ?? ''
|
||||
return db
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user