Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -20,11 +20,13 @@ def analyze_article(text, title, link):
|
|
20 |
# Summarize article text
|
21 |
summary = summarizer(text[:1024], max_length=150, min_length=40, do_sample=False)[0]['summary_text']
|
22 |
print(f"[DEBUG] Summarizer Model inference time: {time.time() - t0:.2f}s")
|
|
|
|
|
23 |
return {
|
24 |
"title": title,
|
25 |
"link": link,
|
26 |
"summary": summary,
|
27 |
-
"
|
28 |
-
"
|
29 |
}
|
30 |
|
|
|
20 |
# Summarize article text
|
21 |
summary = summarizer(text[:1024], max_length=150, min_length=40, do_sample=False)[0]['summary_text']
|
22 |
print(f"[DEBUG] Summarizer Model inference time: {time.time() - t0:.2f}s")
|
23 |
+
is_useful = any(label in ["analytics", "data science"] for label in result['labels'][:2])
|
24 |
+
|
25 |
return {
|
26 |
"title": title,
|
27 |
"link": link,
|
28 |
"summary": summary,
|
29 |
+
"top_label": result['labels'][0],
|
30 |
+
"relevance": "Useful" if is_useful else "Not useful"
|
31 |
}
|
32 |
|