File size: 456 Bytes
acd3ca5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import requests
from bs4 import BeautifulSoup

from transformers.tools.base import Tool


TEXT_DOWNLOAD_DESCRIPTION = (
    "This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text"
    " contained in the file."
)


class TextDownloadTool(Tool):

    inputs = ['text']
    outputs = ['text']

    def __call__(self, url):
        return BeautifulSoup(requests.get(url).text, features="html.parser").get_text()