Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from rss_reader import fetch_articles | |
| from agent import analyze_article | |
| from renderer import render_html | |
| from logger import debug_log, log_exception | |
| def process_rss(rss_input): | |
| try: | |
| debug_log("Function triggered") | |
| rss_urls = [url.strip() for url in rss_input.strip().splitlines() if url.strip()] | |
| debug_log("Parsed RSS URLs", rss_urls) | |
| raw_articles = fetch_articles(rss_urls) | |
| debug_log("Fetched articles count", len(raw_articles)) | |
| analyzed = [] | |
| for a in raw_articles: | |
| debug_log("Analyzing article", a["title"]) | |
| analyzed.append(analyze_article(a["text"], a["title"], a["link"])) | |
| html = render_html(analyzed) | |
| debug_log("HTML rendered, length:", len(html)) | |
| return html | |
| except Exception: | |
| return log_exception("process_rss") | |
| default_rss = """https://rss.nytimes.com/services/xml/rss/nyt/Technology.xml | |
| https://feeds.arstechnica.com/arstechnica/technology-lab""" | |
| iface = gr.Interface( | |
| fn=process_rss, | |
| inputs=gr.Textbox(label="Enter RSS URLs (one per line)", value=default_rss, lines=4), | |
| outputs=gr.HTML(label="📊 GenAI RSS Digest"), | |
| title="GenAI RSS Summarizer", | |
| description="Summarizes articles and detects what’s useful to analytics teams" | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |