APRG commited on
Commit
e33a27b
·
verified ·
1 Parent(s): 729ca73

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +50 -0
tools.py CHANGED
@@ -2,7 +2,57 @@ from smolagents import DuckDuckGoSearchTool
2
  from smolagents import Tool
3
  import random
4
  from huggingface_hub import list_models
 
 
 
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  # Initialize the DuckDuckGo search tool
8
  class InternetSearchTool(Tool):
 
2
  from smolagents import Tool
3
  import random
4
  from huggingface_hub import list_models
5
+ import requests
6
+ from bs4 import BeautifulSoup
7
+ import openpyxl
8
 
9
+ class WikipediaTool(Tool):
10
+ name = "wikipedia_api"
11
+ description = "Returns the contents of a wikipedia article through a direct API call."
12
+ inputs = {
13
+ "title": {
14
+ "type": "string",
15
+ "description": "The title of the wikipedia article to retrieve."
16
+ }
17
+ }
18
+ output_type = "string"
19
+
20
+ def forward(self, question: str):
21
+ search_tool = DuckDuckGoSearchTool()
22
+ result = search_tool(question)
23
+ return result
24
+
25
+ class ExcelTool(Tool):
26
+ name = "read_excel"
27
+ description = "Returns the contents of an Excel file as a Pandas dataframe."
28
+ inputs = {
29
+ "filename": {
30
+ "type": "string",
31
+ "description": "The name of the Excel file to read."
32
+ }
33
+ }
34
+ output_type = "string"
35
+
36
+ def forward(self, question: str):
37
+ search_tool = DuckDuckGoSearchTool()
38
+ result = search_tool(question)
39
+ return result
40
+
41
+ class WebscraperTool(Tool):
42
+ name = "webscraper"
43
+ description = "Returns the page's html content from the input url."
44
+ inputs = {
45
+ "url": {
46
+ "type": "string",
47
+ "description": "The link of the web page to scrape."
48
+ }
49
+ }
50
+ output_type = "string"
51
+
52
+ def forward(self, question: str):
53
+ search_tool = DuckDuckGoSearchTool()
54
+ result = search_tool(question)
55
+ return result
56
 
57
  # Initialize the DuckDuckGo search tool
58
  class InternetSearchTool(Tool):