File size: 551 Bytes
acd3ca5
 
 
81ac149
acd3ca5
 
 
49d7856
acd3ca5
 
 
 
8ac8a9e
c311332
 
630097d
acd3ca5
c311332
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.agents import Tool


TEXT_DOWNLOAD_DESCRIPTION = (
    "This is a tool that downloads a file from a `url` and returns the text contained in the tile."
)


class TextDownloadTool(Tool):
    name = "text_downloader"
    inputs= {"url": {"type": "string", "description": "url to download file from"}}
    output_type= "string"
    description = TEXT_DOWNLOAD_DESCRIPTION

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