Shreyas94 commited on
Commit
2225c6c
1 Parent(s): 3148927

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -60,11 +60,15 @@ async def summarize_news(query, num_results=3):
60
  chunk_size = 500 # Adjust chunk size as needed
61
  chunks = [sentences[i:i + chunk_size] for i in range(0, len(sentences), chunk_size)]
62
 
63
- # Summarize chunks concurrently
64
- summaries = await asyncio.gather(*[summarizer(' '.join(chunk), max_length=120, min_length=30, do_sample=False) for chunk in chunks])
 
 
 
 
65
 
66
  # Combine all summaries
67
- final_summary = ' '.join([summary[0]['summary_text'] for summary in summaries])
68
 
69
  logging.debug(f"Final summarized text: {final_summary}")
70
  return final_summary
 
60
  chunk_size = 500 # Adjust chunk size as needed
61
  chunks = [sentences[i:i + chunk_size] for i in range(0, len(sentences), chunk_size)]
62
 
63
+ # Summarize each chunk separately
64
+ summaries = []
65
+ for chunk in chunks:
66
+ chunk_text = ' '.join(chunk)
67
+ summary = summarizer(chunk_text, max_length=120, min_length=30, do_sample=False)
68
+ summaries.append(summary[0]['summary_text'])
69
 
70
  # Combine all summaries
71
+ final_summary = ' '.join(summaries)
72
 
73
  logging.debug(f"Final summarized text: {final_summary}")
74
  return final_summary