[feat] add modify request chat
This commit is contained in:
@@ -224,9 +224,9 @@ let compCode:{[key:string]:string[]} = {}
|
|||||||
|
|
||||||
export async function runCharacterJS(arg:{
|
export async function runCharacterJS(arg:{
|
||||||
code: string|null,
|
code: string|null,
|
||||||
mode: ScriptMode|'onButtonClick'
|
mode: ScriptMode|'onButtonClick'|'modifyRequestChat'
|
||||||
data: string
|
data: any
|
||||||
}):Promise<string>{
|
}):Promise<any>{
|
||||||
try {
|
try {
|
||||||
if(arg.code === null){
|
if(arg.code === null){
|
||||||
const db = get(DataBase)
|
const db = get(DataBase)
|
||||||
@@ -238,7 +238,8 @@ export async function runCharacterJS(arg:{
|
|||||||
"editoutput": 'editOutput',
|
"editoutput": 'editOutput',
|
||||||
"editprocess": 'editProcess',
|
"editprocess": 'editProcess',
|
||||||
"editdisplay": 'editDisplay',
|
"editdisplay": 'editDisplay',
|
||||||
'onButtonClick': "onButtonClick"
|
'onButtonClick': "onButtonClick",
|
||||||
|
'modifyRequestChat': 'modifyRequestChat'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
let runCodes = [...additionalCharaJS, arg.code]
|
let runCodes = [...additionalCharaJS, arg.code]
|
||||||
@@ -278,7 +279,7 @@ export async function runCharacterJS(arg:{
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
r = result.toString()
|
r = result
|
||||||
|
|
||||||
if(runCode === 'onButtonClick'){
|
if(runCode === 'onButtonClick'){
|
||||||
return r
|
return r
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { getInlayImage, supportsInlayImage } from "../image";
|
|||||||
import { getGenerationModelString } from "./models/modelString";
|
import { getGenerationModelString } from "./models/modelString";
|
||||||
import { sendPeerChar } from "../sync/multiuser";
|
import { sendPeerChar } from "../sync/multiuser";
|
||||||
import { runInlayScreen } from "./inlayScreen";
|
import { runInlayScreen } from "./inlayScreen";
|
||||||
|
import { runCharacterJS } from "../plugins/embedscript";
|
||||||
|
|
||||||
export interface OpenAIChat{
|
export interface OpenAIChat{
|
||||||
role: 'system'|'user'|'assistant'|'function'
|
role: 'system'|'user'|'assistant'|'function'
|
||||||
@@ -841,6 +842,12 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formated = await runCharacterJS({
|
||||||
|
code: null,
|
||||||
|
mode: 'modifyRequestChat',
|
||||||
|
data: formated
|
||||||
|
})
|
||||||
|
|
||||||
{
|
{
|
||||||
//token rechecking
|
//token rechecking
|
||||||
let tokens = 0
|
let tokens = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user