Update tools.py
Browse files
tools.py
CHANGED
|
@@ -180,7 +180,7 @@ class audio_or_mp3__interpreter(Tool):
|
|
| 180 |
|
| 181 |
class Wikipedia_reader(Tool):
|
| 182 |
name="wiki_tool"
|
| 183 |
-
description = "To be used whenever you need to read a Wikipedia page. Will return all the
|
| 184 |
inputs = {
|
| 185 |
"url": {
|
| 186 |
"type": "string",
|
|
@@ -191,8 +191,27 @@ class Wikipedia_reader(Tool):
|
|
| 191 |
|
| 192 |
def forward(self, url: str):
|
| 193 |
try:
|
| 194 |
-
page = requests.get(url)
|
| 195 |
except Exception as e:
|
| 196 |
print('Error downloading page: ',e)
|
| 197 |
soup = BeautifulSoup(page.text, 'html.parser')
|
| 198 |
-
return soup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
class Wikipedia_reader(Tool):
|
| 182 |
name="wiki_tool"
|
| 183 |
+
description = "To be used whenever you need to read a Wikipedia page. Will return all the html code of the Wikipedia page, to easily read it and find information. IF you need numeric information and can not easily have it with this function, use html_tool"
|
| 184 |
inputs = {
|
| 185 |
"url": {
|
| 186 |
"type": "string",
|
|
|
|
| 191 |
|
| 192 |
def forward(self, url: str):
|
| 193 |
try:
|
| 194 |
+
page = requests.get({url})
|
| 195 |
except Exception as e:
|
| 196 |
print('Error downloading page: ',e)
|
| 197 |
soup = BeautifulSoup(page.text, 'html.parser')
|
| 198 |
+
return soup
|
| 199 |
+
|
| 200 |
+
class HTML_find(Tool):
|
| 201 |
+
name="html_tool"
|
| 202 |
+
description = "To be used whenever you need to read a Wikipedia page for NUMERICAL INFORMATION. It will extract the wikitables, hence making it easy to read. It completes the wiki_tool"
|
| 203 |
+
output_type = "string"
|
| 204 |
+
inputs = {
|
| 205 |
+
"url": {
|
| 206 |
+
"type": "string",
|
| 207 |
+
"description": "The wikippedia url page"
|
| 208 |
+
},
|
| 209 |
+
#"subject" : {
|
| 210 |
+
# "type" : "string",
|
| 211 |
+
# "description": "If no subject is defined, the tool will return all the tables. If you know the numerical output (you must be sure about it) that you're searching, as a year, you can specify it with this input.
|
| 212 |
+
#}
|
| 213 |
+
}
|
| 214 |
+
def forward(self,url)#,subject="Inconnu"):
|
| 215 |
+
#if({subject}=="Inconnu"):
|
| 216 |
+
tables=pd.read_html(url)
|
| 217 |
+
return tables
|