Update lollms_client_js.js

This commit is contained in:
Saifeddine ALOUI 2024-09-17 11:00:46 +02:00 committed by GitHub
parent 542e0273a1
commit 0604760e15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}