MickyWin22 commited on
Commit
35d7582
·
verified ·
1 Parent(s): c75fc46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -60,9 +60,8 @@ class GaiaSmolAgent:
60
  timeout=120.0, # Add a timeout to prevent hanging
61
  )
62
 
63
- # A more sophisticated system prompt to guide the agent's reasoning.
64
- # This improves its ability to handle complex GAIA questions.
65
- system_prompt = """
66
  You are an expert-level research assistant AI. Your sole purpose is to answer the user's question by breaking it down into logical steps and using the provided tools.
67
 
68
  **Available Tools:**
@@ -82,11 +81,10 @@ class GaiaSmolAgent:
82
  - Do not ask for clarification. Directly proceed to solve the problem.
83
  """
84
 
85
- # Initialize a single, powerful agent instead of a planner/executor pair.
86
  self.agent = CodeAgent(
87
  model=model,
88
  tools=[file_reader, DuckDuckGoSearchTool()],
89
- system_prompt=system_prompt,
90
  add_base_tools=True, # Provides the python interpreter and the final_answer function
91
  )
92
  print("Optimized GaiaSmolAgent initialized successfully.")
@@ -98,8 +96,10 @@ class GaiaSmolAgent:
98
  """
99
  print(f"Optimized Agent received question: {question[:100]}...")
100
  try:
 
 
101
  # The agent now internally handles the reasoning, code generation, and execution in one step.
102
- final_answer = self.agent.run(question)
103
  except Exception as e:
104
  print(f"FATAL AGENT ERROR: An exception occurred during agent execution: {e}")
105
  print(traceback.format_exc()) # Print full traceback for easier debugging
 
60
  timeout=120.0, # Add a timeout to prevent hanging
61
  )
62
 
63
+ # Store the sophisticated system prompt as an instance variable.
64
+ self.system_prompt = """
 
65
  You are an expert-level research assistant AI. Your sole purpose is to answer the user's question by breaking it down into logical steps and using the provided tools.
66
 
67
  **Available Tools:**
 
81
  - Do not ask for clarification. Directly proceed to solve the problem.
82
  """
83
 
84
+ # Initialize the agent without the 'system_prompt' argument to prevent the TypeError.
85
  self.agent = CodeAgent(
86
  model=model,
87
  tools=[file_reader, DuckDuckGoSearchTool()],
 
88
  add_base_tools=True, # Provides the python interpreter and the final_answer function
89
  )
90
  print("Optimized GaiaSmolAgent initialized successfully.")
 
96
  """
97
  print(f"Optimized Agent received question: {question[:100]}...")
98
  try:
99
+ # Combine the system prompt with the actual question to give the agent full context.
100
+ full_prompt = f"{self.system_prompt}\n\nUser Question: \"{question}\""
101
  # The agent now internally handles the reasoning, code generation, and execution in one step.
102
+ final_answer = self.agent.run(full_prompt)
103
  except Exception as e:
104
  print(f"FATAL AGENT ERROR: An exception occurred during agent execution: {e}")
105
  print(traceback.format_exc()) # Print full traceback for easier debugging