Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -120,18 +120,29 @@ def summarize_news(articles: List[Dict]) -> str:
|
|
120 |
if not articles or not isinstance(articles, list):
|
121 |
return "No articles to summarize"
|
122 |
|
123 |
-
# Prepare content for summarization
|
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"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)}")
|
|
|
120 |
if not articles or not isinstance(articles, list):
|
121 |
return "No articles to summarize"
|
122 |
|
|
|
123 |
content_to_summarize = ""
|
124 |
for article in articles:
|
125 |
content = article.get('full_content', article['snippet'])
|
126 |
content_to_summarize += f"Title: {article['title']}\nSource: {article['source']}\nDate: {article['date']}\nLink: {article['link']}\nContent: {content}\n\n"
|
127 |
|
128 |
+
summary_prompt = f"""Create a clear news summary from these articles. Focus on the main facts and developments.
|
129 |
+
|
130 |
+
For each article, extract the most newsworthy information and remove any redundant content, formatting artifacts, or navigation elements.
|
131 |
+
|
132 |
+
Present the information in this format:
|
133 |
+
1. Start with a brief overview of the main story
|
134 |
+
2. Include specific details and numbers when relevant
|
135 |
+
3. Add source links in markdown format: [Source Name](URL)
|
136 |
|
137 |
{content_to_summarize}"""
|
138 |
|
139 |
try:
|
140 |
summary = deepseek_model.complete(summary_prompt).strip()
|
141 |
+
# Ensure proper markdown link formatting
|
142 |
+
for article in articles:
|
143 |
+
source = article['source']
|
144 |
+
link = article['link']
|
145 |
+
summary = summary.replace(f"[{source}]", f"[{source}]({link})")
|
146 |
return summary
|
147 |
except Exception as e:
|
148 |
print(f"DeepSeek summarization failed: {str(e)}")
|