Skip to content

Commit 0a2ff6d

Browse files
author
prima
committed
feat: Added if the output is visible to the user as part of the command information
1 parent 9464aff commit 0a2ff6d

File tree

1 file changed

+85
-80
lines changed

1 file changed

+85
-80
lines changed

klite.embd

Lines changed: 85 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -25669,6 +25669,33 @@ else
2566925669

2567025670
let getChatOpponentRandomly = () => {
2567125671
return getRandomElemFromArray(localsettings.chatopponent.split("||$||"))
25672+
}
25673+
25674+
let objToText = (obj, depth = 0) => {
25675+
// Hard recursion limit
25676+
if (depth > 1000)
25677+
{
25678+
return ""
25679+
}
25680+
let baseIndent = "", output = ""
25681+
for (let i = 0; i < depth; i++) {
25682+
baseIndent += "\t"
25683+
}
25684+
switch (typeof obj) {
25685+
case "array":
25686+
output += `${baseIndent}Array:\n${obj.map(elem => `${baseIndent}\tElement: ${objToText(elem, depth + 1)}`).join("\n")}`
25687+
break
25688+
case "object":
25689+
let keys = Object.keys(obj)
25690+
output += keys.map(key => {
25691+
return `${baseIndent}-> ${key}:\n${objToText(obj[key], depth + 1)}`
25692+
}).join("\n")
25693+
break
25694+
default:
25695+
output += `${baseIndent}${JSON.stringify(obj)}`
25696+
break
25697+
}
25698+
return output
2567225699
}
2567325700

2567425701
let wordCountEnabled = false
@@ -25691,6 +25718,7 @@ else
2569125718
}
2569225719
},
2569325720
"enabled": true,
25721+
"outputVisibleToUser": true,
2569425722
"executor": (action) => {
2569525723
let suggestions = action?.args?.suggestionsToPickFrom
2569625724
if (!!suggestions && Array.isArray(suggestions)) {
@@ -25719,6 +25747,7 @@ else
2571925747
"message": "<message to send>",
2572025748
},
2572125749
"enabled": true,
25750+
"outputVisibleToUser": true,
2572225751
"executor": (action) => {
2572325752
addThought(createAIPrompt, localsettings.inject_chatnames_instruct ? `${action?.args?.whoToSendMessageAs}: ${action?.args?.message}` : action?.args?.message)
2572425753
}
@@ -25742,8 +25771,8 @@ else
2574225771
"enabled": localsettings.websearch_enabled,
2574325772
"executor": async (action) => {
2574425773
await(new Promise((resolve, reject) => { PerformWebsearch(`${action?.args?.query}`, resolve) }));
25745-
let webResp = JSON.stringify(lastSearchResults);
25746-
addThought(createSysPrompt, "Web search results: " + webResp)
25774+
let webResp = objToText(lastSearchResults);
25775+
addThought(createSysPrompt, `Web search results: \n${webResp, 1}`)
2574725776
}
2574825777
},
2574925778
{
@@ -25760,20 +25789,21 @@ else
2576025789
}
2576125790
},
2576225791
"enabled": true,
25763-
"executor": (action) => {
25764-
let numDice = action?.args?.numDice
25765-
let numSides = action?.args?.numSides
25766-
if (!!numDice && !!numSides) {
25767-
let results = []
25768-
for (let roll = 0; roll < numDice; roll++) {
25769-
results.push(Math.ceil(Math.random() * numSides))
25770-
}
25771-
addThought(createSysPrompt, `Rolled ${numDice} dice with ${numSides} sides: ${results.join(", ")}`)
25772-
}
25773-
else {
25774-
addThought(createSysPrompt, `Could not roll dice as the format was incorrect`)
25792+
"outputVisibleToUser": true,
25793+
"executor": (action) => {
25794+
let numDice = action?.args?.numDice
25795+
let numSides = action?.args?.numSides
25796+
if (!!numDice && !!numSides) {
25797+
let results = []
25798+
for (let roll = 0; roll < numDice; roll++) {
25799+
results.push(Math.ceil(Math.random() * numSides))
2577525800
}
25801+
addThought(createSysPrompt, `Rolled ${numDice} dice with ${numSides} sides: ${results.join(", ")}`)
2577625802
}
25803+
else {
25804+
addThought(createSysPrompt, `Could not roll dice as the format was incorrect`)
25805+
}
25806+
}
2577725807
},
2577825808
{
2577925809
"name": "get_random_terms_from_table",
@@ -25789,6 +25819,7 @@ else
2578925819
enum: getTableNamesFromTextDB()
2579025820
}
2579125821
},
25822+
"outputVisibleToUser": true,
2579225823
"enabled": getTableNamesFromTextDB().length > 0,
2579325824
"executor": (action) => {
2579425825
let numOfTerms = action?.args?.numOfTerms
@@ -25884,7 +25915,6 @@ else
2588425915
"executor": (action) => {
2588525916
let systemPrompt = action?.args?.text
2588625917
if (!!systemPrompt) {
25887-
// localsettings.instruct_sysprompt = systemPrompt
2588825918
current_memory = `{{[SYSTEM]}}${systemPrompt}{{[SYSTEM_END]}}`
2588925919
addThought(createSysPrompt, `Setting overview has been overwritten`)
2589025920
}
@@ -26023,47 +26053,47 @@ else
2602326053
}
2602426054
},
2602526055
{
26026-
"name": "analyse_image",
26027-
"description": "Produces a description about an image using AI based on a prompt and an input image. Will prompt the user to select an image to analyse.",
26028-
"args": {
26029-
"prompt": "<prompt to query image about>"
26030-
},
26031-
"enabled": is_using_kcpp_with_llava(), // Only enabled if local endpoint exists / is in use
26032-
"executor": async (action) => {
26033-
let analysisPrompt = "Describe the image in detail. Transcribe and include any text from the image in the description."
26034-
if (!!action?.args?.prompt) {
26035-
analysisPrompt += `Specifically please focus on:\n\n${action?.args?.prompt}`
26056+
"name": "analyse_image",
26057+
"description": "Produces a description about an image using AI based on a prompt and an input image. Will prompt the user to select an image to analyse. It does not provide the original prompt used to generate the image.",
26058+
"args": {
26059+
"prompt": "<prompt to query image about>"
26060+
},
26061+
"enabled": is_using_kcpp_with_llava(), // Only enabled if local endpoint exists / is in use
26062+
"executor": async (action) => {
26063+
let analysisPrompt = "Describe the image in detail. Transcribe and include any text from the image in the description."
26064+
if (!!action?.args?.prompt) {
26065+
analysisPrompt += `Specifically please focus on:\n\n${action?.args?.prompt}`
26066+
}
26067+
if (!!analysisPrompt) {
26068+
waitingFori2iSelection = true
26069+
addThought(createSysPrompt, `Please click an image as a source for image analysis`, true)
26070+
26071+
let waitForI2ILoop = () => {
26072+
return new Promise((resolve, reject) => {
26073+
let intervalId = setInterval(() => {
26074+
if (waitingFori2iSelection === false || endCurrent) {
26075+
clearInterval(intervalId)
26076+
resolve()
26077+
}
26078+
}, 1000)
26079+
})
2603626080
}
26037-
if (!!analysisPrompt) {
26038-
waitingFori2iSelection = true
26039-
addThought(createSysPrompt, `Please click an image as a source for image analysis`, true)
26040-
26041-
let waitForI2ILoop = () => {
26042-
return new Promise((resolve, reject) => {
26043-
let intervalId = setInterval(() => {
26044-
if (waitingFori2iSelection === false || endCurrent) {
26045-
clearInterval(intervalId)
26046-
resolve()
26047-
}
26048-
}, 1000)
26049-
})
26050-
}
26051-
await waitForI2ILoop()
26052-
if (!!i2i64) {
26053-
let parts = i2i64.split(',');
26054-
if (parts.length === 2 && parts[0].startsWith('data:image')) {
26055-
i2i64 = parts[1];
26056-
}
26057-
let analysisResult = await generateAndGetTextFromPrompt(`${createInstructPrompt(analysisPrompt)}${instructendplaceholder}${!!localsettings?.inject_jailbreak_instruct ? localsettings.custom_jailbreak_text : ""}`, undefined, [i2i64])
26058-
addThought(createSysPrompt, `Image analysed: ${analysisResult}`)
26081+
await waitForI2ILoop()
26082+
if (!!i2i64) {
26083+
let parts = i2i64.split(',');
26084+
if (parts.length === 2 && parts[0].startsWith('data:image')) {
26085+
i2i64 = parts[1];
2605926086
}
26060-
else {
26061-
addThought(createSysPrompt, `User did not select an image - no image analysed`)
26062-
}
26063-
i2i64 = undefined;
26064-
waitingFori2iSelection = false;
26087+
let analysisResult = await generateAndGetTextFromPrompt(`${createInstructPrompt(analysisPrompt)}${instructendplaceholder}${!!localsettings?.inject_jailbreak_instruct ? localsettings.custom_jailbreak_text : ""}`, undefined, [i2i64])
26088+
addThought(createSysPrompt, `Image analysed: ${analysisResult}`)
26089+
}
26090+
else {
26091+
addThought(createSysPrompt, `User did not select an image - no image analysed`)
2606526092
}
26093+
i2i64 = undefined;
26094+
waitingFori2iSelection = false;
2606626095
}
26096+
}
2606726097
},
2606826098
{
2606926099
"name": "generate_image",
@@ -26079,6 +26109,7 @@ else
2607926109
description: "<aspect ratio - must be \"landscape\", \"portrait\" or \"square\">"
2608026110
}
2608126111
},
26112+
"outputVisibleToUser": true,
2608226113
"enabled": localsettings.generate_images_mode == 2, // Only enabled if local endpoint exists / is in use
2608326114
"executor": async (action) => {
2608426115
let prompt = action?.args?.prompt
@@ -26171,6 +26202,7 @@ else
2617126202
"args": {
2617226203
"textToSay": "<text to say>"
2617326204
},
26205+
"outputVisibleToUser": true,
2617426206
"enabled": localsettings.speech_synth == KCPP_TTS_ID, // Only enabled if local endpoint exists / is in use
2617526207
"executor": (action) => {
2617626208
let textToSay = action?.args?.textToSay
@@ -26373,7 +26405,7 @@ else
2637326405
// https://github.com/Wladastic/mini_autogpt is the original repo for these prompts - They have been modified with some attempted improvements. It is MIT licensed.
2637426406
let getCommandsAsText = (commands = getEnabledCommands()) => {
2637526407
return commands.map(command => {
26376-
let baseCommand = `Command: ${command.name}\nDescription: ${command.description}`
26408+
let baseCommand = `Command: ${command.name}\nDescription: ${command.description}\nIs output visible to user: ${!!command?.outputVisibleToUser}`
2637726409
if (!!command.args)
2637826410
{
2637926411
let args = Object.keys(command.args).map(key => {
@@ -26858,33 +26890,6 @@ let checkFinalThoughtsPrompt = `Action: {"command":{"name":"thought","args":{"me
2685826890
}
2685926891
return wistr
2686026892
}
26861-
26862-
let objToText = (obj, depth = 0) => {
26863-
// Hard recursion limit
26864-
if (depth > 1000)
26865-
{
26866-
return ""
26867-
}
26868-
let baseIndent = "", output = ""
26869-
for (let i = 0; i < depth; i++) {
26870-
baseIndent += "\t"
26871-
}
26872-
switch (typeof obj) {
26873-
case "array":
26874-
output += `${baseIndent}Array:\n${obj.map(elem => `${baseIndent}\tElement: ${objToText(elem, depth + 1)}`).join("\n")}`
26875-
break
26876-
case "object":
26877-
let keys = Object.keys(obj)
26878-
output += keys.map(key => {
26879-
return `${baseIndent}-> ${key}:\n${objToText(obj[key], depth + 1)}`
26880-
}).join("\n")
26881-
break
26882-
default:
26883-
output += `${baseIndent}${JSON.stringify(obj)}`
26884-
break
26885-
}
26886-
return output
26887-
}
2688826893
let actionToText = (action) => {
2688926894
let actionAsText = `Name: ${action.name}\n`
2689026895
if (!!action.args)

0 commit comments

Comments
 (0)