Delete tools.py
Browse files
tools.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
# tools.py – Wikipedia + arXiv helpers
|
| 2 |
-
from smolagents import Tool
|
| 3 |
-
import wikipedia, arxiv
|
| 4 |
-
|
| 5 |
-
MAX_CHARS = 20_000 # evita prompt enormi
|
| 6 |
-
|
| 7 |
-
class WikipediaTool(Tool):
|
| 8 |
-
name = "wiki"
|
| 9 |
-
description = "Return full content (truncated) of the most relevant Wikipedia page."
|
| 10 |
-
|
| 11 |
-
def __call__(self, query: str) -> str:
|
| 12 |
-
try:
|
| 13 |
-
page = wikipedia.page(query, auto_suggest=True, redirect=True)
|
| 14 |
-
return page.content[:MAX_CHARS]
|
| 15 |
-
except (wikipedia.PageError, wikipedia.DisambiguationError):
|
| 16 |
-
return ""
|
| 17 |
-
|
| 18 |
-
class ArxivTool(Tool):
|
| 19 |
-
name = "arxiv"
|
| 20 |
-
description = "Return title + abstract of the most recent arXiv paper that matches the query."
|
| 21 |
-
|
| 22 |
-
def __call__(self, query: str) -> str:
|
| 23 |
-
search = arxiv.Search(query=query, max_results=1,
|
| 24 |
-
sort_by=arxiv.SortCriterion.SubmittedDate)
|
| 25 |
-
paper = next(search.results(), None)
|
| 26 |
-
return f"{paper.title}\n{paper.summary}" if paper else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|