KaranShishodia commented on issue #387:
URL: https://github.com/apache/flink-agents/issues/387#issuecomment-3673812060

   public class BatchedSummarizationOperator {
   
       private final int batchSize;
       private final LLMClient llmClient;
   
       public BatchedSummarizationOperator(int batchSize, LLMClient llmClient) {
           this.batchSize = batchSize;
           this.llmClient = llmClient;
       }
   
       public String summarize(List<String> memoryItems) {
           List<String> batchSummaries = new ArrayList<>();
   
           for (int i = 0; i < memoryItems.size(); i += batchSize) {
               List<String> batch = memoryItems.subList(i, Math.min(i + 
batchSize, memoryItems.size()));
               String summary = llmClient.summarize(batch);
               batchSummaries.add(summary);
           }
   
           // Hierarchical summarization
           return llmClient.summarize(batchSummaries);
       }
   }
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to