tommaso1288 commited on
Commit
ad8f765
·
1 Parent(s): 6220346

added some info in system prompt and added file_reader_tool

Browse files
src/agent/base_agent.py CHANGED
@@ -43,5 +43,9 @@ class BaseAgent(ABC):
43
  planning_interval=self.planning_interval,
44
  max_steps=self.max_steps
45
  )
 
 
 
 
46
  print("Agent initialized.")
47
  return agent
 
43
  planning_interval=self.planning_interval,
44
  max_steps=self.max_steps
45
  )
46
+ agent.system_prompt += ("\nWhen answering, provide ONLY the precise answer requested. "
47
+ "Do not include explanations, steps, reasoning, or additional text. "
48
+ "Be direct and specific. GAIA benchmark requires exact matching answers.")
49
+ # print(agent.system_prompt)
50
  print("Agent initialized.")
51
  return agent
src/tools/file_reader_tool.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+
3
+ class FileReaderTool(Tool):
4
+ name = "file_reader"
5
+ description = "Read the content of a text or python code file."
6
+ inputs = {
7
+ "file_path": {
8
+ "type": "string",
9
+ "description": "The path of the file to read."
10
+ }
11
+ }
12
+ output_type = "string"
13
+
14
+ def forward(self, file_path: str) -> str:
15
+ try:
16
+ with open(file_path, "r", encoding="utf-8") as file:
17
+ content = file.read()
18
+ return f"File content:\n{content}"
19
+ except FileNotFoundError:
20
+ return f"Error file '{file_path}' not found."
21
+ except Exception as e:
22
+ return f"Error file_reader is not working properly, error: {e}, please skip this tool"
src/tools/tools_utils.py CHANGED
@@ -3,6 +3,7 @@ from smolagents import DuckDuckGoSearchTool, WikipediaSearchTool, PythonInterpre
3
  from tools.convert_audio_to_text_tool import ConvertAudioToTextTool
4
  from tools.convert_image_to_text_tool import ConvertImageToTextTool
5
  from tools.fetch_url_content_tool import FetchURLContentTool
 
6
 
7
 
8
  class ToolsUtils:
@@ -13,6 +14,7 @@ class ToolsUtils:
13
  FetchURLContentTool(),
14
  ConvertAudioToTextTool(),
15
  # ConvertImageToTextTool(),
 
16
  DuckDuckGoSearchTool(),
17
  WikipediaSearchTool(),
18
  PythonInterpreterTool()
 
3
  from tools.convert_audio_to_text_tool import ConvertAudioToTextTool
4
  from tools.convert_image_to_text_tool import ConvertImageToTextTool
5
  from tools.fetch_url_content_tool import FetchURLContentTool
6
+ from tools.file_reader_tool import FileReaderTool
7
 
8
 
9
  class ToolsUtils:
 
14
  FetchURLContentTool(),
15
  ConvertAudioToTextTool(),
16
  # ConvertImageToTextTool(),
17
+ FileReaderTool(),
18
  DuckDuckGoSearchTool(),
19
  WikipediaSearchTool(),
20
  PythonInterpreterTool()