huytofu92 commited on
Commit
ad0b84b
·
1 Parent(s): 3897863

Add excel load tool

Browse files
Files changed (2) hide show
  1. mini_agents.py +2 -2
  2. tools.py +11 -0
mini_agents.py CHANGED
@@ -1,5 +1,5 @@
1
  from smolagents import CodeAgent, InferenceClientModel
2
- from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv
3
  from tools import tavily_search_tool, visit_webpage_tool
4
  from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
5
  from vlm_tools import image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path
@@ -83,7 +83,7 @@ pandas_model = InferenceClientModel(
83
 
84
  pandas_agent = CodeAgent(
85
  model=pandas_model,
86
- tools=[load_dataframe_from_csv, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
87
  max_steps=4,
88
  # prompt_templates=PROMPT_TEMPLATE["pandas_agent"],
89
  additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy'],
 
1
  from smolagents import CodeAgent, InferenceClientModel
2
+ from tools import sort_list, operate_two_numbers, convert_number, load_dataframe_from_csv, load_dataframe_from_excel
3
  from tools import tavily_search_tool, visit_webpage_tool
4
  from tools import to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby
5
  from vlm_tools import image_processing, object_detection_tool, ocr_scan_tool, extract_images_from_video, get_image_from_file_path, get_video_from_file_path
 
83
 
84
  pandas_agent = CodeAgent(
85
  model=pandas_model,
86
+ tools=[load_dataframe_from_csv, load_dataframe_from_excel, to_dataframe, to_json, get_dataframe_data, get_dataframe_column, get_dataframe_row, get_dataframe_groupby],
87
  max_steps=4,
88
  # prompt_templates=PROMPT_TEMPLATE["pandas_agent"],
89
  additional_authorized_imports=["math", "pandas", "json", "numpy", "io", "os", "logging", "yaml", "pyplot", "matplotlib", 'hmmlearn', 'pickle', 'sklearn', 'scipy'],
tools.py CHANGED
@@ -145,6 +145,17 @@ def load_dataframe_from_csv(file_path: str)->pd.DataFrame:
145
  """
146
  return pd.read_csv(file_path)
147
 
 
 
 
 
 
 
 
 
 
 
 
148
  @tool
149
  def to_dataframe(data: List[dict], columns: List[str])->pd.DataFrame:
150
  """
 
145
  """
146
  return pd.read_csv(file_path)
147
 
148
+ @tool
149
+ def load_dataframe_from_excel(file_path: str)->pd.DataFrame:
150
+ """
151
+ Load a pandas DataFrame from an Excel file
152
+ Args:
153
+ file_path: The path to the Excel file to load.
154
+ Returns:
155
+ The pandas DataFrame
156
+ """
157
+ return pd.read_excel(file_path)
158
+
159
  @tool
160
  def to_dataframe(data: List[dict], columns: List[str])->pd.DataFrame:
161
  """