mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Lock up configuration during prompt manager render
This commit is contained in:
@ -181,7 +181,7 @@ function PromptManagerModule() {
|
|||||||
jailbreak: '',
|
jailbreak: '',
|
||||||
enhanceDefinitions: ''
|
enhanceDefinitions: ''
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// Chatcompletion configuration object
|
// Chatcompletion configuration object
|
||||||
this.serviceSettings = null;
|
this.serviceSettings = null;
|
||||||
@ -588,12 +588,20 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
|
|||||||
* @param afterTryGenerate - Whether a dry run should be attempted before rendering
|
* @param afterTryGenerate - Whether a dry run should be attempted before rendering
|
||||||
*/
|
*/
|
||||||
PromptManagerModule.prototype.render = function (afterTryGenerate = true) {
|
PromptManagerModule.prototype.render = function (afterTryGenerate = true) {
|
||||||
if (main_api !== 'openai') return;
|
if (main_api !== 'openai' ||
|
||||||
|
null === this.activeCharacter) return;
|
||||||
|
|
||||||
if (null === this.activeCharacter) return;
|
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
waitUntilCondition(() => !is_send_press && !is_group_generating, 1024 * 1024, 100).then(() => {
|
const stopPropagation = (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
const configurationContainer = document.getElementById('ai_response_configuration');
|
||||||
|
try {
|
||||||
|
// Lock configuration during render
|
||||||
|
configurationContainer.addEventListener('click', stopPropagation, true);
|
||||||
|
|
||||||
if (true === afterTryGenerate) {
|
if (true === afterTryGenerate) {
|
||||||
// Executed during dry-run for determining context composition
|
// Executed during dry-run for determining context composition
|
||||||
this.profileStart('filling context');
|
this.profileStart('filling context');
|
||||||
@ -613,9 +621,14 @@ PromptManagerModule.prototype.render = function (afterTryGenerate = true) {
|
|||||||
this.makeDraggable();
|
this.makeDraggable();
|
||||||
this.profileEnd('render');
|
this.profileEnd('render');
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
} catch (error) {
|
||||||
console.log('Timeout while waiting for send press to be false');
|
this.log('----- Unexpected error while rendering prompt manager -----');
|
||||||
});
|
this.log(error);
|
||||||
|
this.log(error.stack);
|
||||||
|
this.log('-----------------------------------------------------------');
|
||||||
|
} finally {
|
||||||
|
configurationContainer.removeEventListener('click', stopPropagation, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1400,7 +1400,7 @@ class Message {
|
|||||||
this.content = content;
|
this.content = content;
|
||||||
|
|
||||||
if (this.content) {
|
if (this.content) {
|
||||||
this.tokens = tokenHandler.count({ role: this.role, content: this.content })
|
this.tokens = tokenHandler.count({ role: this.role, content: this.content });
|
||||||
} else {
|
} else {
|
||||||
this.tokens = 0;
|
this.tokens = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user