Adding assistant to Counter
This commit is contained in:
parent
6efd069b5d
commit
f91d66b2b3
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user