Spaces:
Sleeping
Sleeping
Update BasicAgent.py
Browse files- BasicAgent.py +9 -3
BasicAgent.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
import smolagents, numpy, math, xlrd, os
|
|
|
|
|
|
|
| 2 |
from smolagents import (
|
| 3 |
tool,
|
| 4 |
CodeAgent,
|
|
@@ -13,11 +15,15 @@ from smolagents import (
|
|
| 13 |
|
| 14 |
#*
|
| 15 |
@tool
|
| 16 |
-
def read_excel(file_path: str, sheet_name=0):
|
| 17 |
"""
|
| 18 |
Read an Excel file into a pandas DataFrame.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"""
|
| 20 |
-
import pandas as pd
|
| 21 |
try:
|
| 22 |
return pd.read_excel(file_path, sheet_name=sheet_name)
|
| 23 |
except Exception as e:
|
|
|
|
| 1 |
+
import smolagents, numpy, math, xlrd, os
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from typing import Union
|
| 4 |
from smolagents import (
|
| 5 |
tool,
|
| 6 |
CodeAgent,
|
|
|
|
| 15 |
|
| 16 |
#*
|
| 17 |
@tool
|
| 18 |
+
def read_excel(file_path: str, sheet_name: Union[str, int] = 0) -> Union[str, pd.DataFrame]:
|
| 19 |
"""
|
| 20 |
Read an Excel file into a pandas DataFrame.
|
| 21 |
+
Args:
|
| 22 |
+
file_path (str): Path to the Excel file.
|
| 23 |
+
sheet_name (Union[str, int]): Sheet name or index. Defaults to 0.
|
| 24 |
+
Returns:
|
| 25 |
+
DataFrame or error message string.
|
| 26 |
"""
|
|
|
|
| 27 |
try:
|
| 28 |
return pd.read_excel(file_path, sheet_name=sheet_name)
|
| 29 |
except Exception as e:
|