Spaces:
Sleeping
Sleeping
Update app.py
Browse files6 unmodified lines789101112131 unmodified line151617181920212223242526272829303132333435363738394041426 unmodified linesimport requestsimport feedparserfrom tools.final_answer import FinalAnswerToolfrom datetime import datetime, timedeltafrom typing import Listfrom Gradio_UI import GradioUI1 unmodified line@tooldef get_business_news() -> str:"""Backup method: Fetches latest business news using feedparser."""rss_backup_sources = ["https://news.google.com/rss/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNREZxYUdjU0JtVnpMVFF4T1NnQVAB?hl=en&gl=US&ceid=US:en","http://feeds.bbci.co.uk/news/business/rss.xml"]for rss_url in rss_backup_sources:try:feed = feedparser.parse(rss_url)if feed.entries:first_entry = feed.entries[0]title = first_entry.titlesource = first_entry.get("source", {}).get("title", "Unknown Source")return f"Latest Business News: {title} (Source: {source})"except Exception as e:continue # Try the next source if failure occursreturn "Unable to fetch business news at the moment. Please try again later."6 unmodified lines7891011121 unmodified line141516171819202122232425262728293031323334353637383940416 unmodified linesimport requestsimport feedparserfrom tools.final_answer import FinalAnswerToolfrom typing import Listfrom Gradio_UI import GradioUI1 unmodified line@tooldef get_business_news_summary() -> str:"""Fetches and summarizes the latest business news in a concise format."""# Use a reliable RSS feed for business newsrss_url = "http://feeds.bbci.co.uk/news/business/rss.xml"try:# Parse the RSS feedfeed = feedparser.parse(rss_url)if not feed.entries:return "No business news available at the moment."# Extract the latest news headline and descriptionlatest_news = feed.entries[0]title = latest_news.titlesummary = latest_news.get("summary", "No summary available.")return f"🔹 *{title}*\n📌 {summary}"except Exception as e:return f"Error fetching business news: {str(e)}"
app.py+18-19