swarms 7.7.5__tar.gz → 7.7.7__tar.gz
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-7.7.5 → swarms-7.7.7}/PKG-INFO +1 -1
- {swarms-7.7.5 → swarms-7.7.7}/pyproject.toml +2 -2
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/__init__.py +0 -1
- {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/duckdb_wrap.py +15 -6
- swarms-7.7.7/swarms/prompts/max_loop_prompt.py +48 -0
- swarms-7.7.7/swarms/prompts/react_base_prompt.py +41 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent.py +70 -109
- swarms-7.7.7/swarms/structs/concurrent_workflow.py +534 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/conversation.py +123 -6
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/groupchat.py +0 -12
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_model_gpu_manager.py +0 -1
- swarms-7.7.5/swarms/structs/concurrent_workflow.py +0 -419
- {swarms-7.7.5 → swarms-7.7.7}/LICENSE +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/README.md +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/agent_judge.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/agent_print.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/ape_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/auto_generate_swarm_config.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/consistency_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/create_agents_from_yaml.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/flexion_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/gkp_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/i_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/openai_assistant.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/reasoning_agents.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/reasoning_duo.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/agents/tool_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/artifacts/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/artifacts/main_artifact.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/create_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/main.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/cli/onboarding_process.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/client/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/client/main.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/communication/sqlite_wrap.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/accountant_swarm_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/ag_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/aga.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_judge_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/agent_system_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/ai_research_team.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/aot_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/autobloggen.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/autoswarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/chat_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/code_interpreter.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/code_spawner.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/debate.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/documentation.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/education.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/finance_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/finance_agent_sys_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/growth_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/idea2img.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/legal_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/logistics.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/meta_system_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_agent_collab_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_autonomous_instruction_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/multi_modal_visual_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/operations_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/paper_idea_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/personal_stylist.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/product_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/programming.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/project_manager.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt_generator.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/prompt_generator_optimizer.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/python.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/react.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/reasoning_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/refiner_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sales.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sales_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/security_team.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/self_operating_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/sop_generator_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/summaries_prompts.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/support_agent_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/swarm_manager_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/task_assignment_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/tests.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/tools.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/urban_planning.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/visual_cot.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/worker_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/prompts/xray_swarm_prompt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/agent_step_schemas.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/schemas/base_schemas.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_builder.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_registry.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_roles.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/agent_router.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/aop.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/auto_swarm_builder.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_structure.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/base_workflow.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/concat.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/csv_to_agent.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/de_hallucination_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/deep_research_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/dynamic_conversational_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/graph_workflow.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/hiearchical_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/hybrid_hiearchical_peer_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/ma_utils.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/majority_voting.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/malt.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/matrix_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/meme_agent_persona_generator.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/mixture_of_agents.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/model_router.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_collab.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_exec.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/multi_agent_router.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/omni_agent_types.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/output_types.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/rearrange.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/round_robin.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/safe_loading.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/sequential_workflow.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/spreadsheet_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/stopping_conditions.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_arange.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_eval.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_id_generator.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_matcher.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_registry.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarm_router.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/swarming_architectures.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/tree_swarm.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/utils.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/structs/various_alt_swarms.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/bootup.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/telemetry/main.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/base_tool.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/cohere_func_call_schema.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/func_calling_utils.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/func_to_str.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/function_util.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/json_former.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/json_utils.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/logits_processor.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/mcp_client.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/mcp_integration.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/openai_func_calling_schema_pydantic.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/openai_tool_creator_decorator.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/py_func_to_openai_func_str.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/pydantic_to_json.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_parse_exec.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_registry.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_schema_base_model.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/tools/tool_utils.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/__init__.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/any_to_str.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/auto_download_check_packages.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/calculate_func_metrics.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/data_to_text.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/disable_logging.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/file_processing.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/formatter.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/function_caller_model.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/generate_keys.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/history_output_formatter.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/litellm_tokenizer.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/litellm_wrapper.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/loguru_logger.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/markdown_message.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/parse_code.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/pdf_to_text.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/str_to_dict.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/try_except_wrapper.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/visualizer.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/vllm_wrapper.py +0 -0
- {swarms-7.7.5 → swarms-7.7.7}/swarms/utils/wrapper_clusterop.py +0 -0
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
|
5
5
|
|
6
6
|
[tool.poetry]
|
7
7
|
name = "swarms"
|
8
|
-
version = "7.7.
|
8
|
+
version = "7.7.7"
|
9
9
|
description = "Swarms - TGSC"
|
10
10
|
license = "MIT"
|
11
11
|
authors = ["Kye Gomez <kye@apac.ai>"]
|
@@ -87,7 +87,7 @@ swarms = "swarms.cli.main:main"
|
|
87
87
|
|
88
88
|
[tool.poetry.group.lint.dependencies]
|
89
89
|
black = ">=23.1,<26.0"
|
90
|
-
ruff = ">=0.5.1,<0.11.
|
90
|
+
ruff = ">=0.5.1,<0.11.9"
|
91
91
|
types-toml = "^0.10.8.1"
|
92
92
|
types-pytz = ">=2023.3,<2026.0"
|
93
93
|
types-chardet = "^5.0.4.6"
|
@@ -46,6 +46,7 @@ class Message:
|
|
46
46
|
|
47
47
|
class DateTimeEncoder(json.JSONEncoder):
|
48
48
|
"""Custom JSON encoder for handling datetime objects."""
|
49
|
+
|
49
50
|
def default(self, obj):
|
50
51
|
if isinstance(obj, datetime.datetime):
|
51
52
|
return obj.isoformat()
|
@@ -540,7 +541,10 @@ class DuckDBConversation:
|
|
540
541
|
except json.JSONDecodeError:
|
541
542
|
pass
|
542
543
|
|
543
|
-
message = {
|
544
|
+
message = {
|
545
|
+
"role": row[0],
|
546
|
+
"content": content,
|
547
|
+
} # role column
|
544
548
|
|
545
549
|
if row[2]: # timestamp column
|
546
550
|
message["timestamp"] = row[2]
|
@@ -562,7 +566,9 @@ class DuckDBConversation:
|
|
562
566
|
Returns:
|
563
567
|
str: JSON string representation of the conversation
|
564
568
|
"""
|
565
|
-
return json.dumps(
|
569
|
+
return json.dumps(
|
570
|
+
self.to_dict(), indent=2, cls=DateTimeEncoder
|
571
|
+
)
|
566
572
|
|
567
573
|
def to_yaml(self) -> str:
|
568
574
|
"""
|
@@ -585,7 +591,9 @@ class DuckDBConversation:
|
|
585
591
|
"""
|
586
592
|
try:
|
587
593
|
with open(filename, "w") as f:
|
588
|
-
json.dump(
|
594
|
+
json.dump(
|
595
|
+
self.to_dict(), f, indent=2, cls=DateTimeEncoder
|
596
|
+
)
|
589
597
|
return True
|
590
598
|
except Exception as e:
|
591
599
|
if self.enable_logging:
|
@@ -614,12 +622,13 @@ class DuckDBConversation:
|
|
614
622
|
# Add all messages
|
615
623
|
for message in messages:
|
616
624
|
# Convert timestamp string back to datetime if it exists
|
617
|
-
timestamp = None
|
618
625
|
if "timestamp" in message:
|
619
626
|
try:
|
620
|
-
|
627
|
+
datetime.datetime.fromisoformat(
|
628
|
+
message["timestamp"]
|
629
|
+
)
|
621
630
|
except (ValueError, TypeError):
|
622
|
-
|
631
|
+
message["timestamp"]
|
623
632
|
|
624
633
|
self.add(
|
625
634
|
role=message["role"],
|
@@ -0,0 +1,48 @@
|
|
1
|
+
def generate_reasoning_prompt(max_loops: int) -> str:
|
2
|
+
# You are a deliberate, step-by-step reasoning agent designed to solve complex problems
|
3
|
+
# through iterative reasoning loops.
|
4
|
+
|
5
|
+
return f"""
|
6
|
+
Your task is to perform **exactly one loop per generation**,
|
7
|
+
until either the problem is solved or you have completed {max_loops} loops.
|
8
|
+
|
9
|
+
## Instructions:
|
10
|
+
|
11
|
+
- In this generation, perform loop number {{current_loop}} out of {max_loops}.
|
12
|
+
- **Do not perform more than one loop in a single generation.**
|
13
|
+
- Use the **maximum token budget** available to explore, reason, and reflect.
|
14
|
+
- Output must **end** with:
|
15
|
+
- `### End of Loop {{current_loop}}`
|
16
|
+
- **Do not proceed to loop {{current_loop + 1}}** unless explicitly prompted again.
|
17
|
+
|
18
|
+
## Loop Structure (per generation):
|
19
|
+
|
20
|
+
1. **Summarize the Current State**
|
21
|
+
- Recap known information, intermediate thoughts, or context.
|
22
|
+
|
23
|
+
2. **Generate Hypotheses**
|
24
|
+
- Explore possible next steps, questions, or subproblems.
|
25
|
+
|
26
|
+
3. **Evaluate and Choose**
|
27
|
+
- Narrow down based on logic or likelihood of success.
|
28
|
+
|
29
|
+
4. **Act and Update Memory**
|
30
|
+
- Take the chosen step, modify internal reasoning or beliefs.
|
31
|
+
|
32
|
+
5. **Reflect**
|
33
|
+
- Consider whether this step brings you closer to solving the problem.
|
34
|
+
- Suggest whether to continue, backtrack, or finalize.
|
35
|
+
|
36
|
+
## Stopping Criteria:
|
37
|
+
- You will stop reasoning when:
|
38
|
+
- The final answer is found and clearly stated.
|
39
|
+
- {max_loops} loops have been completed.
|
40
|
+
- You conclude that continued reasoning won't help.
|
41
|
+
|
42
|
+
In the final loop (loop {max_loops}), output your final solution as:
|
43
|
+
|
44
|
+
**Final Answer:**
|
45
|
+
|
46
|
+
Be methodical, reflective, and token-efficient. Use all available room to think in detail.
|
47
|
+
Do not rush to conclusions. Each loop is isolated and should be treated as its own generation.
|
48
|
+
"""
|
@@ -0,0 +1,41 @@
|
|
1
|
+
REACT_SYS_PROMPT = """You are a thoughtful and methodical AI agent. You solve problems through careful reasoning and by using external tools when needed. You use a "Thought → Action → Observation" loop, repeating as many times as needed to build your understanding and solve the problem. Your goal is not just to answer correctly, but to demonstrate clear reasoning and adaptability.
|
2
|
+
|
3
|
+
Follow this structure:
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
Question: [The user’s input]
|
8
|
+
|
9
|
+
Thought 1: Understand the question. What is being asked? Break it down into sub-parts. What knowledge or information might be required?
|
10
|
+
|
11
|
+
Thought 2: Form a plan. Decide what steps to take. Which facts should be recalled? Which need to be looked up? Which tools should be used?
|
12
|
+
|
13
|
+
Action 1: [Use a tool, such as Search[query], Lookup[entity], Calculator[expression], or even Plan[...] if you need to set subgoals]
|
14
|
+
Observation 1: [The result from the tool]
|
15
|
+
|
16
|
+
Thought 3: Reflect on the observation. What did you learn? What do you now know or still not know? Update your plan if needed.
|
17
|
+
|
18
|
+
Action 2: [Next tool or operation]
|
19
|
+
Observation 2: [...]
|
20
|
+
|
21
|
+
...
|
22
|
+
|
23
|
+
[Repeat Thought → Action → Observation as needed]
|
24
|
+
|
25
|
+
Thought N: You now have all the necessary information. Synthesize what you know. Reconstruct the answer clearly, and justify it.
|
26
|
+
|
27
|
+
Action N: Finish[final_answer]
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
Guidelines for Reasoning:
|
32
|
+
- Always **start by interpreting the problem carefully.**
|
33
|
+
- If the question is complex, **break it into parts** and tackle each.
|
34
|
+
- **Think before you act.** Plan actions deliberately, not reflexively.
|
35
|
+
- Use **search engines** or **lookup tools** for facts, definitions, or current events.
|
36
|
+
- Use a **calculator** for numerical operations.
|
37
|
+
- Use **Reflection** steps if your observations are unclear, surprising, or contradictory.
|
38
|
+
- Don't rush to finish — **reasoning is more important than speed.**
|
39
|
+
- When concluding, make sure your **answer is fully supported** by earlier steps.
|
40
|
+
|
41
|
+
"""
|
@@ -39,12 +39,19 @@ from swarms.schemas.base_schemas import (
|
|
39
39
|
)
|
40
40
|
from swarms.structs.agent_roles import agent_roles
|
41
41
|
from swarms.structs.conversation import Conversation
|
42
|
+
from swarms.structs.output_types import OutputType
|
42
43
|
from swarms.structs.safe_loading import (
|
43
44
|
SafeLoaderUtils,
|
44
45
|
SafeStateManager,
|
45
46
|
)
|
46
47
|
from swarms.telemetry.main import log_agent_data
|
47
48
|
from swarms.tools.base_tool import BaseTool
|
49
|
+
from swarms.tools.mcp_client import (
|
50
|
+
execute_mcp_tool,
|
51
|
+
find_and_execute_tool,
|
52
|
+
list_all,
|
53
|
+
list_tools_for_multiple_urls,
|
54
|
+
)
|
48
55
|
from swarms.tools.mcp_integration import MCPServerSseParams
|
49
56
|
from swarms.tools.tool_parse_exec import parse_and_execute_json
|
50
57
|
from swarms.utils.any_to_str import any_to_str
|
@@ -57,14 +64,9 @@ from swarms.utils.history_output_formatter import (
|
|
57
64
|
from swarms.utils.litellm_tokenizer import count_tokens
|
58
65
|
from swarms.utils.litellm_wrapper import LiteLLM
|
59
66
|
from swarms.utils.pdf_to_text import pdf_to_text
|
60
|
-
from swarms.structs.output_types import OutputType
|
61
67
|
from swarms.utils.str_to_dict import str_to_dict
|
62
|
-
from swarms.
|
63
|
-
|
64
|
-
list_tools_for_multiple_urls,
|
65
|
-
list_all,
|
66
|
-
find_and_execute_tool,
|
67
|
-
)
|
68
|
+
from swarms.prompts.react_base_prompt import REACT_SYS_PROMPT
|
69
|
+
from swarms.prompts.max_loop_prompt import generate_reasoning_prompt
|
68
70
|
|
69
71
|
|
70
72
|
# Utils
|
@@ -302,7 +304,7 @@ class Agent:
|
|
302
304
|
saved_state_path: Optional[str] = None,
|
303
305
|
autosave: Optional[bool] = False,
|
304
306
|
context_length: Optional[int] = 8192,
|
305
|
-
user_name: Optional[str] = "Human
|
307
|
+
user_name: Optional[str] = "Human",
|
306
308
|
self_healing_enabled: Optional[bool] = False,
|
307
309
|
code_interpreter: Optional[bool] = False,
|
308
310
|
multi_modal: Optional[bool] = None,
|
@@ -396,6 +398,7 @@ class Agent:
|
|
396
398
|
mcp_servers: MCPServerSseParams = None,
|
397
399
|
mcp_url: str = None,
|
398
400
|
mcp_urls: List[str] = None,
|
401
|
+
react_on: bool = False,
|
399
402
|
*args,
|
400
403
|
**kwargs,
|
401
404
|
):
|
@@ -518,12 +521,13 @@ class Agent:
|
|
518
521
|
self.mcp_servers = mcp_servers
|
519
522
|
self.mcp_url = mcp_url
|
520
523
|
self.mcp_urls = mcp_urls
|
524
|
+
self.react_on = react_on
|
521
525
|
|
522
526
|
self._cached_llm = (
|
523
527
|
None # Add this line to cache the LLM instance
|
524
528
|
)
|
525
529
|
|
526
|
-
self.short_memory = self.short_memory_init()
|
530
|
+
# self.short_memory = self.short_memory_init()
|
527
531
|
|
528
532
|
# Initialize the feedback
|
529
533
|
self.feedback = []
|
@@ -555,6 +559,16 @@ class Agent:
|
|
555
559
|
if self.mcp_url or self.mcp_servers is not None:
|
556
560
|
self.add_mcp_tools_to_memory()
|
557
561
|
|
562
|
+
if self.react_on is True:
|
563
|
+
self.system_prompt += REACT_SYS_PROMPT
|
564
|
+
|
565
|
+
if self.max_loops > 1:
|
566
|
+
self.system_prompt += generate_reasoning_prompt(
|
567
|
+
self.max_loops
|
568
|
+
)
|
569
|
+
|
570
|
+
self.short_memory = self.short_memory_init()
|
571
|
+
|
558
572
|
def short_memory_init(self):
|
559
573
|
if (
|
560
574
|
self.agent_name is not None
|
@@ -575,33 +589,6 @@ class Agent:
|
|
575
589
|
|
576
590
|
return self.short_memory
|
577
591
|
|
578
|
-
def init_handling(self):
|
579
|
-
# Define tasks as pairs of (function, condition)
|
580
|
-
# Each task will only run if its condition is True
|
581
|
-
self.setup_config()
|
582
|
-
|
583
|
-
if exists(self.docs_folder):
|
584
|
-
self.get_docs_from_doc_folders()
|
585
|
-
|
586
|
-
if exists(self.tools):
|
587
|
-
self.handle_tool_init()
|
588
|
-
|
589
|
-
if exists(self.tool_schema) or exists(self.list_base_models):
|
590
|
-
self.handle_tool_schema_ops()
|
591
|
-
|
592
|
-
if exists(self.sop) or exists(self.sop_list):
|
593
|
-
self.handle_sop_ops()
|
594
|
-
|
595
|
-
# Run sequential operations after all concurrent tasks are done
|
596
|
-
# self.agent_output = self.agent_output_model()
|
597
|
-
log_agent_data(self.to_dict())
|
598
|
-
|
599
|
-
if self.llm is None:
|
600
|
-
self.llm = self.llm_handling()
|
601
|
-
|
602
|
-
if self.mcp_url or self.mcp_servers is not None:
|
603
|
-
self.add_mcp_tools_to_memory()
|
604
|
-
|
605
592
|
def agent_output_model(self):
|
606
593
|
# Many steps
|
607
594
|
id = agent_id()
|
@@ -1021,24 +1008,13 @@ class Agent:
|
|
1021
1008
|
agent(task="What is the capital of France?", img="path/to/image.jpg", is_last=True)
|
1022
1009
|
"""
|
1023
1010
|
try:
|
1024
|
-
# 1. Batch process initial setup
|
1025
|
-
setup_tasks = [
|
1026
|
-
lambda: self.check_if_no_prompt_then_autogenerate(
|
1027
|
-
task
|
1028
|
-
),
|
1029
|
-
lambda: self.short_memory.add(
|
1030
|
-
role=self.user_name, content=task
|
1031
|
-
),
|
1032
|
-
lambda: (
|
1033
|
-
self.plan(task) if self.plan_enabled else None
|
1034
|
-
),
|
1035
|
-
]
|
1036
1011
|
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1012
|
+
self.check_if_no_prompt_then_autogenerate(task)
|
1013
|
+
|
1014
|
+
self.short_memory.add(role=self.user_name, content=task)
|
1015
|
+
|
1016
|
+
if self.plan_enabled:
|
1017
|
+
self.plan(task)
|
1042
1018
|
|
1043
1019
|
# Set the loop count
|
1044
1020
|
loop_count = 0
|
@@ -1068,10 +1044,18 @@ class Agent:
|
|
1068
1044
|
):
|
1069
1045
|
loop_count += 1
|
1070
1046
|
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1047
|
+
if self.max_loops > 1:
|
1048
|
+
self.short_memory.add(
|
1049
|
+
role=self.agent_name,
|
1050
|
+
content=f"Current Internal Reasoning Loop: {loop_count}/{self.max_loops}",
|
1051
|
+
)
|
1052
|
+
|
1053
|
+
# If it is the final loop, then add the final loop message
|
1054
|
+
if loop_count == self.max_loops:
|
1055
|
+
self.short_memory.add(
|
1056
|
+
role=self.agent_name,
|
1057
|
+
content=f"🎉 Final Internal Reasoning Loop: {loop_count}/{self.max_loops} Prepare your comprehensive response.",
|
1058
|
+
)
|
1075
1059
|
|
1076
1060
|
# Dynamic temperature
|
1077
1061
|
if self.dynamic_temperature_enabled is True:
|
@@ -1111,31 +1095,15 @@ class Agent:
|
|
1111
1095
|
# Convert to a str if the response is not a str
|
1112
1096
|
response = self.parse_llm_output(response)
|
1113
1097
|
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
# # Print
|
1119
|
-
# self.pretty_print(response, loop_count)
|
1120
|
-
|
1121
|
-
# # Output Cleaner
|
1122
|
-
# self.output_cleaner_op(response)
|
1098
|
+
self.short_memory.add(
|
1099
|
+
role=self.agent_name, content=response
|
1100
|
+
)
|
1123
1101
|
|
1124
|
-
#
|
1125
|
-
|
1126
|
-
lambda: self.short_memory.add(
|
1127
|
-
role=self.agent_name, content=response
|
1128
|
-
),
|
1129
|
-
lambda: self.pretty_print(
|
1130
|
-
response, loop_count
|
1131
|
-
),
|
1132
|
-
lambda: self.output_cleaner_op(response),
|
1133
|
-
]
|
1102
|
+
# Print
|
1103
|
+
self.pretty_print(response, loop_count)
|
1134
1104
|
|
1135
|
-
|
1136
|
-
|
1137
|
-
) as executor:
|
1138
|
-
executor.map(lambda f: f(), update_tasks)
|
1105
|
+
# Output Cleaner
|
1106
|
+
self.output_cleaner_op(response)
|
1139
1107
|
|
1140
1108
|
####### MCP TOOL HANDLING #######
|
1141
1109
|
if (
|
@@ -1156,26 +1124,28 @@ class Agent:
|
|
1156
1124
|
role="Tool Executor", content=out
|
1157
1125
|
)
|
1158
1126
|
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1127
|
+
if self.no_print is False:
|
1128
|
+
agent_print(
|
1129
|
+
f"{self.agent_name} - Tool Executor",
|
1130
|
+
out,
|
1131
|
+
loop_count,
|
1132
|
+
self.streaming_on,
|
1133
|
+
)
|
1165
1134
|
|
1166
|
-
out = self.
|
1167
|
-
|
1168
|
-
agent_print(
|
1169
|
-
f"{self.agent_name} - Agent Analysis",
|
1170
|
-
out,
|
1171
|
-
loop_count,
|
1172
|
-
self.streaming_on,
|
1173
|
-
)
|
1135
|
+
out = self.call_llm(task=out)
|
1174
1136
|
|
1175
1137
|
self.short_memory.add(
|
1176
1138
|
role=self.agent_name, content=out
|
1177
1139
|
)
|
1178
1140
|
|
1141
|
+
if self.no_print is False:
|
1142
|
+
agent_print(
|
1143
|
+
f"{self.agent_name} - Agent Analysis",
|
1144
|
+
out,
|
1145
|
+
loop_count,
|
1146
|
+
self.streaming_on,
|
1147
|
+
)
|
1148
|
+
|
1179
1149
|
self.sentiment_and_evaluator(response)
|
1180
1150
|
|
1181
1151
|
success = True # Mark as successful to exit the retry loop
|
@@ -1233,7 +1203,7 @@ class Agent:
|
|
1233
1203
|
break
|
1234
1204
|
|
1235
1205
|
self.short_memory.add(
|
1236
|
-
role=
|
1206
|
+
role=self.user_name, content=user_input
|
1237
1207
|
)
|
1238
1208
|
|
1239
1209
|
if self.loop_interval:
|
@@ -1247,21 +1217,10 @@ class Agent:
|
|
1247
1217
|
|
1248
1218
|
self.save()
|
1249
1219
|
|
1250
|
-
|
1251
|
-
|
1252
|
-
# if self.autosave is True:
|
1253
|
-
# self.save()
|
1254
|
-
|
1255
|
-
# 14. Batch final operations
|
1256
|
-
final_tasks = [
|
1257
|
-
lambda: log_agent_data(self.to_dict()),
|
1258
|
-
lambda: self.save() if self.autosave else None,
|
1259
|
-
]
|
1220
|
+
log_agent_data(self.to_dict())
|
1260
1221
|
|
1261
|
-
|
1262
|
-
|
1263
|
-
) as executor:
|
1264
|
-
executor.map(lambda f: f(), final_tasks)
|
1222
|
+
if self.autosave:
|
1223
|
+
self.save()
|
1265
1224
|
|
1266
1225
|
return history_output_formatter(
|
1267
1226
|
self.short_memory, type=self.output_type
|
@@ -2738,6 +2697,8 @@ class Agent:
|
|
2738
2697
|
f"{self.agent_name}: {response}",
|
2739
2698
|
title=f"Agent Name: {self.agent_name} [Max Loops: {loop_count}]",
|
2740
2699
|
)
|
2700
|
+
elif self.no_print is True:
|
2701
|
+
pass
|
2741
2702
|
else:
|
2742
2703
|
# logger.info(f"Response: {response}")
|
2743
2704
|
formatter.print_panel(
|