Add groupOtherBotRole and groupTemplate
This commit is contained in:
@@ -162,6 +162,8 @@ export const languageEnglish = {
|
|||||||
strictJsonSchema: "If enabled, it will strictly follow the Provided Schema for JSON on some models. if it is disabled, it may ignore the JSON Schema.",
|
strictJsonSchema: "If enabled, it will strictly follow the Provided Schema for JSON on some models. if it is disabled, it may ignore the JSON Schema.",
|
||||||
extractJson: "If it is not blank, it will extract specific JSON data from the response. for example, if you want to extract `response.text[0]` in response `{\"response\": {\"text\": [\"hello\"]}}`, you can put `response.text.0`.",
|
extractJson: "If it is not blank, it will extract specific JSON data from the response. for example, if you want to extract `response.text[0]` in response `{\"response\": {\"text\": [\"hello\"]}}`, you can put `response.text.0`.",
|
||||||
translatorNote: "Here, you can add a unique translation prompt for each character. This option only applies when using the Ax. model for translation. To apply it, include `{{slot::tnote}}` in the language settings. It doesn't work in group chats.",
|
translatorNote: "Here, you can add a unique translation prompt for each character. This option only applies when using the Ax. model for translation. To apply it, include `{{slot::tnote}}` in the language settings. It doesn't work in group chats.",
|
||||||
|
groupInnerFormat: "This defines a format that is used in group chat for characters that isn't speaker. if it is not blank, it will use this format instead of the default format. if `Group Other Bot Role` is `assistant`, it will also be applied to the speaker.",
|
||||||
|
groupOtherBotRole: "This defines a role that is used in group chat for characters that isn't speaker.",
|
||||||
},
|
},
|
||||||
setup: {
|
setup: {
|
||||||
chooseProvider: "Choose AI Provider",
|
chooseProvider: "Choose AI Provider",
|
||||||
@@ -743,4 +745,7 @@ export const languageEnglish = {
|
|||||||
trailingSingleQuote: "Trailing Single Quote",
|
trailingSingleQuote: "Trailing Single Quote",
|
||||||
trailingDoubleQuote: "Trailing Double Quote",
|
trailingDoubleQuote: "Trailing Double Quote",
|
||||||
translatorNote: "Translator's Note",
|
translatorNote: "Translator's Note",
|
||||||
|
formatGroupInSingle: "Format Group in Single",
|
||||||
|
groupInnerFormat: "Non-Speaker Inner Format",
|
||||||
|
groupOtherBotRole: "Non-Speaker Role in Group",
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
|
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
|
||||||
import Help from "src/lib/Others/Help.svelte";
|
import Help from "src/lib/Others/Help.svelte";
|
||||||
import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte";
|
import TextAreaInput from "src/lib/UI/GUI/TextAreaInput.svelte";
|
||||||
|
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
|
||||||
|
import OptionInput from "src/lib/UI/GUI/OptionInput.svelte";
|
||||||
|
|
||||||
let sorted = 0
|
let sorted = 0
|
||||||
let opened = 0
|
let opened = 0
|
||||||
@@ -112,7 +114,7 @@
|
|||||||
<TextInput bind:value={$DataBase.promptSettings.postEndInnerFormat}/>
|
<TextInput bind:value={$DataBase.promptSettings.postEndInnerFormat}/>
|
||||||
|
|
||||||
<Check bind:check={$DataBase.promptSettings.sendChatAsSystem} name={language.sendChatAsSystem} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.sendChatAsSystem} name={language.sendChatAsSystem} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.promptSettings.sendName} name={language.sendName} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.sendName} name={language.formatGroupInSingle} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.promptSettings.utilOverride} name={language.utilOverride} className="mt-4"/>
|
<Check bind:check={$DataBase.promptSettings.utilOverride} name={language.utilOverride} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.jsonSchemaEnabled} name={language.enableJsonSchema} className="mt-4"/>
|
<Check bind:check={$DataBase.jsonSchemaEnabled} name={language.enableJsonSchema} className="mt-4"/>
|
||||||
<Check bind:check={$DataBase.strictJsonSchema} name={language.strictJsonSchema} className="mt-4"/>
|
<Check bind:check={$DataBase.strictJsonSchema} name={language.strictJsonSchema} className="mt-4"/>
|
||||||
@@ -124,10 +126,18 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
|
<span class="text-textcolor mt-4">{language.maxThoughtTagDepth}</span>
|
||||||
<NumberInput bind:value={$DataBase.promptSettings.maxThoughtTagDepth}/>
|
<NumberInput bind:value={$DataBase.promptSettings.maxThoughtTagDepth}/>
|
||||||
|
<span class="text-textcolor mt-4">{language.groupOtherBotRole} <Help key="groupOtherBotRole"/></span>
|
||||||
|
<SelectInput bind:value={$DataBase.groupOtherBotRole}>
|
||||||
|
<OptionInput value="user">User</OptionInput>
|
||||||
|
<OptionInput value="system">System</OptionInput>
|
||||||
|
<OptionInput value="assistant">assistant</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
<span class="text-textcolor mt-4">{language.customPromptTemplateToggle} <Help key='customPromptTemplateToggle' /></span>
|
<span class="text-textcolor mt-4">{language.customPromptTemplateToggle} <Help key='customPromptTemplateToggle' /></span>
|
||||||
<TextAreaInput bind:value={$DataBase.customPromptTemplateToggle}/>
|
<TextAreaInput bind:value={$DataBase.customPromptTemplateToggle}/>
|
||||||
<span class="text-textcolor mt-4">{language.defaultVariables} <Help key='defaultVariables' /></span>
|
<span class="text-textcolor mt-4">{language.defaultVariables} <Help key='defaultVariables' /></span>
|
||||||
<TextAreaInput bind:value={$DataBase.templateDefaultVariables}/>
|
<TextAreaInput bind:value={$DataBase.templateDefaultVariables}/>
|
||||||
|
<span class="text-textcolor mt-4">{language.groupInnerFormat} <Help key='groupInnerFormat' /></span>
|
||||||
|
<TextAreaInput placeholder={`<{{char}}\'s Message>\n{{slot}}\n</{{char}}\'s Message>`} bind:value={$DataBase.groupTemplate}/>
|
||||||
{#if $DataBase.jsonSchemaEnabled}
|
{#if $DataBase.jsonSchemaEnabled}
|
||||||
<span class="text-textcolor mt-4">{language.jsonSchema} <Help key='jsonSchema' /></span>
|
<span class="text-textcolor mt-4">{language.jsonSchema} <Help key='jsonSchema' /></span>
|
||||||
<TextAreaInput bind:value={$DataBase.jsonSchema}/>
|
<TextAreaInput bind:value={$DataBase.jsonSchema}/>
|
||||||
|
|||||||
@@ -1782,11 +1782,16 @@ export function risuChatParser(da:string, arg:{
|
|||||||
|
|
||||||
if(aChara){
|
if(aChara){
|
||||||
if(typeof(aChara) !== 'string' && aChara.type === 'group'){
|
if(typeof(aChara) !== 'string' && aChara.type === 'group'){
|
||||||
|
if(aChara.chats[aChara.chatPage].message.length > 0){
|
||||||
const gc = findCharacterbyId(aChara.chats[aChara.chatPage].message.at(-1).saying ?? '')
|
const gc = findCharacterbyId(aChara.chats[aChara.chatPage].message.at(-1).saying ?? '')
|
||||||
if(gc.name !== 'Unknown Character'){
|
if(gc.name !== 'Unknown Character'){
|
||||||
chara = gc
|
chara = gc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
chara = 'bot'
|
||||||
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
chara = aChara
|
chara = aChara
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,10 +699,25 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
}
|
}
|
||||||
|
|
||||||
let attr:string[] = []
|
let attr:string[] = []
|
||||||
|
let role:'user'|'assistant'|'system' = msg.role === 'user' ? 'user' : 'assistant'
|
||||||
|
|
||||||
if(nowChatroom.type === 'group' || (usingPromptTemplate && db.promptSettings.sendName)){
|
if(
|
||||||
formatedChat = name + ': ' + formatedChat
|
(nowChatroom.type === 'group' && findCharacterbyIdwithCache(msg.saying).chaId !== currentChar.chaId) ||
|
||||||
attr.push('nameAdded')
|
(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){
|
if(usingPromptTemplate && db.promptSettings.maxThoughtTagDepth !== -1){
|
||||||
const depth = ms.length - index
|
const depth = ms.length - index
|
||||||
@@ -712,7 +727,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const chat:OpenAIChat = {
|
const chat:OpenAIChat = {
|
||||||
role: msg.role === 'user' ? 'user' : 'assistant',
|
role: role,
|
||||||
content: formatedChat,
|
content: formatedChat,
|
||||||
memo: msg.chatId,
|
memo: msg.chatId,
|
||||||
attr: attr,
|
attr: attr,
|
||||||
@@ -725,6 +740,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{
|
|||||||
currentTokens += await tokenizer.tokenizeChat(chat)
|
currentTokens += await tokenizer.tokenizeChat(chat)
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
|
console.log(JSON.stringify(chats, null, 2))
|
||||||
|
|
||||||
const depthPrompts = lorepmt.actives.filter(v => {
|
const depthPrompts = lorepmt.actives.filter(v => {
|
||||||
return (v.pos === 'depth' && v.depth > 0) || v.pos === 'reverse_depth'
|
return (v.pos === 'depth' && v.depth > 0) || v.pos === 'reverse_depth'
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ export function setDatabase(data:Database){
|
|||||||
}
|
}
|
||||||
data.customQuotes ??= false
|
data.customQuotes ??= false
|
||||||
data.customQuotesData ??= ['“','”','‘','’']
|
data.customQuotesData ??= ['“','”','‘','’']
|
||||||
|
data.groupOtherBotRole ??= 'user'
|
||||||
changeLanguage(data.language)
|
changeLanguage(data.language)
|
||||||
DataBase.set(data)
|
DataBase.set(data)
|
||||||
}
|
}
|
||||||
@@ -747,6 +748,8 @@ export interface Database{
|
|||||||
}
|
}
|
||||||
customQuotes:boolean
|
customQuotes:boolean
|
||||||
customQuotesData?:[string, string, string, string]
|
customQuotesData?:[string, string, string, string]
|
||||||
|
groupTemplate?:string
|
||||||
|
groupOtherBotRole?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface customscript{
|
export interface customscript{
|
||||||
@@ -1008,6 +1011,8 @@ export interface botPreset{
|
|||||||
jsonSchema?:string
|
jsonSchema?:string
|
||||||
strictJsonSchema?:boolean
|
strictJsonSchema?:boolean
|
||||||
extractJson?:string
|
extractJson?:string
|
||||||
|
groupTemplate?:string
|
||||||
|
groupOtherBotRole?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1298,6 +1303,8 @@ export function saveCurrentPreset(){
|
|||||||
jsonSchema:db.jsonSchema ?? '',
|
jsonSchema:db.jsonSchema ?? '',
|
||||||
strictJsonSchema:db.strictJsonSchema ?? true,
|
strictJsonSchema:db.strictJsonSchema ?? true,
|
||||||
extractJson:db.extractJson ?? '',
|
extractJson:db.extractJson ?? '',
|
||||||
|
groupOtherBotRole: db.groupOtherBotRole ?? 'user',
|
||||||
|
groupTemplate: db.groupTemplate ?? '',
|
||||||
}
|
}
|
||||||
db.botPresets = pres
|
db.botPresets = pres
|
||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
@@ -1390,6 +1397,8 @@ export function setPreset(db:Database, newPres: botPreset){
|
|||||||
db.jsonSchema = newPres.jsonSchema ?? ''
|
db.jsonSchema = newPres.jsonSchema ?? ''
|
||||||
db.strictJsonSchema = newPres.strictJsonSchema ?? true
|
db.strictJsonSchema = newPres.strictJsonSchema ?? true
|
||||||
db.extractJson = newPres.extractJson ?? ''
|
db.extractJson = newPres.extractJson ?? ''
|
||||||
|
db.groupOtherBotRole = newPres.groupOtherBotRole ?? 'user'
|
||||||
|
db.groupTemplate = newPres.groupTemplate ?? ''
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user