Tesvia commited on
Commit
db0abac
·
verified ·
1 Parent(s): ef9f1d9

Upload 4 files

Browse files
Files changed (2) hide show
  1. added_prompt.txt +5 -0
  2. agent.py +12 -8
added_prompt.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ You are a helpful assistant tasked with answering questions using a set of tools.
2
+ Now, I will ask you a question. Report your thoughts, and finish your answer with the following template:
3
+ FINAL ANSWER: [YOUR FINAL ANSWER].
4
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
5
+ Your answer should only start with "FINAL ANSWER: ", then follows with the answer.
agent.py CHANGED
@@ -18,7 +18,7 @@ from dotenv import load_dotenv
18
  from smolagents import (
19
  CodeAgent,
20
  DuckDuckGoSearchTool,
21
- Tool,
22
  )
23
 
24
  # Custom Tools from tools.py
@@ -32,11 +32,11 @@ from tools import (
32
 
33
 
34
  # ---------------------------------------------------------------------------
35
- # Load the system prompt from system_prompt.txt (located in the same directory)
36
  # ---------------------------------------------------------------------------
37
- SYSTEM_PROMPT_PATH = os.path.join(os.path.dirname(__file__), "system_prompt.txt")
38
- with open(SYSTEM_PROMPT_PATH, "r", encoding="utf-8") as f:
39
- SYSTEM_PROMPT = f.read().strip()
40
 
41
 
42
  # ---------------------------------------------------------------------------
@@ -87,12 +87,16 @@ DEFAULT_TOOLS = [
87
  ]
88
 
89
  class GAIAAgent(CodeAgent):
90
- def __init__(self, tools=None, *, system_prompt: str = SYSTEM_PROMPT):
 
 
 
91
  super().__init__(
92
  tools=tools or DEFAULT_TOOLS,
93
- model=_select_model(),
94
- system_prompt=system_prompt
95
  )
 
 
96
 
97
  # Convenience so the object itself can be *called* directly
98
  def __call__(self, question: str, **kwargs: Any) -> str:
 
18
  from smolagents import (
19
  CodeAgent,
20
  DuckDuckGoSearchTool,
21
+ Tool
22
  )
23
 
24
  # Custom Tools from tools.py
 
32
 
33
 
34
  # ---------------------------------------------------------------------------
35
+ # Load the added system prompt from system_prompt.txt (located in the same directory)
36
  # ---------------------------------------------------------------------------
37
+ ADDED_PROMPT_PATH = os.path.join(os.path.dirname(__file__), "added_prompt.txt")
38
+ with open(ADDED_PROMPT_PATH, "r", encoding="utf-8") as f:
39
+ ADDED_PROMPT = f.read().strip()
40
 
41
 
42
  # ---------------------------------------------------------------------------
 
87
  ]
88
 
89
  class GAIAAgent(CodeAgent):
90
+ def __init__(
91
+ self,
92
+ tools=None
93
+ ):
94
  super().__init__(
95
  tools=tools or DEFAULT_TOOLS,
96
+ model=_select_model()
 
97
  )
98
+ # Append the additional prompt to the existing system prompt
99
+ self.prompt_templates["system_prompt"] += f"\n\n{ADDED_PROMPT}"
100
 
101
  # Convenience so the object itself can be *called* directly
102
  def __call__(self, question: str, **kwargs: Any) -> str: