Chunks are too many
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
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
|