wop commited on
Commit
b21ad16
·
verified ·
1 Parent(s): 455d643

Update summarize.js

Browse files
Files changed (1) hide show
  1. summarize.js +7 -1
summarize.js CHANGED
@@ -171,7 +171,13 @@ function setupSection(heading, contentEls) {
171
  ring.setDetail("");
172
  ring.setIndeterminate();
173
 
174
- const prompt = "Summarize this section directly:\n\n" + sectionText(contentEls);
 
 
 
 
 
 
175
 
176
  let textEl = null; // created on the first streamed chunk, once we drop the ring
177
  const summary = await enqueueGenerate(() =>
 
171
  ring.setDetail("");
172
  ring.setIndeterminate();
173
 
174
+ function limitWords(text, maxWords) {
175
+ return text.split(/\s+/).slice(0, maxWords).join(" ");
176
+ }
177
+
178
+ const input = limitWords(sectionText(contentEls), 130);
179
+
180
+ const prompt = "Summarize this section directly:\n\n" + input;
181
 
182
  let textEl = null; // created on the first streamed chunk, once we drop the ring
183
  const summary = await enqueueGenerate(() =>