File size: 1,357 Bytes
42b5a1a
 
 
 
ed84586
42b5a1a
 
ed84586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c578f9
ed84586
 
 
 
42b5a1a
 
adcb8d8
42b5a1a
 
 
 
1529e20
42b5a1a
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()