optionEdge commited on
Commit
33402b3
·
verified ·
1 Parent(s): 533550b

Update BasicAgent.py

Browse files
Files changed (1) hide show
  1. BasicAgent.py +20 -0
BasicAgent.py CHANGED
@@ -10,6 +10,25 @@ from smolagents import (
10
  GoogleSearchTool,
11
  )
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  class newAgent:
14
  """Adapts smolagents.CodeAgent to the HF course template API."""
15
  def __init__(self):
@@ -23,6 +42,7 @@ class newAgent:
23
  "Your answers should contain only what is asked for in the question, without any other content."
24
  "Be exact and concise in your answers to get a good score on the exam questions. Do not add explanation to the answers."
25
  "If you are ask for a list of items, reply with ONLY those items separated by commas, no other text."
 
26
  )
27
  #*
28
  model = HfApiModel(model_id=model_id, token=hf_token)
 
10
  GoogleSearchTool,
11
  )
12
 
13
+ #*
14
+ @tool
15
+ def read_excel(self, file_path, sheet_name=0):
16
+ """
17
+ Read an Excel file into a pandas DataFrame.
18
+
19
+ Args:
20
+ file_path (str): Path to the Excel file.
21
+ sheet_name (str or int, optional): Sheet name or index.
22
+
23
+ Returns:
24
+ pandas.DataFrame or None
25
+ """
26
+ try:
27
+ return pd.read_excel(file_path, sheet_name=sheet_name)
28
+ except Exception as e:
29
+ print(f"Error reading Excel file: {e}")
30
+ return None
31
+
32
  class newAgent:
33
  """Adapts smolagents.CodeAgent to the HF course template API."""
34
  def __init__(self):
 
42
  "Your answers should contain only what is asked for in the question, without any other content."
43
  "Be exact and concise in your answers to get a good score on the exam questions. Do not add explanation to the answers."
44
  "If you are ask for a list of items, reply with ONLY those items separated by commas, no other text."
45
+ "You have a tool to read Excel files. The Excel file tool is named read_excel"
46
  )
47
  #*
48
  model = HfApiModel(model_id=model_id, token=hf_token)