From f12aeb0aa2f07905eb143885f6b671f81403c284 Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Sun, 17 Mar 2024 00:53:26 +0200 Subject: [PATCH] Update lib/ai.js Co-authored-by: KobeN <7845001+kobenguyent@users.noreply.github.com> --- lib/ai.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ai.js b/lib/ai.js index 4955b7cf4..6ae5f16b9 100644 --- a/lib/ai.js +++ b/lib/ai.js @@ -187,7 +187,7 @@ class AiAssistant { // this approach was tested via https://platform.openai.com/tokenizer // we need it to display current usage tokens usage so users could analyze effectiveness of AI - const inputString = messages.map(m => m.content).join(' '); + const inputString = messages.map(m => m.content).join(' ').trim(); const numWords = (inputString.match(/[^\s\-:=]+/g) || []).length; // 2.5 token is constant for average HTML input