sqfoo commited on
Commit
c851c82
·
verified ·
1 Parent(s): c60b26f

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +11 -4
agent.py CHANGED
@@ -185,7 +185,13 @@ def image_caption(dir: str) -> str:
185
 
186
  # 2. Coding
187
  from langchain_experimental.tools import PythonREPLTool
188
- python_tool = PythonREPLTool()
 
 
 
 
 
 
189
 
190
  @tool
191
  def multiply(a: float, b: float) -> float:
@@ -273,11 +279,12 @@ class BasicAgent:
273
  - csv_read: read the content of the attached csv file by passing the TASK-ID as input
274
  - mp3_listen: listen to the content of the attached mp3 file by passing the TASK-ID as input
275
  - image_caption: understand the visual content of the attached image by passing the TASK-ID as input
276
- - python_tool: run the python code
277
-
278
  If Task ID is included in the question, remember to call the relevant read tools [ie. read_file, excel_read, csv_read, mp3_listen, image_caption]
 
279
  """
280
- self.tools = [duckduck_websearch, serper_websearch, visit_webpage, wiki_search, text_splitter, youtube_transcript, read_file, excel_read, csv_read, mp3_listen, image_caption, python_tool]
281
  # self.model_with_tools = self.model.bind_tools(self.tools)
282
  # self.sys_msg = SystemMessage(content=self.sys_prompt)
283
 
 
185
 
186
  # 2. Coding
187
  from langchain_experimental.tools import PythonREPLTool
188
+ @tool
189
+ def run_python(code: str):
190
+ """ Run the given python code
191
+ Args:
192
+ code: the python code
193
+ """
194
+ return PythonREPLTool().run(code)
195
 
196
  @tool
197
  def multiply(a: float, b: float) -> float:
 
279
  - csv_read: read the content of the attached csv file by passing the TASK-ID as input
280
  - mp3_listen: listen to the content of the attached mp3 file by passing the TASK-ID as input
281
  - image_caption: understand the visual content of the attached image by passing the TASK-ID as input
282
+ - run_python: run the python code
283
+
284
  If Task ID is included in the question, remember to call the relevant read tools [ie. read_file, excel_read, csv_read, mp3_listen, image_caption]
285
+ Note: python_tool is called when the question mentions the term "Python" or any math calculation.
286
  """
287
+ self.tools = [duckduck_websearch, serper_websearch, visit_webpage, wiki_search, text_splitter, youtube_transcript, read_file, excel_read, csv_read, mp3_listen, image_caption, run_python]
288
  # self.model_with_tools = self.model.bind_tools(self.tools)
289
  # self.sys_msg = SystemMessage(content=self.sys_prompt)
290