lysandre HF staff commited on
Commit
acd3ca5
0 Parent(s):

Initial commit

Browse files
Files changed (6) hide show
  1. README.md +12 -0
  2. __init__.py +0 -0
  3. app.py +4 -0
  4. requirements.txt +4 -0
  5. text_download.py +20 -0
  6. tool_config.json +3 -0
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Text Download
3
+ emoji: ⚡
4
+ colorFrom: blue
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 3.27.0
8
+ app_file: app.py
9
+ pinned: false
10
+ tags:
11
+ - tool
12
+ ---
__init__.py ADDED
File without changes
app.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from transformers.tools.base import launch_gradio_demo
2
+ from text_download import TextDownloadTool
3
+
4
+ launch_gradio_demo(TextDownloadTool)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ accelerate @ git+https://github.com/huggingface/accelerate
2
+ transformers @ git+https://github.com/huggingface/transformers@test_composition
3
+ bs4
4
+ gradio
text_download.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+
4
+ from transformers.tools.base import Tool
5
+
6
+
7
+ TEXT_DOWNLOAD_DESCRIPTION = (
8
+ "This is a tool that downloads a file from a `url`. It takes the `url` as input, and returns the text"
9
+ " contained in the file."
10
+ )
11
+
12
+
13
+ class TextDownloadTool(Tool):
14
+
15
+ inputs = ['text']
16
+ outputs = ['text']
17
+
18
+ def __call__(self, url):
19
+ return BeautifulSoup(requests.get(url).text, features="html.parser").get_text()
20
+
tool_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "custom_tools": {"text-download": "text_download.TextDownloadTool"}
3
+ }