Update app.py
Browse files
app.py
CHANGED
|
@@ -60,9 +60,8 @@ class GaiaSmolAgent:
|
|
| 60 |
timeout=120.0, # Add a timeout to prevent hanging
|
| 61 |
)
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
|
| 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
|
| 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(
|
| 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
|