broadfield-dev commited on
Commit
35d88fe
·
verified ·
1 Parent(s): a29bdfe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -14,14 +14,14 @@ def index():
14
  logger.info("Starting to fetch RSS feeds")
15
  articles = fetch_rss_feeds()
16
  logger.info(f"Fetched {len(articles)} articles")
17
- process_and_store_articles(articles, summarize=False) # Skip summarization initially
18
  logger.info("Articles processed and stored")
19
  stored_docs = vector_db.similarity_search("news", k=len(articles))
20
  enriched_articles = [
21
  {
22
  "title": doc.metadata["title"],
23
  "link": doc.metadata["link"],
24
- "summary": doc.page_content or doc.metadata["original_description"], # Use description if no summary
25
  "category": doc.metadata["category"],
26
  "sentiment": doc.metadata["sentiment"],
27
  "published": doc.metadata["published"],
@@ -40,7 +40,7 @@ def index():
40
  {
41
  "title": doc.metadata["title"],
42
  "link": doc.metadata["link"],
43
- "summary": doc.page_content or doc.metadata["original_description"],
44
  "category": doc.metadata["category"],
45
  "sentiment": doc.metadata["sentiment"],
46
  "published": doc.metadata["published"],
@@ -48,7 +48,7 @@ def index():
48
  }
49
  for doc in results
50
  ]
51
- logger.info(f"Search returned {len(enriched_articles)} results")
52
 
53
  categorized_articles = {}
54
  for article in enriched_articles:
@@ -69,4 +69,4 @@ def summarize():
69
  return jsonify({"summary": summary})
70
 
71
  if __name__ == "__main__":
72
- app.run(host="0.0.0.0", port=7860)
 
14
  logger.info("Starting to fetch RSS feeds")
15
  articles = fetch_rss_feeds()
16
  logger.info(f"Fetched {len(articles)} articles")
17
+ process_and_store_articles(articles) # Load without summarization
18
  logger.info("Articles processed and stored")
19
  stored_docs = vector_db.similarity_search("news", k=len(articles))
20
  enriched_articles = [
21
  {
22
  "title": doc.metadata["title"],
23
  "link": doc.metadata["link"],
24
+ "summary": doc.metadata["original_description"], # Use original description initially
25
  "category": doc.metadata["category"],
26
  "sentiment": doc.metadata["sentiment"],
27
  "published": doc.metadata["published"],
 
40
  {
41
  "title": doc.metadata["title"],
42
  "link": doc.metadata["link"],
43
+ "summary": summarize_article(doc.metadata["original_description"]), # Summarize on search
44
  "category": doc.metadata["category"],
45
  "sentiment": doc.metadata["sentiment"],
46
  "published": doc.metadata["published"],
 
48
  }
49
  for doc in results
50
  ]
51
+ logger.info(f"Search returned {len(enriched_articles)} results with summaries")
52
 
53
  categorized_articles = {}
54
  for article in enriched_articles:
 
69
  return jsonify({"summary": summary})
70
 
71
  if __name__ == "__main__":
72
+ app.run(debug=True, host="0.0.0.0", port=7860)