Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
@@ -2,9 +2,6 @@ from smolagents import Tool
|
|
2 |
import requests
|
3 |
|
4 |
def fetch_wikipedia_article(query: str) -> str:
|
5 |
-
"""
|
6 |
-
Fetch the plain text of a Wikipedia article using the Wikipedia API.
|
7 |
-
"""
|
8 |
url = "https://en.wikipedia.org/w/api.php"
|
9 |
params = {
|
10 |
"action": "query",
|
@@ -20,9 +17,6 @@ def fetch_wikipedia_article(query: str) -> str:
|
|
20 |
return page.get("extract", "No content found for this query.")
|
21 |
|
22 |
def search_wikipedia(query: str) -> str:
|
23 |
-
"""
|
24 |
-
Search for a Wikipedia article title using the Wikipedia API.
|
25 |
-
"""
|
26 |
url = "https://en.wikipedia.org/w/api.php"
|
27 |
params = {
|
28 |
"action": "query",
|
@@ -41,6 +35,7 @@ class WikipediaTool(Tool):
|
|
41 |
def __init__(self):
|
42 |
self.name = "WikipediaTool"
|
43 |
self.description = "Fetches plain text from a Wikipedia article. Input should be the article title."
|
|
|
44 |
super().__init__(name=self.name, description=self.description)
|
45 |
|
46 |
def __call__(self, query: str) -> str:
|
@@ -50,6 +45,7 @@ class WikipediaSearchTool(Tool):
|
|
50 |
def __init__(self):
|
51 |
self.name = "WikipediaSearchTool"
|
52 |
self.description = "Searches Wikipedia for article titles related to a query. Input should be a question or topic."
|
|
|
53 |
super().__init__(name=self.name, description=self.description)
|
54 |
|
55 |
def __call__(self, query: str) -> str:
|
|
|
2 |
import requests
|
3 |
|
4 |
def fetch_wikipedia_article(query: str) -> str:
|
|
|
|
|
|
|
5 |
url = "https://en.wikipedia.org/w/api.php"
|
6 |
params = {
|
7 |
"action": "query",
|
|
|
17 |
return page.get("extract", "No content found for this query.")
|
18 |
|
19 |
def search_wikipedia(query: str) -> str:
|
|
|
|
|
|
|
20 |
url = "https://en.wikipedia.org/w/api.php"
|
21 |
params = {
|
22 |
"action": "query",
|
|
|
35 |
def __init__(self):
|
36 |
self.name = "WikipediaTool"
|
37 |
self.description = "Fetches plain text from a Wikipedia article. Input should be the article title."
|
38 |
+
self.inputs = ["query"] # <- Add inputs attribute here
|
39 |
super().__init__(name=self.name, description=self.description)
|
40 |
|
41 |
def __call__(self, query: str) -> str:
|
|
|
45 |
def __init__(self):
|
46 |
self.name = "WikipediaSearchTool"
|
47 |
self.description = "Searches Wikipedia for article titles related to a query. Input should be a question or topic."
|
48 |
+
self.inputs = ["query"] # <- Add inputs attribute here
|
49 |
super().__init__(name=self.name, description=self.description)
|
50 |
|
51 |
def __call__(self, query: str) -> str:
|