fdaudens HF Staff commited on
Commit
c286b8b
·
verified ·
1 Parent(s): 17a17b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -33
app.py CHANGED
@@ -124,44 +124,14 @@ def summarize_news(articles: List[Dict]) -> str:
124
  content_to_summarize = ""
125
  for article in articles:
126
  content = article.get('full_content', article['snippet'])
127
- content_to_summarize += f"Title: {article['title']}\nSource: {article['source']}\nDate: {article['date']}\nContent: {content}\n\n"
128
 
129
- # Use DeepSeek model to generate a concise summary
130
- summary_prompt = f"""Analyze these news articles and create a comprehensive yet concise summary:
131
 
132
- {content_to_summarize}
133
-
134
- Requirements:
135
- 1. Start with a 2-3 sentence overview of the main developments
136
- 2. Focus on concrete facts and important details
137
- 3. Maintain journalistic neutrality
138
- 4. Include relevant names, locations, and key figures
139
- 5. Organize related information together
140
-
141
- Format the output exactly as follows:
142
- 📰 Summary:
143
- [2-3 sentence overview of the main developments]
144
-
145
- 🔍 Key Developments:
146
- • [First major development with specific details]
147
- • [Second major development with specific details]
148
- • [Additional developments if relevant]
149
-
150
- 📑 Articles:
151
- 1. [Article Title] ([Source], [Date])
152
- [One-line highlight of the article's main point]
153
- [Read more: link]
154
- """
155
 
156
  try:
157
  summary = deepseek_model.complete(summary_prompt).strip()
158
- # Ensure links are properly formatted
159
- for article in articles:
160
- if article['link'] in summary:
161
- summary = summary.replace(
162
- f"[Read more: {article['link']}]",
163
- f"[Read more]({article['link']})"
164
- )
165
  return summary
166
  except Exception as e:
167
  print(f"DeepSeek summarization failed: {str(e)}")
 
124
  content_to_summarize = ""
125
  for article in articles:
126
  content = article.get('full_content', article['snippet'])
127
+ content_to_summarize += f"Title: {article['title']}\nSource: {article['source']}\nDate: {article['date']}\nLink: {article['link']}\nContent: {content}\n\n"
128
 
129
+ summary_prompt = f"""Summarize these news articles in a clear and concise way. Include the most important developments and add links to the original articles.
 
130
 
131
+ {content_to_summarize}"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  try:
134
  summary = deepseek_model.complete(summary_prompt).strip()
 
 
 
 
 
 
 
135
  return summary
136
  except Exception as e:
137
  print(f"DeepSeek summarization failed: {str(e)}")