Add request related triggers
This commit is contained in:
@@ -365,6 +365,16 @@ export const languageEnglish = {
|
|||||||
v2UpdateGUIDesc: "Update GUI",
|
v2UpdateGUIDesc: "Update GUI",
|
||||||
v2Wait: "Wait",
|
v2Wait: "Wait",
|
||||||
v2WaitDesc: "Wait {{value}} seconds",
|
v2WaitDesc: "Wait {{value}} seconds",
|
||||||
|
v2GetRequestState: "Get Request Data Content",
|
||||||
|
v2GetRequestStateDesc: "Get Request Content at {{index}} => {{outputVar}}",
|
||||||
|
v2SetRequestState: "Set Request Data Content",
|
||||||
|
v2SetRequestStateDesc: "Set Request Content at {{index}} to {{value}}",
|
||||||
|
v2GetRequestStateRole: "Get Request Data Role",
|
||||||
|
v2GetRequestStateRoleDesc: "Get Request Data Role at {{index}} => {{outputVar}}",
|
||||||
|
v2SetRequestStateRole: "Set Request Data Role",
|
||||||
|
v2SetRequestStateRoleDesc: "Set Request Data Role at {{index}} to {{value}}",
|
||||||
|
v2GetRequestStateLength: "Get Request Data Length",
|
||||||
|
v2GetRequestStateLengthDesc: "Get Request Data Length => {{outputVar}}",
|
||||||
},
|
},
|
||||||
|
|
||||||
confirm: "Confirm",
|
confirm: "Confirm",
|
||||||
|
|||||||
@@ -317,6 +317,16 @@ export const languageKorean = {
|
|||||||
"v2UpdateGUIDesc": "GUI 업데이트",
|
"v2UpdateGUIDesc": "GUI 업데이트",
|
||||||
"v2Wait": "기다리기",
|
"v2Wait": "기다리기",
|
||||||
"v2WaitDesc": "{{value}} 초 기다리기",
|
"v2WaitDesc": "{{value}} 초 기다리기",
|
||||||
|
"v2GetRequestState": "리퀘스트 데이터 내용 가져오기",
|
||||||
|
"v2GetRequestStateDesc": "{{index}}에서 리퀘스트 내용 가져오기 => {{outputVar}}",
|
||||||
|
"v2SetRequestState": "리퀘스트 데이터 내용 설정",
|
||||||
|
"v2SetRequestStateDesc": "{{index}}에 있는 리퀘스트 내용을 {{value}}로 설정",
|
||||||
|
"v2GetRequestStateRole": "리퀘스트 데이터 역할 가져오기",
|
||||||
|
"v2GetRequestStateRoleDesc": "{{index}}에서 리퀘스트 데이터 역할 가져오기 => {{outputVar}}",
|
||||||
|
"v2SetRequestStateRole": "리퀘스트 데이터 역할 설정",
|
||||||
|
"v2SetRequestStateRoleDesc": "{{index}}에 있는 리퀘스트 데이터 역할을 {{value}}로 설정",
|
||||||
|
"v2GetRequestStateLength": "리퀘스트 데이터 길이 가져오기",
|
||||||
|
"v2GetRequestStateLengthDesc": "리퀘스트 데이터 길이 가져오기 => {{outputVar}}",
|
||||||
},
|
},
|
||||||
"confirm": "확인",
|
"confirm": "확인",
|
||||||
"goback": "뒤로",
|
"goback": "뒤로",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import Portal from "src/lib/UI/GUI/Portal.svelte";
|
import Portal from "src/lib/UI/GUI/Portal.svelte";
|
||||||
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
|
import SelectInput from "src/lib/UI/GUI/SelectInput.svelte";
|
||||||
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
|
import TextInput from "src/lib/UI/GUI/TextInput.svelte";
|
||||||
import { type triggerEffectV2, type triggerEffect, type triggerscript, displayAllowList } from "src/ts/process/triggers";
|
import { type triggerEffectV2, type triggerEffect, type triggerscript, displayAllowList, requestAllowList } from "src/ts/process/triggers";
|
||||||
import { sleep } from "src/ts/util";
|
import { sleep } from "src/ts/util";
|
||||||
import { onDestroy, onMount } from "svelte";
|
import { onDestroy, onMount } from "svelte";
|
||||||
|
|
||||||
@@ -20,6 +20,11 @@
|
|||||||
//Special
|
//Special
|
||||||
'v2GetDisplayState',
|
'v2GetDisplayState',
|
||||||
'v2SetDisplayState',
|
'v2SetDisplayState',
|
||||||
|
'v2GetRequestState',
|
||||||
|
'v2SetRequestState',
|
||||||
|
'v2GetRequestStateRole',
|
||||||
|
'v2SetRequestStateRole',
|
||||||
|
'v2GetRequestStateLength',
|
||||||
|
|
||||||
//Control
|
//Control
|
||||||
'v2SetVar',
|
'v2SetVar',
|
||||||
@@ -102,6 +107,16 @@
|
|||||||
'v2RunImgGen'
|
'v2RunImgGen'
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const specialTypes = [
|
||||||
|
'v2GetDisplayState',
|
||||||
|
'v2SetDisplayState',
|
||||||
|
'v2GetRequestState',
|
||||||
|
'v2SetRequestState',
|
||||||
|
'v2GetRequestStateRole',
|
||||||
|
'v2SetRequestStateRole',
|
||||||
|
'v2GetRequestStateLength',
|
||||||
|
]
|
||||||
|
|
||||||
let lastClickTime = 0
|
let lastClickTime = 0
|
||||||
let { value = $bindable([]), lowLevelAble = false }: Props = $props();
|
let { value = $bindable([]), lowLevelAble = false }: Props = $props();
|
||||||
@@ -123,12 +138,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkSupported = (e:string) => {
|
const checkSupported = (e:string) => {
|
||||||
if(e === 'v2SetDisplayState' || e === 'v2GetDisplayState'){
|
|
||||||
return value[selectedIndex].type === 'display'
|
|
||||||
}
|
|
||||||
if(value[selectedIndex].type === 'display'){
|
if(value[selectedIndex].type === 'display'){
|
||||||
return displayAllowList.includes(e)
|
return displayAllowList.includes(e)
|
||||||
}
|
}
|
||||||
|
if(value[selectedIndex].type === 'request'){
|
||||||
|
return requestAllowList.includes(e)
|
||||||
|
}
|
||||||
|
if(specialTypes.includes(e)){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if(lowLevelAble){
|
if(lowLevelAble){
|
||||||
return true
|
return true
|
||||||
@@ -665,6 +683,56 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'v2GetRequestState':{
|
||||||
|
editTrigger = {
|
||||||
|
type: 'v2GetRequestState',
|
||||||
|
outputVar: '',
|
||||||
|
index: '',
|
||||||
|
indexType: 'value',
|
||||||
|
indent: 0
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'v2SetRequestState':{
|
||||||
|
editTrigger = {
|
||||||
|
type: 'v2SetRequestState',
|
||||||
|
value: '',
|
||||||
|
valueType: 'value',
|
||||||
|
index: '',
|
||||||
|
indexType: 'value',
|
||||||
|
indent: 0
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'v2GetRequestStateRole':{
|
||||||
|
editTrigger = {
|
||||||
|
type: 'v2GetRequestStateRole',
|
||||||
|
outputVar: '',
|
||||||
|
index: '',
|
||||||
|
indexType: 'value',
|
||||||
|
indent: 0
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'v2SetRequestStateRole':{
|
||||||
|
editTrigger = {
|
||||||
|
type: 'v2SetRequestStateRole',
|
||||||
|
value: '',
|
||||||
|
valueType: 'value',
|
||||||
|
index: '',
|
||||||
|
indexType: 'value',
|
||||||
|
indent: 0
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'v2GetRequestStateLength':{
|
||||||
|
editTrigger = {
|
||||||
|
type: 'v2GetRequestStateLength',
|
||||||
|
outputVar: '',
|
||||||
|
indent: 0
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,6 +931,7 @@
|
|||||||
<OptionInput value="input">{language.triggerInput}</OptionInput>
|
<OptionInput value="input">{language.triggerInput}</OptionInput>
|
||||||
<OptionInput value="manual">{language.triggerManual}</OptionInput>
|
<OptionInput value="manual">{language.triggerManual}</OptionInput>
|
||||||
<OptionInput value="display">{language.editDisplay}</OptionInput>
|
<OptionInput value="display">{language.editDisplay}</OptionInput>
|
||||||
|
<OptionInput value="request">{language.editProcess}</OptionInput>
|
||||||
|
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
</div>
|
</div>
|
||||||
@@ -1513,6 +1582,57 @@
|
|||||||
<OptionInput value="var">{language.var}</OptionInput>
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
</SelectInput>
|
</SelectInput>
|
||||||
<TextInput bind:value={editTrigger.value} />
|
<TextInput bind:value={editTrigger.value} />
|
||||||
|
{:else if editTrigger.type === 'v2GetRequestState'}
|
||||||
|
<span class="block text-textcolor">{language.index}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.indexType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.index} />
|
||||||
|
|
||||||
|
<span class="block text-textcolor">{language.outputVar}</span>
|
||||||
|
<TextInput bind:value={editTrigger.outputVar} />
|
||||||
|
{:else if editTrigger.type === 'v2GetRequestStateRole'}
|
||||||
|
<span class="block text-textcolor">{language.index}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.indexType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.index} />
|
||||||
|
|
||||||
|
<span class="block text-textcolor">{language.outputVar}</span>
|
||||||
|
<TextInput bind:value={editTrigger.outputVar} />
|
||||||
|
{:else if editTrigger.type === 'v2SetRequestState'}
|
||||||
|
<span class="block text-textcolor">{language.index}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.indexType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.index} />
|
||||||
|
|
||||||
|
<span class="block text-textcolor">{language.value}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.valueType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.value} />
|
||||||
|
{:else if editTrigger.type === 'v2SetRequestStateRole'}
|
||||||
|
<span class="block text-textcolor">{language.index}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.indexType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.index} />
|
||||||
|
|
||||||
|
<span class="block text-textcolor">{language.value}</span>
|
||||||
|
<SelectInput bind:value={editTrigger.valueType}>
|
||||||
|
<OptionInput value="value">{language.value}</OptionInput>
|
||||||
|
<OptionInput value="var">{language.var}</OptionInput>
|
||||||
|
</SelectInput>
|
||||||
|
<TextInput bind:value={editTrigger.value} />
|
||||||
|
{:else if editTrigger.type === 'v2GetRequestStateLength'}
|
||||||
|
<span class="block text-textcolor">{language.outputVar}</span>
|
||||||
|
<TextInput bind:value={editTrigger.outputVar} />
|
||||||
{:else}
|
{:else}
|
||||||
<span>{language.noConfig}</span>
|
<span>{language.noConfig}</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { MultiModal, OpenAIChat, OpenAIChatFull } from "./index.svelte";
|
import type { MultiModal, OpenAIChat, OpenAIChatFull } from "./index.svelte";
|
||||||
import { getCurrentCharacter, getDatabase, setDatabase, type character } from "../storage/database.svelte";
|
import { getCurrentCharacter, getCurrentChat, getDatabase, setDatabase, type character } from "../storage/database.svelte";
|
||||||
import { pluginProcess, pluginV2 } from "../plugins/plugins";
|
import { pluginProcess, pluginV2 } from "../plugins/plugins";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { stringlizeAINChat, getStopStrings, unstringlizeAIN, unstringlizeChat } from "./stringlize";
|
import { stringlizeAINChat, getStopStrings, unstringlizeAIN, unstringlizeChat } from "./stringlize";
|
||||||
@@ -21,6 +21,7 @@ import { applyChatTemplate } from "./templates/chatTemplate";
|
|||||||
import { OobaParams } from "./prompt";
|
import { OobaParams } from "./prompt";
|
||||||
import { extractJSON, getGeneralJSONSchema, getOpenAIJSONSchema } from "./templates/jsonSchema";
|
import { extractJSON, getGeneralJSONSchema, getOpenAIJSONSchema } from "./templates/jsonSchema";
|
||||||
import { getModelInfo, LLMFlags, LLMFormat, type LLMModel } from "../model/modellist";
|
import { getModelInfo, LLMFlags, LLMFormat, type LLMModel } from "../model/modellist";
|
||||||
|
import { runTrigger } from "./triggers";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -243,6 +244,29 @@ export async function requestChatData(arg:requestDataArgument, model:ModelModeEx
|
|||||||
arg.formated = await replacer(arg.formated, model)
|
arg.formated = await replacer(arg.formated, model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
const currentChar = getCurrentCharacter()
|
||||||
|
if(currentChar.type !== 'group'){
|
||||||
|
const perf = performance.now()
|
||||||
|
const d = await runTrigger(currentChar, 'request', {
|
||||||
|
chat: getCurrentChat(),
|
||||||
|
displayMode: true,
|
||||||
|
displayData: JSON.stringify(arg.formated)
|
||||||
|
})
|
||||||
|
|
||||||
|
const got = JSON.parse(d.displayData)
|
||||||
|
if(!got || !Array.isArray(got)){
|
||||||
|
throw new Error('Invalid return')
|
||||||
|
}
|
||||||
|
arg.formated = got
|
||||||
|
console.log('Trigger time', performance.now() - perf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const da = await requestChatDataMain(arg, model, abortSignal)
|
const da = await requestChatDataMain(arg, model, abortSignal)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { parseKeyValue, sleep } from "../util";
|
|||||||
import { alertError, alertInput, alertNormal, alertSelect } from "../alert";
|
import { alertError, alertInput, alertNormal, alertSelect } from "../alert";
|
||||||
import type { OpenAIChat } from "./index.svelte";
|
import type { OpenAIChat } from "./index.svelte";
|
||||||
import { HypaProcesser } from "./memory/hypamemory";
|
import { HypaProcesser } from "./memory/hypamemory";
|
||||||
import { requestChatData } from "./request";
|
import { requestChatData, type OpenAIChatExtra } from "./request";
|
||||||
import { generateAIImage } from "./stableDiff";
|
import { generateAIImage } from "./stableDiff";
|
||||||
import { writeInlayImage } from "./files/inlays";
|
import { writeInlayImage } from "./files/inlays";
|
||||||
import { runLua } from "./lua";
|
import { runLua } from "./lua";
|
||||||
@@ -17,7 +17,7 @@ import { runLua } from "./lua";
|
|||||||
|
|
||||||
export interface triggerscript{
|
export interface triggerscript{
|
||||||
comment: string;
|
comment: string;
|
||||||
type: 'start'|'manual'|'output'|'input'|'display'
|
type: 'start'|'manual'|'output'|'input'|'display'|'request'
|
||||||
conditions: triggerCondition[]
|
conditions: triggerCondition[]
|
||||||
effect:triggerEffect[]
|
effect:triggerEffect[]
|
||||||
lowLevelAccess?: boolean
|
lowLevelAccess?: boolean
|
||||||
@@ -37,7 +37,8 @@ export type triggerEffectV2 = triggerV2Header|triggerV2IfVar|triggerV2Else|tri
|
|||||||
triggerV2SetCharacterDesc|triggerV2MakeArrayVar|triggerV2GetArrayVarLength|triggerV2GetArrayVar|triggerV2SetArrayVar|
|
triggerV2SetCharacterDesc|triggerV2MakeArrayVar|triggerV2GetArrayVarLength|triggerV2GetArrayVar|triggerV2SetArrayVar|
|
||||||
triggerV2PushArrayVar|triggerV2PopArrayVar|triggerV2ShiftArrayVar|triggerV2UnshiftArrayVar|triggerV2SpliceArrayVar|triggerV2GetFirstMessage|
|
triggerV2PushArrayVar|triggerV2PopArrayVar|triggerV2ShiftArrayVar|triggerV2UnshiftArrayVar|triggerV2SpliceArrayVar|triggerV2GetFirstMessage|
|
||||||
triggerV2SliceArrayVar|triggerV2GetIndexOfValueInArrayVar|triggerV2RemoveIndexFromArrayVar|triggerV2ConcatString|triggerV2GetLastUserMessage|
|
triggerV2SliceArrayVar|triggerV2GetIndexOfValueInArrayVar|triggerV2RemoveIndexFromArrayVar|triggerV2ConcatString|triggerV2GetLastUserMessage|
|
||||||
triggerV2GetLastCharMessage|triggerV2GetAlertInput|triggerV2GetDisplayState|triggerV2SetDisplayState|triggerV2UpdateGUI|triggerV2Wait
|
triggerV2GetLastCharMessage|triggerV2GetAlertInput|triggerV2GetDisplayState|triggerV2SetDisplayState|triggerV2UpdateGUI|triggerV2Wait|
|
||||||
|
triggerV2GetRequestState|triggerV2SetRequestState|triggerV2GetRequestStateRole|triggerV2SetRequestStateRole|triggerV2GetReuqestStateLength
|
||||||
|
|
||||||
export type triggerConditionsVar = {
|
export type triggerConditionsVar = {
|
||||||
type:'var'|'value'
|
type:'var'|'value'
|
||||||
@@ -95,7 +96,7 @@ export interface triggerEffectImpersonate{
|
|||||||
value:string
|
value:string
|
||||||
}
|
}
|
||||||
|
|
||||||
type triggerMode = 'start'|'manual'|'output'|'input'|'display'
|
type triggerMode = 'start'|'manual'|'output'|'input'|'display'|'request'
|
||||||
|
|
||||||
export interface triggerEffectCommand{
|
export interface triggerEffectCommand{
|
||||||
type: 'command',
|
type: 'command',
|
||||||
@@ -625,6 +626,46 @@ export type triggerV2SetDisplayState = {
|
|||||||
indent: number
|
indent: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type triggerV2GetRequestState = {
|
||||||
|
type: 'v2GetRequestState',
|
||||||
|
outputVar: string,
|
||||||
|
index: string,
|
||||||
|
indexType: 'var'|'value',
|
||||||
|
indent: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type triggerV2GetRequestStateRole = {
|
||||||
|
type: 'v2GetRequestStateRole',
|
||||||
|
outputVar: string,
|
||||||
|
index: string,
|
||||||
|
indexType: 'var'|'value',
|
||||||
|
indent: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type triggerV2SetRequestState = {
|
||||||
|
type: 'v2SetRequestState',
|
||||||
|
value: string,
|
||||||
|
valueType: 'var'|'value',
|
||||||
|
index: string,
|
||||||
|
indexType: 'var'|'value',
|
||||||
|
indent: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type triggerV2SetRequestStateRole = {
|
||||||
|
type: 'v2SetRequestStateRole',
|
||||||
|
value: string,
|
||||||
|
valueType: 'var'|'value',
|
||||||
|
index: string,
|
||||||
|
indexType: 'var'|'value',
|
||||||
|
indent: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type triggerV2GetReuqestStateLength = {
|
||||||
|
type: 'v2GetRequestStateLength',
|
||||||
|
outputVar: string,
|
||||||
|
indent: number
|
||||||
|
}
|
||||||
|
|
||||||
export type triggerV2UpdateGUI = {
|
export type triggerV2UpdateGUI = {
|
||||||
type: 'v2UpdateGUI',
|
type: 'v2UpdateGUI',
|
||||||
indent: number
|
indent: number
|
||||||
@@ -637,9 +678,7 @@ export type triggerV2Wait = {
|
|||||||
indent: number
|
indent: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const displayAllowList = [
|
const safeSubset = [
|
||||||
'v2GetDisplayState',
|
|
||||||
'v2SetDisplayState',
|
|
||||||
'v2SetVar',
|
'v2SetVar',
|
||||||
'v2If',
|
'v2If',
|
||||||
'v2Else',
|
'v2Else',
|
||||||
@@ -671,6 +710,21 @@ export const displayAllowList = [
|
|||||||
'v2RemoveIndexFromArrayVar'
|
'v2RemoveIndexFromArrayVar'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const displayAllowList = [
|
||||||
|
'v2GetDisplayState',
|
||||||
|
'v2SetDisplayState',
|
||||||
|
...safeSubset
|
||||||
|
]
|
||||||
|
|
||||||
|
export const requestAllowList = [
|
||||||
|
'v2GetRequestState',
|
||||||
|
'v2SetRequestState',
|
||||||
|
'v2GetRequestStateRole',
|
||||||
|
'v2SetRequestStateRole',
|
||||||
|
'v2GetRequestStateLength',
|
||||||
|
...safeSubset
|
||||||
|
]
|
||||||
|
|
||||||
export async function runTrigger(char:character,mode:triggerMode, arg:{
|
export async function runTrigger(char:character,mode:triggerMode, arg:{
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
recursiveCount?: number
|
recursiveCount?: number
|
||||||
@@ -838,7 +892,10 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
|
|
||||||
for(let index = 0; index < trigger.effect.length; index++){
|
for(let index = 0; index < trigger.effect.length; index++){
|
||||||
const effect = trigger.effect[index]
|
const effect = trigger.effect[index]
|
||||||
if(arg.displayMode && !displayAllowList.includes(effect.type)){
|
if(mode === 'display' && !displayAllowList.includes(effect.type)){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if(mode === 'request' && !requestAllowList.includes(effect.type)){
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch(effect.type){
|
switch(effect.type){
|
||||||
@@ -1704,6 +1761,59 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
|
|||||||
await sleep(value * 1000)
|
await sleep(value * 1000)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case 'v2GetRequestState':{
|
||||||
|
if(!arg.displayMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const json = JSON.parse(arg.displayData) as OpenAIChat[]
|
||||||
|
const index = effect.indexType === 'value' ? Number(risuChatParser(effect.index,{chara:char})) : Number(getVar(risuChatParser(effect.index,{chara:char})))
|
||||||
|
const content = json?.[index]?.content ?? 'null'
|
||||||
|
setVar(effect.outputVar, content)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'v2SetRequestState':{
|
||||||
|
if(!arg.displayMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const json = JSON.parse(arg.displayData) as OpenAIChat[]
|
||||||
|
const index = effect.indexType === 'value' ? Number(risuChatParser(effect.index,{chara:char})) : Number(getVar(risuChatParser(effect.index,{chara:char})))
|
||||||
|
const value = effect.valueType === 'value' ? risuChatParser(effect.value,{chara:char}) : getVar(risuChatParser(effect.value,{chara:char}))
|
||||||
|
json[index].content = value
|
||||||
|
arg.displayData = JSON.stringify(json)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'v2GetRequestStateRole':{
|
||||||
|
if(!arg.displayMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const json = JSON.parse(arg.displayData) as OpenAIChat[]
|
||||||
|
const index = effect.indexType === 'value' ? Number(risuChatParser(effect.index,{chara:char})) : Number(getVar(risuChatParser(effect.index,{chara:char})))
|
||||||
|
const content = json?.[index]?.role ?? 'null'
|
||||||
|
setVar(effect.outputVar, content)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case 'v2SetRequestStateRole':{
|
||||||
|
if(!arg.displayMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const json = JSON.parse(arg.displayData) as OpenAIChat[]
|
||||||
|
const index = effect.indexType === 'value' ? Number(risuChatParser(effect.index,{chara:char})) : Number(getVar(risuChatParser(effect.index,{chara:char})))
|
||||||
|
const value = effect.valueType === 'value' ? risuChatParser(effect.value,{chara:char}) : getVar(risuChatParser(effect.value,{chara:char}))
|
||||||
|
if(value === 'user' || value === 'assistant' || value === 'system'){
|
||||||
|
json[index].role = value
|
||||||
|
}
|
||||||
|
arg.displayData = JSON.stringify(json)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'v2GetRequestStateLength':{
|
||||||
|
if(!arg.displayMode){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const json = JSON.parse(arg.displayData) as OpenAIChat[]
|
||||||
|
setVar(effect.outputVar, json.length.toString())
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user