Spaces:
Sleeping
Sleeping
removed wiki bc timeout
Browse files
app.py
CHANGED
|
@@ -97,9 +97,9 @@ class SlpMultiAgent:
|
|
| 97 |
|
| 98 |
# Create only essential agents with reduced complexity
|
| 99 |
research_agent = CodeAgent(
|
| 100 |
-
tools=[KnowledgeBaseTool(),
|
| 101 |
model=model,
|
| 102 |
-
additional_authorized_imports=["re", "datetime"
|
| 103 |
max_steps=2, # Reduced steps for cost
|
| 104 |
name="ResearchAgent",
|
| 105 |
verbosity_level=0,
|
|
@@ -122,14 +122,14 @@ class SlpMultiAgent:
|
|
| 122 |
temperature=0.0,
|
| 123 |
max_tokens=500
|
| 124 |
),
|
| 125 |
-
tools=[KnowledgeBaseTool(),
|
| 126 |
managed_agents=[research_agent, solver_agent], # Only 2 agents
|
| 127 |
name="ManagerAgent",
|
| 128 |
description="Efficient manager for quick problem solving.",
|
| 129 |
-
additional_authorized_imports=["re", "math"
|
| 130 |
planning_interval=1, # Faster planning
|
| 131 |
verbosity_level=0, # Reduce verbosity
|
| 132 |
-
max_steps=
|
| 133 |
final_answer_checks=[check_reasoning]
|
| 134 |
)
|
| 135 |
|
|
@@ -145,16 +145,16 @@ class SlpMultiAgent:
|
|
| 145 |
lambda: manager_agent.run(f"""
|
| 146 |
Question: {short_question}
|
| 147 |
|
| 148 |
-
|
| 149 |
-
-
|
| 150 |
-
- wikipedia_search(query): Search Wikipedia
|
| 151 |
-
- ResearchAgent: For factual research
|
| 152 |
- SolverAgent: For calculations and logic
|
| 153 |
|
| 154 |
-
|
| 155 |
-
<code>
|
|
|
|
|
|
|
| 156 |
|
| 157 |
-
|
| 158 |
""")
|
| 159 |
)
|
| 160 |
break # Success, exit retry loop
|
|
@@ -180,7 +180,7 @@ class SlpMultiAgent:
|
|
| 180 |
if result and isinstance(result, str):
|
| 181 |
# Look for final_answer pattern
|
| 182 |
import re
|
| 183 |
-
final_answer_match = re.search(r'final_answer\(["\']([^"\']*)["\'\]
|
| 184 |
if final_answer_match:
|
| 185 |
clean_answer = final_answer_match.group(1)
|
| 186 |
return clean_answer
|
|
|
|
| 97 |
|
| 98 |
# Create only essential agents with reduced complexity
|
| 99 |
research_agent = CodeAgent(
|
| 100 |
+
tools=[KnowledgeBaseTool()], # Remove Wikipedia to avoid timeouts
|
| 101 |
model=model,
|
| 102 |
+
additional_authorized_imports=["re", "datetime"],
|
| 103 |
max_steps=2, # Reduced steps for cost
|
| 104 |
name="ResearchAgent",
|
| 105 |
verbosity_level=0,
|
|
|
|
| 122 |
temperature=0.0,
|
| 123 |
max_tokens=500
|
| 124 |
),
|
| 125 |
+
tools=[KnowledgeBaseTool()], # Remove Wikipedia to avoid timeouts
|
| 126 |
managed_agents=[research_agent, solver_agent], # Only 2 agents
|
| 127 |
name="ManagerAgent",
|
| 128 |
description="Efficient manager for quick problem solving.",
|
| 129 |
+
additional_authorized_imports=["re", "math"],
|
| 130 |
planning_interval=1, # Faster planning
|
| 131 |
verbosity_level=0, # Reduce verbosity
|
| 132 |
+
max_steps=3, # Further reduced steps to avoid timeouts
|
| 133 |
final_answer_checks=[check_reasoning]
|
| 134 |
)
|
| 135 |
|
|
|
|
| 145 |
lambda: manager_agent.run(f"""
|
| 146 |
Question: {short_question}
|
| 147 |
|
| 148 |
+
You have knowledge_base() tool and two agents:
|
| 149 |
+
- ResearchAgent: For factual questions
|
|
|
|
|
|
|
| 150 |
- SolverAgent: For calculations and logic
|
| 151 |
|
| 152 |
+
IMPORTANT: Always end with exactly this format:
|
| 153 |
+
<code>
|
| 154 |
+
final_answer("your direct answer")
|
| 155 |
+
</code>
|
| 156 |
|
| 157 |
+
Be concise and direct.
|
| 158 |
""")
|
| 159 |
)
|
| 160 |
break # Success, exit retry loop
|
|
|
|
| 180 |
if result and isinstance(result, str):
|
| 181 |
# Look for final_answer pattern
|
| 182 |
import re
|
| 183 |
+
final_answer_match = re.search(r'final_answer\(["\']([^"\']*)["\'\)]', result) # Fixed regex
|
| 184 |
if final_answer_match:
|
| 185 |
clean_answer = final_answer_match.group(1)
|
| 186 |
return clean_answer
|