SergeyO7 commited on
Commit
d6e2c4c
·
verified ·
1 Parent(s): 45db113

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +8 -5
agent.py CHANGED
@@ -34,7 +34,8 @@ def search_arxiv(query: str) -> str:
34
  ])
35
  return {"arxiv_results": formatted_search_docs}
36
 
37
- from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception
 
38
  import requests
39
 
40
 
@@ -111,7 +112,8 @@ class SpeechToTextTool(Tool):
111
  class ExcelReaderTool(Tool):
112
  name = "excel_reader"
113
  description = """
114
- Reads and returns a pandas DataFrame from an Excel file (.xlsx, .xls).
 
115
  """
116
  inputs = {
117
  "excel_path": {
@@ -124,9 +126,9 @@ class ExcelReaderTool(Tool):
124
  "nullable": True
125
  }
126
  }
127
- output_type = "pandas.DataFrame"
128
 
129
- def forward(self, excel_path: str, sheet_name: str = None) -> pd.DataFrame:
130
  try:
131
  if not os.path.exists(excel_path):
132
  return f"Error: Excel file not found at {excel_path}"
@@ -134,10 +136,11 @@ class ExcelReaderTool(Tool):
134
  df = pd.read_excel(excel_path, sheet_name=sheet_name)
135
  else:
136
  df = pd.read_excel(excel_path)
137
- return df
138
  except Exception as e:
139
  return f"Error reading Excel file: {str(e)}"
140
 
 
141
  class PythonCodeReaderTool(Tool):
142
  name = "read_python_code"
143
  description = "Reads a Python (.py) file and returns its content as a string."
 
34
  ])
35
  return {"arxiv_results": formatted_search_docs}
36
 
37
+ from
38
+ tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception
39
  import requests
40
 
41
 
 
112
  class ExcelReaderTool(Tool):
113
  name = "excel_reader"
114
  description = """
115
+ Reads an Excel file (.xlsx, .xls) and returns its content as a CSV string.
116
+ Use pandas.read_csv(StringIO(data)) to parse the output into a DataFrame.
117
  """
118
  inputs = {
119
  "excel_path": {
 
126
  "nullable": True
127
  }
128
  }
129
+ output_type = "string"
130
 
131
+ def forward(self, excel_path: str, sheet_name: str = None) -> str:
132
  try:
133
  if not os.path.exists(excel_path):
134
  return f"Error: Excel file not found at {excel_path}"
 
136
  df = pd.read_excel(excel_path, sheet_name=sheet_name)
137
  else:
138
  df = pd.read_excel(excel_path)
139
+ return df.to_csv(index=False)
140
  except Exception as e:
141
  return f"Error reading Excel file: {str(e)}"
142
 
143
+
144
  class PythonCodeReaderTool(Tool):
145
  name = "read_python_code"
146
  description = "Reads a Python (.py) file and returns its content as a string."