CoralLeiCN commited on
Commit
cd5c77a
·
1 Parent(s): 04e6f8d

Add pandas import to BasicAgent and change ReadExcelFileBytes output type to object

Browse files
Files changed (2) hide show
  1. agent/agents.py +1 -0
  2. agent/tools.py +3 -2
agent/agents.py CHANGED
@@ -82,6 +82,7 @@ class BasicAgent:
82
  wiki_retriever,
83
  ],
84
  model=model,
 
85
  step_callbacks=STEP_CALLBACKS,
86
  max_steps=15,
87
  )
 
82
  wiki_retriever,
83
  ],
84
  model=model,
85
+ additional_authorized_imports=["pandas"],
86
  step_callbacks=STEP_CALLBACKS,
87
  max_steps=15,
88
  )
agent/tools.py CHANGED
@@ -229,7 +229,7 @@ class ReadExcelFileBytes(Tool):
229
  "description": "the bytes content of the Excel file",
230
  },
231
  }
232
- output_type = "string"
233
 
234
  def forward(self, excel_bytes: str):
235
  from io import BytesIO
@@ -237,4 +237,5 @@ class ReadExcelFileBytes(Tool):
237
  import pandas as pd
238
 
239
  df = pd.read_excel(BytesIO(excel_bytes))
240
- return df.to_string()
 
 
229
  "description": "the bytes content of the Excel file",
230
  },
231
  }
232
+ output_type = "object" # pandas DataFrame
233
 
234
  def forward(self, excel_bytes: str):
235
  from io import BytesIO
 
237
  import pandas as pd
238
 
239
  df = pd.read_excel(BytesIO(excel_bytes))
240
+ print(f"Read {len(df)} rows from the Excel file as pandas DataFrame.")
241
+ return df