mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Possible chroma auto-adjust fix
This commit is contained in:
@ -551,10 +551,10 @@ async function onSelectInjectFile(e) {
|
|||||||
function doAutoAdjust(chat, maxContext) {
|
function doAutoAdjust(chat, maxContext) {
|
||||||
console.debug('CHROMADB: Auto-adjusting sliders (messages: %o, maxContext: %o)', chat.length, maxContext);
|
console.debug('CHROMADB: Auto-adjusting sliders (messages: %o, maxContext: %o)', chat.length, maxContext);
|
||||||
// Get mean message length
|
// Get mean message length
|
||||||
const meanMessageLength = chat.reduce((acc, cur) => acc + cur.mes.length, 0) / chat.length;
|
const meanMessageLength = chat.reduce((acc, cur) => acc + (cur?.mes?.length ?? 0), 0) / chat.length;
|
||||||
|
|
||||||
if (Number.isNaN(meanMessageLength)) {
|
if (Number.isNaN(meanMessageLength) || meanMessageLength === 0) {
|
||||||
console.debug('CHROMADB: Mean message length is NaN, aborting auto-adjust');
|
console.debug('CHROMADB: Mean message length is zero or NaN, aborting auto-adjust');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user