genai-rss-space / agent.py
8shanrahan's picture
Update agent.py
86c1607 verified
raw
history blame
544 Bytes
from transformers import pipeline
# Load once at startup
classifier = pipeline(
"zero-shot-classification",
model="valhalla/distilbart-mnli-12-3"
)
def analyze_article(text, title, link):
result = classifier(
text,
candidate_labels=["analytics", "data science", "business insight"],
multi_label=True
)
summary = result['labels'][0]
return {
"title": title,
"link": link,
"summary": summary,
"labels": result['labels'],
"scores": result['scores']
}