diff --git a/public/scripts/extensions/objective/index.js b/public/scripts/extensions/objective/index.js
index 21739b6f8..8f651c205 100644
--- a/public/scripts/extensions/objective/index.js
+++ b/public/scripts/extensions/objective/index.js
@@ -69,10 +69,17 @@ function getTaskByIdRecurse(taskId, task) {
return null;
}
+function substituteParamsPrompts(content) {
+ content = content.replace(/{{objective}}/gi, currentObjective.description)
+ content = content.replace(/{{task}}/gi, currentTask.description)
+ content = substituteParams(content)
+ return content
+}
+
// Call Quiet Generate to create task list using character context, then convert to tasks. Should not be called much.
async function generateTasks() {
- const prompt = substituteParams(objectivePrompts.createTask.replace(/{{objective}}/gi, currentObjective.description));
+ const prompt = substituteParamsPrompts(objectivePrompts.createTask);
console.log(`Generating tasks for objective with prompt`)
toastr.info('Generating tasks for objective', 'Please wait...');
const taskResponse = await generateQuietPrompt(prompt)
@@ -101,7 +108,7 @@ async function checkTaskCompleted() {
}
checkCounter = $('#objective-check-frequency').val()
- const prompt = substituteParams(objectivePrompts.checkTaskCompleted.replace(/{{task}}/gi, currentTask.description));
+ const prompt = substituteParamsPrompts(objectivePrompts.checkTaskCompleted);
const taskResponse = (await generateQuietPrompt(prompt)).toLowerCase()
// Check response if task complete
@@ -149,7 +156,7 @@ function setCurrentTask(taskId = null) {
// Don't just check for a current task, check if it has data
const description = currentTask.description || null;
if (description) {
- const extensionPromptText = objectivePrompts.currentTask.replace(/{{task}}/gi, description);
+ const extensionPromptText = substituteParamsPrompts(objectivePrompts.currentTask);
// Remove highlights
$('.objective-task').css({'border-color':'','border-width':''})
@@ -163,7 +170,6 @@ function setCurrentTask(taskId = null) {
highlightTask = parent
}
-
// Update the extension prompt
context.setExtensionPrompt(MODULE_NAME, extensionPromptText, 1, $('#objective-chat-depth').val());
console.info(`Current task in context.extensionPrompts.Objective is ${JSON.stringify(context.extensionPrompts.Objective)}`);
@@ -369,6 +375,8 @@ function onEditPromptClick() {
let popupText = ''
popupText += `
+ Edit prompts used by Objective for this session. You can use {{objective}} or {{task}} plus any other standard template variables. Save template to persist changes.
+
@@ -378,12 +386,12 @@ function onEditPromptClick() {