Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
@@ -1,21 +1,4 @@
|
|
1 |
from smolagents import Tool
|
2 |
-
import wikipediaapi
|
3 |
-
|
4 |
-
class WikipediaTool(Tool):
|
5 |
-
name = "wikipedia_lookup"
|
6 |
-
description = "Fetches English Wikipedia summary for a given topic."
|
7 |
-
|
8 |
-
inputs = {
|
9 |
-
"query": {"type": "string", "description": "The Wikipedia page title to retrieve."}
|
10 |
-
}
|
11 |
-
output_type = "string"
|
12 |
-
|
13 |
-
def forward(self, query: str) -> str:
|
14 |
-
wiki = wikipediaapi.Wikipedia('en')
|
15 |
-
page = wiki.page(query)
|
16 |
-
if not page.exists():
|
17 |
-
return f"Wikipedia page '{query}' does not exist."
|
18 |
-
return page.summary[:1000]
|
19 |
|
20 |
|
21 |
class TextTransformerTool(Tool):
|
|
|
1 |
from smolagents import Tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
|
4 |
class TextTransformerTool(Tool):
|