Adding assistant to Counter

This commit is contained in:
Raven Scott 2023-08-14 23:44:06 -04:00
parent 6efd069b5d
commit f91d66b2b3

View File

@ -439,7 +439,7 @@ async function generateResponse(conversation, message) {
let totalTokens = 0; let totalTokens = 0;
for (const message of messages) { for (const message of messages) {
if (message.role === 'user') { if (message.role === 'user' || message.role === 'assistant') {
const encodedTokens = llamaTokenizer.encode(message.content); const encodedTokens = llamaTokenizer.encode(message.content);
totalTokens += encodedTokens.length; totalTokens += encodedTokens.length;
} }
@ -453,7 +453,7 @@ async function generateResponse(conversation, message) {
let tokenLength = totalTokens let tokenLength = totalTokens
// Remove older conversations if necessary // Remove older conversations if necessary
const maxLength = 2048; const maxLength = 2000;
if (tokenLength > maxLength) { if (tokenLength > maxLength) {
const diff = tokenLength - maxLength; const diff = tokenLength - maxLength;
let removedTokens = 0; let removedTokens = 0;