cpatino10 commited on
Commit
936f890
·
verified ·
1 Parent(s): 7c83b3d

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +11 -15
agent.py CHANGED
@@ -1,26 +1,23 @@
1
- from smolagents import CodeAgent, InferenceClientModel
2
- from tools import all_tools
3
-
4
- # define GAIA specific system prompt
5
- GAIA_SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question.
6
- Report your thoughts, and finish your answer with your final response.
7
- Your final answer should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
8
- 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.
9
- 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.
10
- 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.
11
-
12
- Return ONLY the final answer as the output of your last step."""
13
 
14
  # model
15
  model = InferenceClientModel(
16
  model_id="Qwen/Qwen2.5-Coder-1.5B-Instruct"
17
  )
 
 
 
18
 
19
  # Initialize agent
20
  agent = CodeAgent(
21
  model=model,
22
- tools=all_tools,
23
- additional_authorized_imports=["pandas", "numpy"],
 
 
 
24
  )
25
 
26
  # run function
@@ -28,6 +25,5 @@ def run_agent(question: str) -> str:
28
  """
29
  This function is used to run the agent. Function is called in app.py
30
  """
31
- full_query = f"{GAIA_SYSTEM_PROMPT}\n\nQuestion:{question}"
32
  result = agent.run(full_query)
33
  return str(result).strip()
 
1
+ import yaml
2
+ from smolagents import CodeAgent, InferenceClientModel, final_answer
3
+ from tools import search_tool, visit_webpage, handle_file
 
 
 
 
 
 
 
 
 
4
 
5
  # model
6
  model = InferenceClientModel(
7
  model_id="Qwen/Qwen2.5-Coder-1.5B-Instruct"
8
  )
9
+ # load the prompt template from yaml file
10
+ with open("prompts.yaml", 'r') as stream:
11
+ prompt_templates = yaml.safe_load(stream)
12
 
13
  # Initialize agent
14
  agent = CodeAgent(
15
  model=model,
16
+ tools=[search_tool, visit_webpage, handle_file],
17
+ max_steps-12,
18
+ verbosity_level=1,
19
+ additional_authorized_imports=["pandas", "numpy", "re", "math"],
20
+ prompt_templates=prompt_templates
21
  )
22
 
23
  # run function
 
25
  """
26
  This function is used to run the agent. Function is called in app.py
27
  """
 
28
  result = agent.run(full_query)
29
  return str(result).strip()