Spaces:
Sleeping
Sleeping
more agents added
Browse files
app.py
CHANGED
|
@@ -112,25 +112,55 @@ class SlpMultiAgent:
|
|
| 112 |
max_tokens=1000 # Keep higher tokens for complex reasoning
|
| 113 |
)
|
| 114 |
|
| 115 |
-
# Create specialized agents
|
| 116 |
research_agent = CodeAgent(
|
| 117 |
-
tools=[
|
| 118 |
model=model,
|
| 119 |
-
additional_authorized_imports=["pandas", "time", "json", "requests", "
|
| 120 |
max_steps=4,
|
| 121 |
name="ResearchAgent",
|
| 122 |
verbosity_level=0,
|
| 123 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
)
|
| 125 |
|
| 126 |
-
|
| 127 |
tools=[],
|
| 128 |
model=model,
|
| 129 |
-
additional_authorized_imports=["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
max_steps=3,
|
| 131 |
-
name="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
verbosity_level=0,
|
| 133 |
-
description="
|
| 134 |
)
|
| 135 |
|
| 136 |
manager_agent = CodeAgent(
|
|
@@ -140,7 +170,7 @@ class SlpMultiAgent:
|
|
| 140 |
max_tokens=1200
|
| 141 |
),
|
| 142 |
tools=[KnowledgeBaseTool()],
|
| 143 |
-
managed_agents=[research_agent,
|
| 144 |
name="ManagerAgent",
|
| 145 |
description="A manager agent that coordinates research and analysis agents to solve complex questions.",
|
| 146 |
additional_authorized_imports=[
|
|
@@ -153,7 +183,7 @@ class SlpMultiAgent:
|
|
| 153 |
],
|
| 154 |
planning_interval=2,
|
| 155 |
verbosity_level=1,
|
| 156 |
-
max_steps=
|
| 157 |
final_answer_checks=[check_reasoning]
|
| 158 |
)
|
| 159 |
|
|
@@ -169,19 +199,22 @@ class SlpMultiAgent:
|
|
| 169 |
lambda: manager_agent.run(f"""
|
| 170 |
Question: {short_question}
|
| 171 |
|
| 172 |
-
You have
|
| 173 |
-
- ResearchAgent:
|
| 174 |
-
-
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
| 177 |
-
1. Analyze
|
| 178 |
-
2. Use knowledge_base()
|
| 179 |
-
3. Delegate to appropriate
|
| 180 |
-
4. Synthesize
|
| 181 |
|
| 182 |
-
CRITICAL: End with <code>final_answer("exact answer
|
| 183 |
|
| 184 |
-
|
| 185 |
""")
|
| 186 |
)
|
| 187 |
break # Success, exit retry loop
|
|
|
|
| 112 |
max_tokens=1000 # Keep higher tokens for complex reasoning
|
| 113 |
)
|
| 114 |
|
| 115 |
+
# Create specialized agents for complex problem-solving
|
| 116 |
research_agent = CodeAgent(
|
| 117 |
+
tools=[KnowledgeBaseTool()],
|
| 118 |
model=model,
|
| 119 |
+
additional_authorized_imports=["pandas", "time", "json", "requests", "re", "datetime"],
|
| 120 |
max_steps=4,
|
| 121 |
name="ResearchAgent",
|
| 122 |
verbosity_level=0,
|
| 123 |
+
description="Specializes in factual research, historical data, and knowledge retrieval."
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
math_agent = CodeAgent(
|
| 127 |
+
tools=[],
|
| 128 |
+
model=model,
|
| 129 |
+
additional_authorized_imports=["math", "statistics", "numpy", "pandas", "fractions", "decimal"],
|
| 130 |
+
max_steps=4,
|
| 131 |
+
name="MathAgent",
|
| 132 |
+
verbosity_level=0,
|
| 133 |
+
description="Specializes in mathematical calculations, statistics, and numerical analysis."
|
| 134 |
)
|
| 135 |
|
| 136 |
+
logic_agent = CodeAgent(
|
| 137 |
tools=[],
|
| 138 |
model=model,
|
| 139 |
+
additional_authorized_imports=["itertools", "collections", "re", "string"],
|
| 140 |
+
max_steps=4,
|
| 141 |
+
name="LogicAgent",
|
| 142 |
+
verbosity_level=0,
|
| 143 |
+
description="Specializes in logical reasoning, pattern recognition, and problem decomposition."
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
language_agent = CodeAgent(
|
| 147 |
+
tools=[],
|
| 148 |
+
model=model,
|
| 149 |
+
additional_authorized_imports=["re", "string", "collections"],
|
| 150 |
max_steps=3,
|
| 151 |
+
name="LanguageAgent",
|
| 152 |
+
verbosity_level=0,
|
| 153 |
+
description="Specializes in text analysis, word puzzles, linguistics, and language patterns."
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
data_agent = CodeAgent(
|
| 157 |
+
tools=[],
|
| 158 |
+
model=model,
|
| 159 |
+
additional_authorized_imports=["pandas", "json", "csv", "collections", "statistics"],
|
| 160 |
+
max_steps=4,
|
| 161 |
+
name="DataAgent",
|
| 162 |
verbosity_level=0,
|
| 163 |
+
description="Specializes in data processing, sorting, filtering, and structured analysis."
|
| 164 |
)
|
| 165 |
|
| 166 |
manager_agent = CodeAgent(
|
|
|
|
| 170 |
max_tokens=1200
|
| 171 |
),
|
| 172 |
tools=[KnowledgeBaseTool()],
|
| 173 |
+
managed_agents=[research_agent, math_agent, logic_agent, language_agent, data_agent],
|
| 174 |
name="ManagerAgent",
|
| 175 |
description="A manager agent that coordinates research and analysis agents to solve complex questions.",
|
| 176 |
additional_authorized_imports=[
|
|
|
|
| 183 |
],
|
| 184 |
planning_interval=2,
|
| 185 |
verbosity_level=1,
|
| 186 |
+
max_steps=10, # More steps for complex coordination
|
| 187 |
final_answer_checks=[check_reasoning]
|
| 188 |
)
|
| 189 |
|
|
|
|
| 199 |
lambda: manager_agent.run(f"""
|
| 200 |
Question: {short_question}
|
| 201 |
|
| 202 |
+
You have 5 specialized agents available:
|
| 203 |
+
- ResearchAgent: Facts, history, knowledge lookup
|
| 204 |
+
- MathAgent: Calculations, statistics, numerical problems
|
| 205 |
+
- LogicAgent: Logical reasoning, patterns, problem decomposition
|
| 206 |
+
- LanguageAgent: Text analysis, word puzzles, linguistics
|
| 207 |
+
- DataAgent: Data processing, sorting, structured analysis
|
| 208 |
|
| 209 |
+
Strategy:
|
| 210 |
+
1. Analyze question type and complexity
|
| 211 |
+
2. Use knowledge_base() for context
|
| 212 |
+
3. Delegate to most appropriate specialist agent(s)
|
| 213 |
+
4. Synthesize results into final answer
|
| 214 |
|
| 215 |
+
CRITICAL: End with <code>final_answer("exact answer")</code>
|
| 216 |
|
| 217 |
+
Final answer must be direct and specific - no explanations.
|
| 218 |
""")
|
| 219 |
)
|
| 220 |
break # Success, exit retry loop
|