From 0604760e153e340466ca29574ad3971ea5ab7e37 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 17 Sep 2024 11:00:46 +0200 Subject: [PATCH] Update lollms_client_js.js --- endpoints/libraries/lollms_client_js.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/endpoints/libraries/lollms_client_js.js b/endpoints/libraries/lollms_client_js.js index 0d497cd8..483fcd5b 100644 --- a/endpoints/libraries/lollms_client_js.js +++ b/endpoints/libraries/lollms_client_js.js @@ -974,7 +974,8 @@ async summarizeText( maxSummarySize = 512, callback = null, chunkSummaryPostProcessing = null, - summaryMode = "SEQUENTIAL" + summaryMode = "SEQUENTIAL", + reformat=false ) { console.log("Tokenizing:") console.log(text) @@ -982,6 +983,7 @@ async summarizeText( let tk = await this.tokenize(text); let prevLen = tk.length; let documentChunks = null; + console.log(`Text size: ${prevLen}`) while (tk.length > maxSummarySize && (documentChunks === null || documentChunks.length > 1)) { this.stepStart(`Compressing ${docName}...`); @@ -1004,6 +1006,18 @@ async summarizeText( this.stepEnd(`Compressing ${docName}...`); if (dtkLn <= 10) break; // it is not summarizing } + if(reformat){ + text = await this.lollms.generate( + [ + this.lollms.system_message(), + `${text}`, + this.lollms.system_message(), + summaryInstruction, + "Do not add any extra comments.", + this.lollms.system_message() + answerStart + ].join("\n"), + ); + } return text; }