#843 Wait for group to stop generating before checking objectives
This commit is contained in:
parent
7596d78322
commit
e5f3a70860
|
@ -334,7 +334,7 @@ async function summarizeChat(context) {
|
||||||
async function summarizeChatMain(context, force) {
|
async function summarizeChatMain(context, force) {
|
||||||
try {
|
try {
|
||||||
// Wait for the send button to be released
|
// Wait for the send button to be released
|
||||||
waitUntilCondition(() => is_send_press === false, 10000, 100);
|
waitUntilCondition(() => is_send_press === false, 30000, 100);
|
||||||
} catch {
|
} catch {
|
||||||
console.debug('Timeout waiting for is_send_press');
|
console.debug('Timeout waiting for is_send_press');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { chat_metadata, callPopup, saveSettingsDebounced, getCurrentChatId } from "../../../script.js";
|
import { chat_metadata, callPopup, saveSettingsDebounced, is_send_press } from "../../../script.js";
|
||||||
import { getContext, extension_settings, saveMetadataDebounced } from "../../extensions.js";
|
import { getContext, extension_settings, saveMetadataDebounced } from "../../extensions.js";
|
||||||
import {
|
import {
|
||||||
substituteParams,
|
substituteParams,
|
||||||
|
@ -7,6 +7,8 @@ import {
|
||||||
generateQuietPrompt,
|
generateQuietPrompt,
|
||||||
} from "../../../script.js";
|
} from "../../../script.js";
|
||||||
import { registerSlashCommand } from "../../slash-commands.js";
|
import { registerSlashCommand } from "../../slash-commands.js";
|
||||||
|
import { waitUntilCondition } from "../../utils.js";
|
||||||
|
import { is_group_generating, selected_group } from "../../group-chats.js";
|
||||||
|
|
||||||
const MODULE_NAME = "Objective"
|
const MODULE_NAME = "Objective"
|
||||||
|
|
||||||
|
@ -86,7 +88,7 @@ async function generateTasks() {
|
||||||
console.log(`Generating tasks for objective with prompt`)
|
console.log(`Generating tasks for objective with prompt`)
|
||||||
toastr.info('Generating tasks for objective', 'Please wait...');
|
toastr.info('Generating tasks for objective', 'Please wait...');
|
||||||
const taskResponse = await generateQuietPrompt(prompt)
|
const taskResponse = await generateQuietPrompt(prompt)
|
||||||
|
|
||||||
// Clear all existing objective tasks when generating
|
// Clear all existing objective tasks when generating
|
||||||
currentObjective.children = []
|
currentObjective.children = []
|
||||||
const numberedListPattern = /^\d+\./
|
const numberedListPattern = /^\d+\./
|
||||||
|
@ -109,6 +111,19 @@ async function checkTaskCompleted() {
|
||||||
if (jQuery.isEmptyObject(currentTask)) {
|
if (jQuery.isEmptyObject(currentTask)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Wait for group to finish generating
|
||||||
|
if (selected_group) {
|
||||||
|
await waitUntilCondition(() => is_group_generating === false, 1000, 10);
|
||||||
|
}
|
||||||
|
// Another extension might be doing something with the chat, so wait for it to finish
|
||||||
|
await waitUntilCondition(() => is_send_press === false, 30000, 10);
|
||||||
|
} catch {
|
||||||
|
console.debug("Failed to wait for group to finish generating")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkCounter = $('#objective-check-frequency').val()
|
checkCounter = $('#objective-check-frequency').val()
|
||||||
toastr.info("Checking for task completion.")
|
toastr.info("Checking for task completion.")
|
||||||
|
|
||||||
|
@ -163,14 +178,14 @@ function setCurrentTask(taskId = null) {
|
||||||
const description = currentTask.description || null;
|
const description = currentTask.description || null;
|
||||||
if (description) {
|
if (description) {
|
||||||
const extensionPromptText = substituteParamsPrompts(objectivePrompts.currentTask);
|
const extensionPromptText = substituteParamsPrompts(objectivePrompts.currentTask);
|
||||||
|
|
||||||
// Remove highlights
|
// Remove highlights
|
||||||
$('.objective-task').css({'border-color':'','border-width':''})
|
$('.objective-task').css({'border-color':'','border-width':''})
|
||||||
// Highlight current task
|
// Highlight current task
|
||||||
let highlightTask = currentTask
|
let highlightTask = currentTask
|
||||||
while (highlightTask.parentId !== ""){
|
while (highlightTask.parentId !== ""){
|
||||||
if (highlightTask.descriptionSpan){
|
if (highlightTask.descriptionSpan){
|
||||||
highlightTask.descriptionSpan.css({'border-color':'yellow','border-width':'2px'});
|
highlightTask.descriptionSpan.css({'border-color':'yellow','border-width':'2px'});
|
||||||
}
|
}
|
||||||
const parent = getTaskById(highlightTask.parentId)
|
const parent = getTaskById(highlightTask.parentId)
|
||||||
highlightTask = parent
|
highlightTask = parent
|
||||||
|
@ -238,7 +253,7 @@ class ObjectiveTask {
|
||||||
))
|
))
|
||||||
saveState()
|
saveState()
|
||||||
}
|
}
|
||||||
|
|
||||||
getIndex(){
|
getIndex(){
|
||||||
if (this.parentId !== null) {
|
if (this.parentId !== null) {
|
||||||
const parent = getTaskById(this.parentId)
|
const parent = getTaskById(this.parentId)
|
||||||
|
@ -302,7 +317,7 @@ class ObjectiveTask {
|
||||||
this.deleteButton = $(`#objective-task-delete-${this.id}`);
|
this.deleteButton = $(`#objective-task-delete-${this.id}`);
|
||||||
this.taskHtml = $(`#objective-task-label-${this.id}`);
|
this.taskHtml = $(`#objective-task-label-${this.id}`);
|
||||||
this.branchButton = $(`#objective-task-add-branch-${this.id}`)
|
this.branchButton = $(`#objective-task-add-branch-${this.id}`)
|
||||||
|
|
||||||
// Handle sub-task forking style
|
// Handle sub-task forking style
|
||||||
if (this.children.length > 0){
|
if (this.children.length > 0){
|
||||||
this.branchButton.css({'color':'#33cc33'})
|
this.branchButton.css({'color':'#33cc33'})
|
||||||
|
@ -408,7 +423,7 @@ function onEditPromptClick() {
|
||||||
$('#objective-prompt-generate').val(objectivePrompts.createTask)
|
$('#objective-prompt-generate').val(objectivePrompts.createTask)
|
||||||
$('#objective-prompt-check').val(objectivePrompts.checkTaskCompleted)
|
$('#objective-prompt-check').val(objectivePrompts.checkTaskCompleted)
|
||||||
$('#objective-prompt-extension-prompt').val(objectivePrompts.currentTask)
|
$('#objective-prompt-extension-prompt').val(objectivePrompts.currentTask)
|
||||||
|
|
||||||
// Handle value updates
|
// Handle value updates
|
||||||
$('#objective-prompt-generate').on('input', () => {
|
$('#objective-prompt-generate').on('input', () => {
|
||||||
objectivePrompts.createTask = $('#objective-prompt-generate').val()
|
objectivePrompts.createTask = $('#objective-prompt-generate').val()
|
||||||
|
@ -419,7 +434,7 @@ function onEditPromptClick() {
|
||||||
$('#objective-prompt-extension-prompt').on('input', () => {
|
$('#objective-prompt-extension-prompt').on('input', () => {
|
||||||
objectivePrompts.currentTask = $('#objective-prompt-extension-prompt').val()
|
objectivePrompts.currentTask = $('#objective-prompt-extension-prompt').val()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle new
|
// Handle new
|
||||||
$('#objective-custom-prompt-new').on('click', () => {
|
$('#objective-custom-prompt-new').on('click', () => {
|
||||||
newCustomPrompt()
|
newCustomPrompt()
|
||||||
|
@ -440,7 +455,7 @@ function onEditPromptClick() {
|
||||||
}
|
}
|
||||||
async function newCustomPrompt() {
|
async function newCustomPrompt() {
|
||||||
const customPromptName = await callPopup('<h3>Custom Prompt name:</h3>', 'input');
|
const customPromptName = await callPopup('<h3>Custom Prompt name:</h3>', 'input');
|
||||||
|
|
||||||
if (customPromptName == "") {
|
if (customPromptName == "") {
|
||||||
toastr.warning("Please set custom prompt name to save.")
|
toastr.warning("Please set custom prompt name to save.")
|
||||||
return
|
return
|
||||||
|
@ -644,7 +659,7 @@ function loadSettings() {
|
||||||
// Reset Objectives and Tasks in memory
|
// Reset Objectives and Tasks in memory
|
||||||
taskTree = null;
|
taskTree = null;
|
||||||
currentObjective = null;
|
currentObjective = null;
|
||||||
|
|
||||||
// Init extension settings
|
// Init extension settings
|
||||||
if (Object.keys(extension_settings.objective).length === 0) {
|
if (Object.keys(extension_settings.objective).length === 0) {
|
||||||
Object.assign(extension_settings.objective, { 'customPrompts': {'default':defaultPrompts}})
|
Object.assign(extension_settings.objective, { 'customPrompts': {'default':defaultPrompts}})
|
||||||
|
|
Loading…
Reference in New Issue