surfansun commited on
Commit
df77f8e
1 Parent(s): 1f73f3d

Upload tool

Browse files
Files changed (4) hide show
  1. app.py +4 -0
  2. inspirational_quote_tool.py +20 -0
  3. requirements.txt +2 -0
  4. tool_config.json +5 -0
app.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from transformers import launch_gradio_demo
2
+ from inspirational_quote_tool import ZenQuoteFetcher
3
+
4
+ launch_gradio_demo(ZenQuoteFetcher)
inspirational_quote_tool.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # zenquote_fetcher.py
2
+ # import json
3
+ import requests
4
+ from transformers import Tool
5
+
6
+ class ZenQuoteFetcher(Tool):
7
+ name = "zen_quote_fetcher"
8
+ description = "This is a tool that fetches an inspirational quote from zenquotes.io. It takes no input, and returns a quote."
9
+
10
+ inputs = []
11
+ outputs = ["text"]
12
+
13
+ def __call__(self):
14
+ response = requests.get('https://zenquotes.io/api/random')
15
+ json_data = json.loads(response.text)
16
+ quote = json_data[0]['q'] + " - " + json_data[0]['a']
17
+ return quote
18
+
19
+
20
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ requests
tool_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "description": "This is a tool that fetches an inspirational quote from zenquotes.io. It takes no input, and returns a quote.",
3
+ "name": "zen_quote_fetcher",
4
+ "tool_class": "inspirational_quote_tool.ZenQuoteFetcher"
5
+ }