Add option to auto-adjust number of chroma messages to keep / query based on context size.

This commit is contained in:
Cohee
2023-06-18 16:29:23 +03:00
parent 58a6ccd4a5
commit 22a5def618
3 changed files with 82 additions and 9 deletions

View File

@@ -558,7 +558,7 @@ function getCurrentChatId() {
}
}
const CHARACTERS_PER_TOKEN_RATIO = 3.35;
export const CHARACTERS_PER_TOKEN_RATIO = 3.35;
const talkativeness_default = 0.5;
var is_advanced_char_open = false;
@@ -1945,8 +1945,11 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
coreChat.pop();
}
// Determine token limit
let this_max_context = getMaxContextSize();
if (extension_settings.chromadb.n_results !== 0) {
await runGenerationInterceptors(coreChat);
await runGenerationInterceptors(coreChat, this_max_context);
console.log(`Core/all messages: ${coreChat.length}/${chat.length}`);
}
@@ -1993,9 +1996,6 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
chat2[i] = formatMessageHistoryItem(coreChat[j], isInstruct);
}
// Determine token limit
let this_max_context = getMaxContextSize();
// Adjust token limit for Horde
let adjustedParams;
if (main_api == 'koboldhorde' && (horde_settings.auto_adjust_context_length || horde_settings.auto_adjust_response_length)) {