iQuentin commited on
Commit
8d1ae36
·
verified ·
1 Parent(s): eb3e2e9

Some clean up and back to GAIA extra system prompt as the tested simple "write numbers in letters" works well.

Browse files
Files changed (1) hide show
  1. agent.py +4 -14
agent.py CHANGED
@@ -1,7 +1,6 @@
1
  import os
2
  from smolagents import (
3
  CodeAgent,
4
- PromptTemplates,
5
  DuckDuckGoSearchTool,
6
  VisitWebpageTool,
7
  PythonInterpreterTool,
@@ -23,24 +22,19 @@ class QAgent:
23
  api_key: Optional[str] = None,
24
  provider: Optional[str] = None, # for InferenceClientModel
25
  timeout: Optional[int] = None, # for InferenceClientModel
26
- # system_prompt: str = "",
27
  temperature: float = 0.2,
28
  verbose: bool = False # Verbose logging or not
29
  ):
30
  """
31
  QAgent description
32
  """
33
- # Enhance system prompt for GAIA test
34
- extra="If the answer is a number, write it out in words."
35
- # "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. 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."
36
- # custom_prompt = f"{extra}\n\n{CODE_SYSTEM_PROMPT}"
37
 
38
 
39
  print(f"Begin QAgent init with: ")
40
  self.verbose = verbose
41
- # self.system_prompt = system_prompt or ""
42
- # print(f"self.system_prompt = {self.system_prompt}, system_prompt = {system_prompt}")
43
-
44
 
45
 
46
  # if model_type == "HfApiModel":
@@ -116,17 +110,13 @@ class QAgent:
116
 
117
  # Setup imports
118
  self.imports = ["pandas", "numpy", "datetime", "json", "re", "math", "os", "requests", "csv", "urllib"]
119
- # custom_templates = PromptTemplates(
120
- # system_prompt=custom_prompt,
121
- # planning=PlanningPromptTemplate(template="Remember: reflect deeply."),
122
- # )
123
  # Create CodeAgent
124
  print(f"Begin creating CodeAgent")
125
  self.agent = CodeAgent(
126
  tools=self.tools,
127
  model=self.model,
128
  instructions=extra,
129
- # prompt_templates=custom_templates,
130
  # additional_authorized_imports=self.imports,
131
  # executor_type=executor_type,
132
  # executor_kwargs=executor_kwargs,
 
1
  import os
2
  from smolagents import (
3
  CodeAgent,
 
4
  DuckDuckGoSearchTool,
5
  VisitWebpageTool,
6
  PythonInterpreterTool,
 
22
  api_key: Optional[str] = None,
23
  provider: Optional[str] = None, # for InferenceClientModel
24
  timeout: Optional[int] = None, # for InferenceClientModel
 
25
  temperature: float = 0.2,
26
  verbose: bool = False # Verbose logging or not
27
  ):
28
  """
29
  QAgent description
30
  """
31
+ # Enhance system prompt for GAIA questions
32
+ extra="You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. 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."
33
+ # "If the answer is a number, write it out in words." --> tested, it works!
 
34
 
35
 
36
  print(f"Begin QAgent init with: ")
37
  self.verbose = verbose
 
 
 
38
 
39
 
40
  # if model_type == "HfApiModel":
 
110
 
111
  # Setup imports
112
  self.imports = ["pandas", "numpy", "datetime", "json", "re", "math", "os", "requests", "csv", "urllib"]
113
+
 
 
 
114
  # Create CodeAgent
115
  print(f"Begin creating CodeAgent")
116
  self.agent = CodeAgent(
117
  tools=self.tools,
118
  model=self.model,
119
  instructions=extra,
 
120
  # additional_authorized_imports=self.imports,
121
  # executor_type=executor_type,
122
  # executor_kwargs=executor_kwargs,