Skip to content

Commit

Permalink
Summary limit
Browse files Browse the repository at this point in the history
  • Loading branch information
debymf committed Oct 22, 2023
1 parent d6fbeef commit ebe08c6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/ExampleSummarization.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@

% Looping process to gradually summarize the text chunk by chunk, reducing
% the chunk size with each iteration.
numCalls = 0;
while numel(chunks)>1
summarizedChunks = strings(size(chunks));
numCalls = numCalls + numel(chunks);
% Add a limit to the number of calls, to ensure you are not making
% more calls than what is expected. You can change this value to match
% what is needed for your application.
if numCalls > 20
error("Document is too long to be summarized.")
end

for i = 1:length(chunks)
summarizedChunks(i) = generate(summarizer, "Summarize this content:" + newline + chunks(i));
summarizedChunks(i) = generate(summarizer, "Summarize this content:" + newline + chunks(i));
end

% Merging the summarized chunks to serve as the base for the next iteration
Expand Down

0 comments on commit ebe08c6

Please sign in to comment.