swarms 7.7.8__py3-none-any.whl → 7.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarms/__init__.py +0 -1
- swarms/agents/cort_agent.py +206 -0
- swarms/agents/react_agent.py +173 -0
- swarms/agents/self_agent_builder.py +40 -0
- swarms/communication/base_communication.py +290 -0
- swarms/communication/duckdb_wrap.py +369 -72
- swarms/communication/pulsar_struct.py +691 -0
- swarms/communication/redis_wrap.py +1362 -0
- swarms/communication/sqlite_wrap.py +547 -44
- swarms/prompts/agent_self_builder_prompt.py +103 -0
- swarms/prompts/safety_prompt.py +50 -0
- swarms/schemas/__init__.py +6 -1
- swarms/schemas/agent_class_schema.py +91 -0
- swarms/schemas/agent_mcp_errors.py +18 -0
- swarms/schemas/agent_tool_schema.py +13 -0
- swarms/schemas/llm_agent_schema.py +92 -0
- swarms/schemas/mcp_schemas.py +43 -0
- swarms/structs/__init__.py +4 -0
- swarms/structs/agent.py +315 -267
- swarms/structs/aop.py +3 -1
- swarms/structs/batch_agent_execution.py +64 -0
- swarms/structs/conversation.py +261 -57
- swarms/structs/council_judge.py +542 -0
- swarms/structs/deep_research_swarm.py +19 -22
- swarms/structs/long_agent.py +424 -0
- swarms/structs/ma_utils.py +11 -8
- swarms/structs/malt.py +30 -28
- swarms/structs/multi_model_gpu_manager.py +1 -1
- swarms/structs/output_types.py +1 -1
- swarms/structs/swarm_router.py +70 -15
- swarms/tools/__init__.py +12 -0
- swarms/tools/base_tool.py +2840 -264
- swarms/tools/create_agent_tool.py +104 -0
- swarms/tools/mcp_client_call.py +504 -0
- swarms/tools/py_func_to_openai_func_str.py +45 -7
- swarms/tools/pydantic_to_json.py +10 -27
- swarms/utils/audio_processing.py +343 -0
- swarms/utils/history_output_formatter.py +5 -5
- swarms/utils/index.py +226 -0
- swarms/utils/litellm_wrapper.py +65 -67
- swarms/utils/try_except_wrapper.py +2 -2
- swarms/utils/xml_utils.py +42 -0
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/METADATA +5 -4
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/RECORD +47 -30
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/WHEEL +1 -1
- swarms/client/__init__.py +0 -15
- swarms/client/main.py +0 -407
- swarms/tools/mcp_client.py +0 -246
- swarms/tools/mcp_integration.py +0 -340
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/LICENSE +0 -0
- {swarms-7.7.8.dist-info → swarms-7.8.0.dist-info}/entry_points.txt +0 -0
swarms/structs/swarm_router.py
CHANGED
@@ -24,6 +24,7 @@ from swarms.structs.output_types import OutputType
|
|
24
24
|
from swarms.utils.loguru_logger import initialize_logger
|
25
25
|
from swarms.structs.malt import MALT
|
26
26
|
from swarms.structs.deep_research_swarm import DeepResearchSwarm
|
27
|
+
from swarms.structs.council_judge import CouncilAsAJudge
|
27
28
|
|
28
29
|
logger = initialize_logger(log_folder="swarm_router")
|
29
30
|
|
@@ -41,6 +42,7 @@ SwarmType = Literal[
|
|
41
42
|
"MajorityVoting",
|
42
43
|
"MALT",
|
43
44
|
"DeepResearchSwarm",
|
45
|
+
"CouncilAsAJudge",
|
44
46
|
]
|
45
47
|
|
46
48
|
|
@@ -121,7 +123,7 @@ class SwarmRouter:
|
|
121
123
|
shared_memory_system (Any, optional): Shared memory system for agents. Defaults to None.
|
122
124
|
rules (str, optional): Rules to inject into every agent. Defaults to None.
|
123
125
|
documents (List[str], optional): List of document file paths to use. Defaults to empty list.
|
124
|
-
output_type (str, optional): Output format type. Defaults to "string".
|
126
|
+
output_type (str, optional): Output format type. Defaults to "string". Supported: 'str', 'string', 'list', 'json', 'dict', 'yaml', 'xml'.
|
125
127
|
|
126
128
|
Attributes:
|
127
129
|
name (str): Name identifier for the SwarmRouter instance
|
@@ -136,7 +138,7 @@ class SwarmRouter:
|
|
136
138
|
shared_memory_system (Any): Shared memory system for agents
|
137
139
|
rules (str): Rules injected into every agent
|
138
140
|
documents (List[str]): List of document file paths
|
139
|
-
output_type (str): Output format type
|
141
|
+
output_type (str): Output format type. Supported: 'str', 'string', 'list', 'json', 'dict', 'yaml', 'xml'.
|
140
142
|
logs (List[SwarmLog]): List of execution logs
|
141
143
|
swarm: The instantiated swarm object
|
142
144
|
|
@@ -225,13 +227,7 @@ class SwarmRouter:
|
|
225
227
|
csv_path=self.csv_file_path
|
226
228
|
).load_agents()
|
227
229
|
|
228
|
-
|
229
|
-
self._log(
|
230
|
-
"info",
|
231
|
-
f"SwarmRouter initialized with swarm type: {swarm_type}",
|
232
|
-
)
|
233
|
-
|
234
|
-
# Handle Automated Prompt Engineering
|
230
|
+
def setup(self):
|
235
231
|
if self.auto_generate_prompts is True:
|
236
232
|
self.activate_ape()
|
237
233
|
|
@@ -289,18 +285,52 @@ class SwarmRouter:
|
|
289
285
|
raise RuntimeError(error_msg) from e
|
290
286
|
|
291
287
|
def reliability_check(self):
|
292
|
-
|
288
|
+
"""Perform reliability checks on swarm configuration.
|
293
289
|
|
294
|
-
|
295
|
-
|
290
|
+
Validates essential swarm parameters and configuration before execution.
|
291
|
+
Handles special case for CouncilAsAJudge which may not require agents.
|
292
|
+
"""
|
293
|
+
logger.info(
|
294
|
+
"🔍 [SYSTEM] Initializing advanced swarm reliability diagnostics..."
|
295
|
+
)
|
296
|
+
logger.info(
|
297
|
+
"⚡ [SYSTEM] Running pre-flight checks and system validation..."
|
298
|
+
)
|
299
|
+
|
300
|
+
# Check swarm type first since it affects other validations
|
296
301
|
if self.swarm_type is None:
|
302
|
+
logger.error(
|
303
|
+
"❌ [CRITICAL] Swarm type validation failed - type cannot be 'none'"
|
304
|
+
)
|
297
305
|
raise ValueError("Swarm type cannot be 'none'.")
|
306
|
+
|
307
|
+
# Special handling for CouncilAsAJudge
|
308
|
+
if self.swarm_type == "CouncilAsAJudge":
|
309
|
+
if self.agents is not None:
|
310
|
+
logger.warning(
|
311
|
+
"⚠️ [ADVISORY] CouncilAsAJudge detected with agents - this is atypical"
|
312
|
+
)
|
313
|
+
elif not self.agents:
|
314
|
+
logger.error(
|
315
|
+
"❌ [CRITICAL] Agent validation failed - no agents detected in swarm"
|
316
|
+
)
|
317
|
+
raise ValueError("No agents provided for the swarm.")
|
318
|
+
|
319
|
+
# Validate max_loops
|
298
320
|
if self.max_loops == 0:
|
321
|
+
logger.error(
|
322
|
+
"❌ [CRITICAL] Loop validation failed - max_loops cannot be 0"
|
323
|
+
)
|
299
324
|
raise ValueError("max_loops cannot be 0.")
|
300
325
|
|
326
|
+
# Setup other functionality
|
327
|
+
logger.info("🔄 [SYSTEM] Initializing swarm subsystems...")
|
328
|
+
self.setup()
|
329
|
+
|
301
330
|
logger.info(
|
302
|
-
"
|
331
|
+
"✅ [SYSTEM] All reliability checks passed successfully"
|
303
332
|
)
|
333
|
+
logger.info("🚀 [SYSTEM] Swarm is ready for deployment")
|
304
334
|
|
305
335
|
def _create_swarm(
|
306
336
|
self, task: str = None, *args, **kwargs
|
@@ -358,6 +388,15 @@ class SwarmRouter:
|
|
358
388
|
preset_agents=True,
|
359
389
|
)
|
360
390
|
|
391
|
+
elif self.swarm_type == "CouncilAsAJudge":
|
392
|
+
return CouncilAsAJudge(
|
393
|
+
name=self.name,
|
394
|
+
description=self.description,
|
395
|
+
model_name=self.model_name,
|
396
|
+
output_type=self.output_type,
|
397
|
+
base_agent=self.agents[0] if self.agents else None,
|
398
|
+
)
|
399
|
+
|
361
400
|
elif self.swarm_type == "DeepResearchSwarm":
|
362
401
|
return DeepResearchSwarm(
|
363
402
|
name=self.name,
|
@@ -496,7 +535,14 @@ class SwarmRouter:
|
|
496
535
|
self.logs.append(log_entry)
|
497
536
|
logger.log(level.upper(), message)
|
498
537
|
|
499
|
-
def _run(
|
538
|
+
def _run(
|
539
|
+
self,
|
540
|
+
task: str,
|
541
|
+
img: str,
|
542
|
+
model_response: str,
|
543
|
+
*args,
|
544
|
+
**kwargs,
|
545
|
+
) -> Any:
|
500
546
|
"""
|
501
547
|
Dynamically run the specified task on the selected or matched swarm type.
|
502
548
|
|
@@ -520,7 +566,16 @@ class SwarmRouter:
|
|
520
566
|
logger.info(
|
521
567
|
f"Running task on {self.swarm_type} swarm with task: {task}"
|
522
568
|
)
|
523
|
-
|
569
|
+
|
570
|
+
if self.swarm_type == "CouncilAsAJudge":
|
571
|
+
result = self.swarm.run(
|
572
|
+
task=task,
|
573
|
+
model_response=model_response,
|
574
|
+
*args,
|
575
|
+
**kwargs,
|
576
|
+
)
|
577
|
+
else:
|
578
|
+
result = self.swarm.run(task=task, *args, **kwargs)
|
524
579
|
|
525
580
|
logger.info("Swarm completed successfully")
|
526
581
|
return result
|
swarms/tools/__init__.py
CHANGED
@@ -27,6 +27,13 @@ from swarms.tools.cohere_func_call_schema import (
|
|
27
27
|
)
|
28
28
|
from swarms.tools.tool_registry import ToolStorage, tool_registry
|
29
29
|
from swarms.tools.json_utils import base_model_to_json
|
30
|
+
from swarms.tools.mcp_client_call import (
|
31
|
+
execute_tool_call_simple,
|
32
|
+
_execute_tool_call_simple,
|
33
|
+
get_tools_for_multiple_mcp_servers,
|
34
|
+
get_mcp_tools_sync,
|
35
|
+
aget_mcp_tools,
|
36
|
+
)
|
30
37
|
|
31
38
|
|
32
39
|
__all__ = [
|
@@ -50,4 +57,9 @@ __all__ = [
|
|
50
57
|
"ToolStorage",
|
51
58
|
"tool_registry",
|
52
59
|
"base_model_to_json",
|
60
|
+
"execute_tool_call_simple",
|
61
|
+
"_execute_tool_call_simple",
|
62
|
+
"get_tools_for_multiple_mcp_servers",
|
63
|
+
"get_mcp_tools_sync",
|
64
|
+
"aget_mcp_tools",
|
53
65
|
]
|