Artsem Radzevich commited on
Commit
58477b5
·
1 Parent(s): 9073c71

Updated tools.

Browse files
Files changed (2) hide show
  1. tools/excel_analysis_tool.py +8 -5
  2. tools/wiki_tool.py +14 -10
tools/excel_analysis_tool.py CHANGED
@@ -4,11 +4,14 @@ from huggingface_hub import hf_hub_download
4
 
5
  class ExcelAnalysisTool(Tool):
6
  def __init__(self):
7
- self.name = "ExcelAnalysisTool"
8
- self.description = (
9
- "Loads an Excel file from the GAIA dataset on Hugging Face and calculates "
10
- "the total sales for items labeled as 'food', excluding drinks. "
11
- "Provide input as a string with the filename, e.g., 'sales_data.xlsx'."
 
 
 
12
  )
13
  self.repo_id = "gaia-benchmark/GAIA"
14
 
 
4
 
5
  class ExcelAnalysisTool(Tool):
6
  def __init__(self):
7
+ super().__init__(
8
+ name="ExcelAnalysisTool",
9
+ description=(
10
+ "Loads an Excel file from the GAIA dataset on Hugging Face and calculates "
11
+ "the total sales for items labeled as 'food', excluding drinks. "
12
+ "Provide input as a string with the filename, e.g., 'sales_data.xlsx'."
13
+ ),
14
+ inputs=["filename"]
15
  )
16
  self.repo_id = "gaia-benchmark/GAIA"
17
 
tools/wiki_tool.py CHANGED
@@ -3,12 +3,15 @@ import wikipedia
3
 
4
  class WikiTool(Tool):
5
  def __init__(self):
6
- self.name = "WikiTool"
7
- self.description = (
8
- "Performs Wikipedia lookups. Supports actions: 'summary' and 'is_historical_country'.\n"
9
- "Usage:\n"
10
- "- {'action': 'summary', 'topic': 'France'}\n"
11
- "- {'action': 'is_historical_country', 'country_name': 'Yugoslavia'}"
 
 
 
12
  )
13
 
14
  def fetch_summary(self, topic: str) -> str:
@@ -22,7 +25,7 @@ class WikiTool(Tool):
22
  except Exception as e:
23
  return f"An unexpected error occurred: {str(e)}"
24
 
25
- def is_historical_country(self, country_name: str) -> bool:
26
  try:
27
  summary = wikipedia.summary(country_name, sentences=2).lower()
28
  keywords = [
@@ -30,11 +33,12 @@ class WikiTool(Tool):
30
  "was a country", "defunct", "dissolved", "existed until",
31
  "disestablished", "merged into"
32
  ]
33
- return any(keyword in summary for keyword in keywords)
 
34
  except Exception:
35
- return False
36
 
37
- def __call__(self, args: dict):
38
  action = args.get("action")
39
 
40
  if action == "summary":
 
3
 
4
  class WikiTool(Tool):
5
  def __init__(self):
6
+ super().__init__(
7
+ name="WikiTool",
8
+ description=(
9
+ "Performs Wikipedia lookups. Supports actions: 'summary' and 'is_historical_country'.\n"
10
+ "Usage:\n"
11
+ "- {'action': 'summary', 'topic': 'France'}\n"
12
+ "- {'action': 'is_historical_country', 'country_name': 'Yugoslavia'}"
13
+ ),
14
+ inputs=["action", "topic", "country_name"]
15
  )
16
 
17
  def fetch_summary(self, topic: str) -> str:
 
25
  except Exception as e:
26
  return f"An unexpected error occurred: {str(e)}"
27
 
28
+ def is_historical_country(self, country_name: str) -> str:
29
  try:
30
  summary = wikipedia.summary(country_name, sentences=2).lower()
31
  keywords = [
 
33
  "was a country", "defunct", "dissolved", "existed until",
34
  "disestablished", "merged into"
35
  ]
36
+ result = any(keyword in summary for keyword in keywords)
37
+ return "Yes" if result else "No"
38
  except Exception:
39
+ return "Unknown (error during lookup)"
40
 
41
+ def __call__(self, args: dict) -> str:
42
  action = args.get("action")
43
 
44
  if action == "summary":