Spaces:
Sleeping
Sleeping
Update BasicAgent.py
Browse files- BasicAgent.py +15 -15
BasicAgent.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import smolagents, numpy, math, xlrd, os
|
| 2 |
from smolagents import (
|
| 3 |
Tool,
|
| 4 |
CodeAgent,
|
|
@@ -13,22 +13,22 @@ from smolagents import (
|
|
| 13 |
|
| 14 |
#*
|
| 15 |
@tool
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
#
|
| 33 |
class newAgent:
|
| 34 |
"""Adapts smolagents.CodeAgent to the HF course template API."""
|
|
|
|
| 1 |
+
import smolagents, numpy, math, xlrd, os, pandas
|
| 2 |
from smolagents import (
|
| 3 |
Tool,
|
| 4 |
CodeAgent,
|
|
|
|
| 13 |
|
| 14 |
#*
|
| 15 |
@tool
|
| 16 |
+
def read_excel(self, file_path, sheet_name=0):
|
| 17 |
+
"""
|
| 18 |
+
Read an Excel file into a pandas DataFrame.
|
| 19 |
|
| 20 |
+
Args:
|
| 21 |
+
file_path (str): Path to the Excel file.
|
| 22 |
+
sheet_name (str or int, optional): Sheet name or index.
|
| 23 |
|
| 24 |
+
Returns:
|
| 25 |
+
pandas.DataFrame or None
|
| 26 |
+
"""
|
| 27 |
+
try:
|
| 28 |
+
return pd.read_excel(file_path, sheet_name=sheet_name)
|
| 29 |
+
except Exception as e:
|
| 30 |
+
print(f"Error reading Excel file: {e}")
|
| 31 |
+
return None
|
| 32 |
#
|
| 33 |
class newAgent:
|
| 34 |
"""Adapts smolagents.CodeAgent to the HF course template API."""
|