Mbonea commited on
Commit
a819bf2
1 Parent(s): bcdd593

Chunks are too many

Browse files
Files changed (1) hide show
  1. App/Chat/utils/Summarize.py +5 -1
App/Chat/utils/Summarize.py CHANGED
@@ -139,7 +139,11 @@ async def Summarizer(essay):
139
 
140
  tasks = [PalmTextModel(map_prompt.format(text=doc.page_content)) for doc in docs]
141
  # Gather and execute the tasks concurrently
142
- responses = await asyncio.gather(*tasks)
 
 
 
 
143
  main = " ".join(responses)
144
  ans = await PalmTextModel(combine_prompt.format(text=main))
145
  return ans
 
139
 
140
  tasks = [PalmTextModel(map_prompt.format(text=doc.page_content)) for doc in docs]
141
  # Gather and execute the tasks concurrently
142
+ chunked_tasks = [tasks[i:i+20] for i in range(0, len(tasks), 20)]
143
+ responses = []
144
+ for chunk in chunked_tasks:
145
+ chunk_responses = await asyncio.gather(*chunk)
146
+ responses.extend(chunk_responses)
147
  main = " ".join(responses)
148
  ans = await PalmTextModel(combine_prompt.format(text=main))
149
  return ans