feat: Add new triggers
This commit is contained in:
@@ -633,4 +633,15 @@ export const languageEnglish = {
|
|||||||
lowLevelAccessConfirm: "This character uses Low Level Access. which means this character can access the AI model and your storage directly. do you really want to import this character?",
|
lowLevelAccessConfirm: "This character uses Low Level Access. which means this character can access the AI model and your storage directly. do you really want to import this character?",
|
||||||
triggerLowLevelOnly: "This trigger only works with Low Level Access. to enable this trigger, enable Low Level Access in advanced settings in the character.",
|
triggerLowLevelOnly: "This trigger only works with Low Level Access. to enable this trigger, enable Low Level Access in advanced settings in the character.",
|
||||||
truthy: "Truthy",
|
truthy: "Truthy",
|
||||||
|
extractRegex: "Extract Text with Regex",
|
||||||
|
runImgGen: "Run Image Generation",
|
||||||
|
cutChat: "Cut Chat",
|
||||||
|
modifyChat: "Modify Chat",
|
||||||
|
regex: "Regex",
|
||||||
|
flags: "Flags",
|
||||||
|
resultFormat: "Result Format",
|
||||||
|
negPrompt: "Negative Prompt",
|
||||||
|
start: "Start",
|
||||||
|
end: "End",
|
||||||
|
index: "Index",
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
location: 'historyend'
|
location: 'historyend'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'setvar'){
|
else if(effect.type === 'setvar'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'setvar',
|
type: 'setvar',
|
||||||
var: '',
|
var: '',
|
||||||
@@ -211,38 +211,38 @@
|
|||||||
operator: '='
|
operator: '='
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'impersonate'){
|
else if(effect.type === 'impersonate'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'impersonate',
|
type: 'impersonate',
|
||||||
role: 'char',
|
role: 'char',
|
||||||
value: ''
|
value: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'command'){
|
else if(effect.type === 'command'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'command',
|
type: 'command',
|
||||||
value: ''
|
value: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'stop'){
|
else if(effect.type === 'stop'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'runtrigger'){
|
else if(effect.type === 'runtrigger'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'runtrigger',
|
type: 'runtrigger',
|
||||||
value: ''
|
value: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'runLLM'){
|
else if(effect.type === 'runLLM'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'runLLM',
|
type: 'runLLM',
|
||||||
value: '',
|
value: '',
|
||||||
inputVar: ''
|
inputVar: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'checkSimilarity'){
|
else if(effect.type === 'checkSimilarity'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'checkSimilarity',
|
type: 'checkSimilarity',
|
||||||
source: '',
|
source: '',
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
inputVar: ''
|
inputVar: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(effect.type === 'showAlert'){
|
else if(effect.type === 'showAlert'){
|
||||||
effect = {
|
effect = {
|
||||||
type: 'showAlert',
|
type: 'showAlert',
|
||||||
alertType: 'normal',
|
alertType: 'normal',
|
||||||
@@ -258,23 +258,58 @@
|
|||||||
inputVar: ''
|
inputVar: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(effect.type === 'extractRegex'){
|
||||||
|
effect ={
|
||||||
|
type: 'extractRegex',
|
||||||
|
value: '',
|
||||||
|
regex: '',
|
||||||
|
flags: '',
|
||||||
|
inputVar: '',
|
||||||
|
result:''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(effect.type === 'runImgGen'){
|
||||||
|
effect = {
|
||||||
|
type: 'runImgGen',
|
||||||
|
value: '',
|
||||||
|
negValue: '',
|
||||||
|
inputVar: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(effect.type === 'sendAIprompt'){
|
||||||
|
effect = {
|
||||||
|
type: 'sendAIprompt'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(effect.type === 'cutchat'){
|
||||||
|
effect = {
|
||||||
|
type: 'cutchat',
|
||||||
|
start: '',
|
||||||
|
end: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(effect.type === 'modifychat'){
|
||||||
|
effect = {
|
||||||
|
type: 'modifychat',
|
||||||
|
value: '',
|
||||||
|
index: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
<OptionInput value="setvar">{language.triggerEffSetVar}</OptionInput>
|
<OptionInput value="setvar">{language.triggerEffSetVar}</OptionInput>
|
||||||
<OptionInput value="impersonate">{language.triggerEffImperson}</OptionInput>
|
<OptionInput value="impersonate">{language.triggerEffImperson}</OptionInput>
|
||||||
<OptionInput value="command">{language.triggerEffCommand}</OptionInput>
|
<OptionInput value="command">{language.triggerEffCommand}</OptionInput>
|
||||||
{#if effect.type === 'systemprompt' || value.type === 'start'}
|
<OptionInput value="systemprompt">{language.triggerEffSysPrompt}</OptionInput>
|
||||||
<OptionInput value="systemprompt">{language.triggerEffSysPrompt}</OptionInput>
|
<OptionInput value="stop">{language.triggerEffStop}</OptionInput>
|
||||||
{/if}
|
|
||||||
{#if effect.type === 'stop' || value.type === 'start'}
|
|
||||||
<OptionInput value="stop">{language.triggerEffStop}</OptionInput>
|
|
||||||
{/if}
|
|
||||||
<OptionInput value="runtrigger">{language.triggerEffRunTrigger}</OptionInput>
|
<OptionInput value="runtrigger">{language.triggerEffRunTrigger}</OptionInput>
|
||||||
<OptionInput value="runLLM">{language.triggerEffRunLLM}</OptionInput>
|
<OptionInput value="runLLM">{language.triggerEffRunLLM}</OptionInput>
|
||||||
<OptionInput value="checkSimilarity">{language.triggerEffCheckSim}</OptionInput>
|
<OptionInput value="checkSimilarity">{language.triggerEffCheckSim}</OptionInput>
|
||||||
<OptionInput value="showAlert">{language.triggerEffShowAlert}</OptionInput>
|
<OptionInput value="showAlert">{language.triggerEffShowAlert}</OptionInput>
|
||||||
{#if effect.type === 'sendAIprompt' || value.type === 'output'}
|
<OptionInput value="sendAIprompt">{language.triggerEffectSendAI}</OptionInput>
|
||||||
<OptionInput value="sendAIprompt">{language.triggerEffectSendAI}</OptionInput>
|
<OptionInput value="extractRegex">{language.extractRegex}</OptionInput>
|
||||||
{/if}
|
<OptionInput value="runImgGen">{language.runImgGen}</OptionInput>
|
||||||
|
<OptionInput value="cutchat">{language.cutChat}</OptionInput>
|
||||||
|
<OptionInput value="modifychat">{language.modifyChat}</OptionInput>
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
{#if
|
{#if
|
||||||
(value.type !== 'start' && (effect.type === 'systemprompt' || effect.type === 'stop')) ||
|
(value.type !== 'start' && (effect.type === 'systemprompt' || effect.type === 'stop')) ||
|
||||||
@@ -283,7 +318,14 @@
|
|||||||
<span class="text-red-400 text-sm">{language.invaildTriggerEffect}</span>
|
<span class="text-red-400 text-sm">{language.invaildTriggerEffect}</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if
|
{#if
|
||||||
!lowLevelAble && (effect.type === 'runLLM' || effect.type === 'checkSimilarity' || effect.type === 'showAlert' || effect.type === 'sendAIprompt')
|
!lowLevelAble && (
|
||||||
|
effect.type === 'runLLM' ||
|
||||||
|
effect.type === 'checkSimilarity' ||
|
||||||
|
effect.type === 'showAlert' ||
|
||||||
|
effect.type === 'sendAIprompt' ||
|
||||||
|
effect.type === 'extractRegex' ||
|
||||||
|
effect.type === 'runImgGen'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
<span class="text-red-400 text-sm">{language.triggerLowLevelOnly}</span>
|
<span class="text-red-400 text-sm">{language.triggerLowLevelOnly}</span>
|
||||||
|
|
||||||
@@ -363,6 +405,51 @@
|
|||||||
<span class="text-textcolor2 text-sm">{language.value}</span>
|
<span class="text-textcolor2 text-sm">{language.value}</span>
|
||||||
<TextAreaInput highlight bind:value={effect.value} />
|
<TextAreaInput highlight bind:value={effect.value} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if effect.type === 'extractRegex'}
|
||||||
|
<span class="text-textcolor2 text-sm">{language.value}</span>
|
||||||
|
<TextAreaInput highlight bind:value={effect.value} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.regex}</span>
|
||||||
|
<TextInput bind:value={effect.regex} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.flags}</span>
|
||||||
|
<TextInput bind:value={effect.flags} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.resultFormat}</span>
|
||||||
|
<TextInput bind:value={effect.result} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.resultStoredVar}</span>
|
||||||
|
<TextInput bind:value={effect.inputVar} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if effect.type === 'runImgGen'}
|
||||||
|
<span class="text-textcolor2 text-sm">{language.prompt}</span>
|
||||||
|
<TextAreaInput highlight bind:value={effect.value} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.negPrompt}</span>
|
||||||
|
<TextAreaInput highlight bind:value={effect.negValue} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.resultStoredVar}</span>
|
||||||
|
<TextInput bind:value={effect.inputVar} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if effect.type === 'cutchat'}
|
||||||
|
<span class="text-textcolor2 text-sm">{language.start}</span>
|
||||||
|
<TextInput bind:value={effect.start} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.end}</span>
|
||||||
|
<TextInput bind:value={effect.end} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if effect.type === 'modifychat'}
|
||||||
|
<span class="text-textcolor2 text-sm">{language.index}</span>
|
||||||
|
<TextInput bind:value={effect.index} />
|
||||||
|
|
||||||
|
<span class="text-textcolor2 text-sm">{language.value}</span>
|
||||||
|
<TextAreaInput highlight bind:value={effect.value} />
|
||||||
|
|
||||||
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export interface triggerscript{
|
|||||||
|
|
||||||
export type triggerCondition = triggerConditionsVar|triggerConditionsExists|triggerConditionsChatIndex
|
export type triggerCondition = triggerConditionsVar|triggerConditionsExists|triggerConditionsChatIndex
|
||||||
|
|
||||||
export type triggerEffect = triggerEffectImgGen|triggerEffectRegex|triggerEffectRunLLM|triggerEffectCheckSimilarity|triggerEffectSendAIprompt|triggerEffectShowAlert|triggerEffectSetvar|triggerEffectSystemPrompt|triggerEffectImpersonate|triggerEffectCommand|triggerEffectStop|triggerEffectRunTrigger
|
export type triggerEffect = triggerEffectCutChat|triggerEffectModifyChat|triggerEffectImgGen|triggerEffectRegex|triggerEffectRunLLM|triggerEffectCheckSimilarity|triggerEffectSendAIprompt|triggerEffectShowAlert|triggerEffectSetvar|triggerEffectSystemPrompt|triggerEffectImpersonate|triggerEffectCommand|triggerEffectStop|triggerEffectRunTrigger
|
||||||
|
|
||||||
export type triggerConditionsVar = {
|
export type triggerConditionsVar = {
|
||||||
type:'var'|'value'
|
type:'var'|'value'
|
||||||
@@ -52,6 +52,18 @@ export interface triggerEffectSetvar{
|
|||||||
value:string
|
value:string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface triggerEffectCutChat{
|
||||||
|
type: 'cutchat',
|
||||||
|
start: string,
|
||||||
|
end: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface triggerEffectModifyChat{
|
||||||
|
type: 'modifychat',
|
||||||
|
index: string,
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface triggerEffectSystemPrompt{
|
export interface triggerEffectSystemPrompt{
|
||||||
type: 'systemprompt',
|
type: 'systemprompt',
|
||||||
location: 'start'|'historyend'|'promptend',
|
location: 'start'|'historyend'|'promptend',
|
||||||
@@ -345,6 +357,20 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case 'cutchat':{
|
||||||
|
const start = Number(risuChatParser(effect.start,{chara:char}))
|
||||||
|
const end = Number(risuChatParser(effect.end,{chara:char}))
|
||||||
|
chat.message = chat.message.slice(start,end)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'modifychat':{
|
||||||
|
const index = Number(risuChatParser(effect.index,{chara:char}))
|
||||||
|
const value = risuChatParser(effect.value,{chara:char})
|
||||||
|
if(chat.message[index]){
|
||||||
|
chat.message[index].data = value
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
// low level access only
|
// low level access only
|
||||||
case 'showAlert':{
|
case 'showAlert':{
|
||||||
|
|||||||
Reference in New Issue
Block a user