From 4629dac81cb639f9f080278dc125b9d87d450c8d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 15 Apr 2024 22:52:56 +0100 Subject: [PATCH] fix: Fix slice call in the content truncation logic which was resulting in excessive usage of context tokens. Fixes #94 --- apps/workers/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/workers/utils.ts b/apps/workers/utils.ts index 8e69dcd2..2372684e 100644 --- a/apps/workers/utils.ts +++ b/apps/workers/utils.ts @@ -40,7 +40,7 @@ export async function readPDFText(buffer: Buffer): Promise<{ export function truncateContent(content: string, length = 1500) { let words = content.split(" "); if (words.length > length) { - words = words.slice(length); + words = words.slice(0, length); content = words.join(" "); } return content;