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?",
|
||||
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",
|
||||
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'
|
||||
}
|
||||
}
|
||||
if(effect.type === 'setvar'){
|
||||
else if(effect.type === 'setvar'){
|
||||
effect = {
|
||||
type: 'setvar',
|
||||
var: '',
|
||||
@@ -211,38 +211,38 @@
|
||||
operator: '='
|
||||
}
|
||||
}
|
||||
if(effect.type === 'impersonate'){
|
||||
else if(effect.type === 'impersonate'){
|
||||
effect = {
|
||||
type: 'impersonate',
|
||||
role: 'char',
|
||||
value: ''
|
||||
}
|
||||
}
|
||||
if(effect.type === 'command'){
|
||||
else if(effect.type === 'command'){
|
||||
effect = {
|
||||
type: 'command',
|
||||
value: ''
|
||||
}
|
||||
}
|
||||
if(effect.type === 'stop'){
|
||||
else if(effect.type === 'stop'){
|
||||
effect = {
|
||||
type: 'stop',
|
||||
}
|
||||
}
|
||||
if(effect.type === 'runtrigger'){
|
||||
else if(effect.type === 'runtrigger'){
|
||||
effect = {
|
||||
type: 'runtrigger',
|
||||
value: ''
|
||||
}
|
||||
}
|
||||
if(effect.type === 'runLLM'){
|
||||
else if(effect.type === 'runLLM'){
|
||||
effect = {
|
||||
type: 'runLLM',
|
||||
value: '',
|
||||
inputVar: ''
|
||||
}
|
||||
}
|
||||
if(effect.type === 'checkSimilarity'){
|
||||
else if(effect.type === 'checkSimilarity'){
|
||||
effect = {
|
||||
type: 'checkSimilarity',
|
||||
source: '',
|
||||
@@ -250,7 +250,7 @@
|
||||
inputVar: ''
|
||||
}
|
||||
}
|
||||
if(effect.type === 'showAlert'){
|
||||
else if(effect.type === 'showAlert'){
|
||||
effect = {
|
||||
type: 'showAlert',
|
||||
alertType: 'normal',
|
||||
@@ -258,23 +258,58 @@
|
||||
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="impersonate">{language.triggerEffImperson}</OptionInput>
|
||||
<OptionInput value="command">{language.triggerEffCommand}</OptionInput>
|
||||
{#if effect.type === 'systemprompt' || value.type === 'start'}
|
||||
<OptionInput value="systemprompt">{language.triggerEffSysPrompt}</OptionInput>
|
||||
{/if}
|
||||
{#if effect.type === 'stop' || value.type === 'start'}
|
||||
<OptionInput value="stop">{language.triggerEffStop}</OptionInput>
|
||||
{/if}
|
||||
<OptionInput value="systemprompt">{language.triggerEffSysPrompt}</OptionInput>
|
||||
<OptionInput value="stop">{language.triggerEffStop}</OptionInput>
|
||||
<OptionInput value="runtrigger">{language.triggerEffRunTrigger}</OptionInput>
|
||||
<OptionInput value="runLLM">{language.triggerEffRunLLM}</OptionInput>
|
||||
<OptionInput value="checkSimilarity">{language.triggerEffCheckSim}</OptionInput>
|
||||
<OptionInput value="showAlert">{language.triggerEffShowAlert}</OptionInput>
|
||||
{#if effect.type === 'sendAIprompt' || value.type === 'output'}
|
||||
<OptionInput value="sendAIprompt">{language.triggerEffectSendAI}</OptionInput>
|
||||
{/if}
|
||||
<OptionInput value="sendAIprompt">{language.triggerEffectSendAI}</OptionInput>
|
||||
<OptionInput value="extractRegex">{language.extractRegex}</OptionInput>
|
||||
<OptionInput value="runImgGen">{language.runImgGen}</OptionInput>
|
||||
<OptionInput value="cutchat">{language.cutChat}</OptionInput>
|
||||
<OptionInput value="modifychat">{language.modifyChat}</OptionInput>
|
||||
</SelectInput>
|
||||
{#if
|
||||
(value.type !== 'start' && (effect.type === 'systemprompt' || effect.type === 'stop')) ||
|
||||
@@ -283,7 +318,14 @@
|
||||
<span class="text-red-400 text-sm">{language.invaildTriggerEffect}</span>
|
||||
{/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>
|
||||
|
||||
@@ -363,6 +405,51 @@
|
||||
<span class="text-textcolor2 text-sm">{language.value}</span>
|
||||
<TextAreaInput highlight bind:value={effect.value} />
|
||||
{/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}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface triggerscript{
|
||||
|
||||
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 = {
|
||||
type:'var'|'value'
|
||||
@@ -52,6 +52,18 @@ export interface triggerEffectSetvar{
|
||||
value:string
|
||||
}
|
||||
|
||||
export interface triggerEffectCutChat{
|
||||
type: 'cutchat',
|
||||
start: string,
|
||||
end: string
|
||||
}
|
||||
|
||||
export interface triggerEffectModifyChat{
|
||||
type: 'modifychat',
|
||||
index: string,
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface triggerEffectSystemPrompt{
|
||||
type: 'systemprompt',
|
||||
location: 'start'|'historyend'|'promptend',
|
||||
@@ -345,6 +357,20 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
||||
}
|
||||
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
|
||||
case 'showAlert':{
|
||||
|
||||
Reference in New Issue
Block a user