Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -143,8 +143,7 @@ class SpeechToTextTool(Tool):
|
|
| 143 |
class ExcelReaderTool(Tool):
|
| 144 |
name = "excel_reader"
|
| 145 |
description = """
|
| 146 |
-
|
| 147 |
-
It can extract data, calculate statistics, and perform data analysis on spreadsheets.
|
| 148 |
"""
|
| 149 |
inputs = {
|
| 150 |
"excel_path": {
|
|
@@ -168,20 +167,7 @@ class ExcelReaderTool(Tool):
|
|
| 168 |
df = pd.read_excel(excel_path, sheet_name=sheet_name)
|
| 169 |
else:
|
| 170 |
df = pd.read_excel(excel_path)
|
| 171 |
-
|
| 172 |
-
"shape": df.shape,
|
| 173 |
-
"columns": list(df.columns),
|
| 174 |
-
"dtypes": df.dtypes.to_dict(),
|
| 175 |
-
"head": df.head(5).to_dict()
|
| 176 |
-
}
|
| 177 |
-
result = f"Excel file: {excel_path}\n"
|
| 178 |
-
result += f"Shape: {info['shape'][0]} rows × {info['shape'][1]} columns\n\n"
|
| 179 |
-
result += "Columns:\n"
|
| 180 |
-
for col in info['columns']:
|
| 181 |
-
result += f"- {col} ({info['dtypes'].get(col)})\n"
|
| 182 |
-
result += "\nPreview (first 5 rows):\n"
|
| 183 |
-
result += df.head(5).to_string()
|
| 184 |
-
return result
|
| 185 |
except Exception as e:
|
| 186 |
return f"Error reading Excel file: {str(e)}"
|
| 187 |
|
|
@@ -189,7 +175,8 @@ class PythonCodeReaderTool(Tool):
|
|
| 189 |
name = "read_python_code"
|
| 190 |
description = "Reads a Python (.py) file and returns its content as a string."
|
| 191 |
inputs = {
|
| 192 |
-
"file_path": {"type": "string", "description": "The path to the Python file to read"
|
|
|
|
| 193 |
}
|
| 194 |
output_type = "string"
|
| 195 |
|
|
|
|
| 143 |
class ExcelReaderTool(Tool):
|
| 144 |
name = "excel_reader"
|
| 145 |
description = """
|
| 146 |
+
Reads and returns a pandas DataFrame from an Excel file (.xlsx, .xls).
|
|
|
|
| 147 |
"""
|
| 148 |
inputs = {
|
| 149 |
"excel_path": {
|
|
|
|
| 167 |
df = pd.read_excel(excel_path, sheet_name=sheet_name)
|
| 168 |
else:
|
| 169 |
df = pd.read_excel(excel_path)
|
| 170 |
+
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
except Exception as e:
|
| 172 |
return f"Error reading Excel file: {str(e)}"
|
| 173 |
|
|
|
|
| 175 |
name = "read_python_code"
|
| 176 |
description = "Reads a Python (.py) file and returns its content as a string."
|
| 177 |
inputs = {
|
| 178 |
+
"file_path": {"type": "string", "description": "The path to the Python file to read"
|
| 179 |
+
}
|
| 180 |
}
|
| 181 |
output_type = "string"
|
| 182 |
|