swarms 7.6.9__tar.gz → 7.7.1__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.
Files changed (191) hide show
  1. {swarms-7.6.9 → swarms-7.7.1}/PKG-INFO +1 -1
  2. {swarms-7.6.9 → swarms-7.7.1}/pyproject.toml +2 -2
  3. swarms-7.7.1/swarms/prompts/paper_idea_agent.py +31 -0
  4. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agent.py +166 -116
  5. swarms-7.7.1/swarms/structs/aop.py +557 -0
  6. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/conversation.py +21 -0
  7. {swarms-7.6.9 → swarms-7.7.1}/swarms/telemetry/main.py +124 -37
  8. swarms-7.7.1/swarms/tools/mcp_client.py +90 -0
  9. swarms-7.7.1/swarms/utils/history_output_formatter.py +47 -0
  10. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/litellm_wrapper.py +26 -10
  11. swarms-7.6.9/swarms/utils/history_output_formatter.py +0 -23
  12. {swarms-7.6.9 → swarms-7.7.1}/LICENSE +0 -0
  13. {swarms-7.6.9 → swarms-7.7.1}/README.md +0 -0
  14. {swarms-7.6.9 → swarms-7.7.1}/swarms/__init__.py +0 -0
  15. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/__init__.py +0 -0
  16. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/agent_judge.py +0 -0
  17. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/agent_print.py +0 -0
  18. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/ape_agent.py +0 -0
  19. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/auto_generate_swarm_config.py +0 -0
  20. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/consistency_agent.py +0 -0
  21. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/create_agents_from_yaml.py +0 -0
  22. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/flexion_agent.py +0 -0
  23. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/gkp_agent.py +0 -0
  24. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/i_agent.py +0 -0
  25. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/openai_assistant.py +0 -0
  26. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/reasoning_agents.py +0 -0
  27. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/reasoning_duo.py +0 -0
  28. {swarms-7.6.9 → swarms-7.7.1}/swarms/agents/tool_agent.py +0 -0
  29. {swarms-7.6.9 → swarms-7.7.1}/swarms/artifacts/__init__.py +0 -0
  30. {swarms-7.6.9 → swarms-7.7.1}/swarms/artifacts/main_artifact.py +0 -0
  31. {swarms-7.6.9 → swarms-7.7.1}/swarms/cli/__init__.py +0 -0
  32. {swarms-7.6.9 → swarms-7.7.1}/swarms/cli/create_agent.py +0 -0
  33. {swarms-7.6.9 → swarms-7.7.1}/swarms/cli/main.py +0 -0
  34. {swarms-7.6.9 → swarms-7.7.1}/swarms/cli/onboarding_process.py +0 -0
  35. {swarms-7.6.9 → swarms-7.7.1}/swarms/client/__init__.py +0 -0
  36. {swarms-7.6.9 → swarms-7.7.1}/swarms/client/main.py +0 -0
  37. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/__init__.py +0 -0
  38. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/accountant_swarm_prompts.py +0 -0
  39. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/ag_prompt.py +0 -0
  40. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/aga.py +0 -0
  41. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/agent_judge_prompt.py +0 -0
  42. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/agent_prompt.py +0 -0
  43. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/agent_prompts.py +0 -0
  44. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/agent_system_prompts.py +0 -0
  45. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/ai_research_team.py +0 -0
  46. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/aot_prompt.py +0 -0
  47. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/autobloggen.py +0 -0
  48. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/autoswarm.py +0 -0
  49. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/chat_prompt.py +0 -0
  50. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/code_interpreter.py +0 -0
  51. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/code_spawner.py +0 -0
  52. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/debate.py +0 -0
  53. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/documentation.py +0 -0
  54. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/education.py +0 -0
  55. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/finance_agent_prompt.py +0 -0
  56. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/finance_agent_sys_prompt.py +0 -0
  57. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/growth_agent_prompt.py +0 -0
  58. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/idea2img.py +0 -0
  59. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/legal_agent_prompt.py +0 -0
  60. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/logistics.py +0 -0
  61. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/meta_system_prompt.py +0 -0
  62. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/multi_agent_collab_prompt.py +0 -0
  63. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/multi_modal_autonomous_instruction_prompt.py +0 -0
  64. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/multi_modal_prompts.py +0 -0
  65. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/multi_modal_visual_prompts.py +0 -0
  66. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/operations_agent_prompt.py +0 -0
  67. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/personal_stylist.py +0 -0
  68. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/product_agent_prompt.py +0 -0
  69. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/programming.py +0 -0
  70. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/project_manager.py +0 -0
  71. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/prompt.py +0 -0
  72. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/prompt_generator.py +0 -0
  73. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/prompt_generator_optimizer.py +0 -0
  74. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/python.py +0 -0
  75. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/react.py +0 -0
  76. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/reasoning_prompt.py +0 -0
  77. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/refiner_agent_prompt.py +0 -0
  78. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/sales.py +0 -0
  79. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/sales_prompts.py +0 -0
  80. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/security_team.py +0 -0
  81. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/self_operating_prompt.py +0 -0
  82. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/sop_generator_agent_prompt.py +0 -0
  83. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/summaries_prompts.py +0 -0
  84. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/support_agent_prompt.py +0 -0
  85. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/swarm_manager_agent.py +0 -0
  86. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/task_assignment_prompt.py +0 -0
  87. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/tests.py +0 -0
  88. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/tools.py +0 -0
  89. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/urban_planning.py +0 -0
  90. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/visual_cot.py +0 -0
  91. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/worker_prompt.py +0 -0
  92. {swarms-7.6.9 → swarms-7.7.1}/swarms/prompts/xray_swarm_prompt.py +0 -0
  93. {swarms-7.6.9 → swarms-7.7.1}/swarms/schemas/__init__.py +0 -0
  94. {swarms-7.6.9 → swarms-7.7.1}/swarms/schemas/agent_input_schema.py +0 -0
  95. {swarms-7.6.9 → swarms-7.7.1}/swarms/schemas/agent_step_schemas.py +0 -0
  96. {swarms-7.6.9 → swarms-7.7.1}/swarms/schemas/base_schemas.py +0 -0
  97. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/__init__.py +0 -0
  98. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agent_builder.py +0 -0
  99. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agent_registry.py +0 -0
  100. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agent_roles.py +0 -0
  101. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agent_router.py +0 -0
  102. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/agents_available.py +0 -0
  103. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/async_workflow.py +0 -0
  104. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/auto_swarm_builder.py +0 -0
  105. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/base_structure.py +0 -0
  106. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/base_swarm.py +0 -0
  107. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/base_workflow.py +0 -0
  108. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/concat.py +0 -0
  109. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/concurrent_workflow.py +0 -0
  110. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/csv_to_agent.py +0 -0
  111. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/de_hallucination_swarm.py +0 -0
  112. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/deep_research_swarm.py +0 -0
  113. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/dynamic_conversational_swarm.py +0 -0
  114. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/graph_swarm.py +0 -0
  115. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/graph_workflow.py +0 -0
  116. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/groupchat.py +0 -0
  117. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/hiearchical_swarm.py +0 -0
  118. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/hybrid_hiearchical_peer_swarm.py +0 -0
  119. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/majority_voting.py +0 -0
  120. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/malt.py +0 -0
  121. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/matrix_swarm.py +0 -0
  122. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/meme_agent_persona_generator.py +0 -0
  123. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/mixture_of_agents.py +0 -0
  124. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/model_router.py +0 -0
  125. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/multi_agent_collab.py +0 -0
  126. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/multi_agent_exec.py +0 -0
  127. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/multi_agent_orchestrator.py +0 -0
  128. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/octotools.py +0 -0
  129. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/omni_agent_types.py +0 -0
  130. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/output_types.py +0 -0
  131. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/pulsar_swarm.py +0 -0
  132. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/queue_swarm.py +0 -0
  133. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/rearrange.py +0 -0
  134. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/round_robin.py +0 -0
  135. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/safe_loading.py +0 -0
  136. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/sequential_workflow.py +0 -0
  137. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/spreadsheet_swarm.py +0 -0
  138. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/stopping_conditions.py +0 -0
  139. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_arange.py +0 -0
  140. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_builder.py +0 -0
  141. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_eval.py +0 -0
  142. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_id_generator.py +0 -0
  143. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_load_balancer.py +0 -0
  144. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_matcher.py +0 -0
  145. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_output_type.py +0 -0
  146. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_registry.py +0 -0
  147. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarm_router.py +0 -0
  148. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/swarming_architectures.py +0 -0
  149. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/talk_hier.py +0 -0
  150. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/tree_swarm.py +0 -0
  151. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/utils.py +0 -0
  152. {swarms-7.6.9 → swarms-7.7.1}/swarms/structs/various_alt_swarms.py +0 -0
  153. {swarms-7.6.9 → swarms-7.7.1}/swarms/telemetry/__init__.py +0 -0
  154. {swarms-7.6.9 → swarms-7.7.1}/swarms/telemetry/bootup.py +0 -0
  155. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/__init__.py +0 -0
  156. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/base_tool.py +0 -0
  157. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/cohere_func_call_schema.py +0 -0
  158. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/func_calling_utils.py +0 -0
  159. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/func_to_str.py +0 -0
  160. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/function_util.py +0 -0
  161. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/json_former.py +0 -0
  162. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/json_utils.py +0 -0
  163. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/logits_processor.py +0 -0
  164. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/mcp_integration.py +0 -0
  165. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/openai_func_calling_schema_pydantic.py +0 -0
  166. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/openai_tool_creator_decorator.py +0 -0
  167. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/py_func_to_openai_func_str.py +0 -0
  168. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/pydantic_to_json.py +0 -0
  169. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/tool_parse_exec.py +0 -0
  170. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/tool_registry.py +0 -0
  171. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/tool_schema_base_model.py +0 -0
  172. {swarms-7.6.9 → swarms-7.7.1}/swarms/tools/tool_utils.py +0 -0
  173. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/__init__.py +0 -0
  174. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/any_to_str.py +0 -0
  175. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/auto_download_check_packages.py +0 -0
  176. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/calculate_func_metrics.py +0 -0
  177. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/data_to_text.py +0 -0
  178. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/disable_logging.py +0 -0
  179. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/file_processing.py +0 -0
  180. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/formatter.py +0 -0
  181. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/function_caller_model.py +0 -0
  182. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/litellm_tokenizer.py +0 -0
  183. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/loguru_logger.py +0 -0
  184. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/markdown_message.py +0 -0
  185. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/parse_code.py +0 -0
  186. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/pdf_to_text.py +0 -0
  187. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/str_to_dict.py +0 -0
  188. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/try_except_wrapper.py +0 -0
  189. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/visualizer.py +0 -0
  190. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/vllm_wrapper.py +0 -0
  191. {swarms-7.6.9 → swarms-7.7.1}/swarms/utils/wrapper_clusterop.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: swarms
3
- Version: 7.6.9
3
+ Version: 7.7.1
4
4
  Summary: Swarms - TGSC
5
5
  Home-page: https://github.com/kyegomez/swarms
6
6
  License: MIT
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
5
5
 
6
6
  [tool.poetry]
7
7
  name = "swarms"
8
- version = "7.6.9"
8
+ version = "7.7.1"
9
9
  description = "Swarms - TGSC"
10
10
  license = "MIT"
11
11
  authors = ["Kye Gomez <kye@apac.ai>"]
@@ -84,7 +84,7 @@ swarms = "swarms.cli.main:main"
84
84
 
85
85
  [tool.poetry.group.lint.dependencies]
86
86
  black = ">=23.1,<26.0"
87
- ruff = ">=0.5.1,<0.11.3"
87
+ ruff = ">=0.5.1,<0.11.6"
88
88
  types-toml = "^0.10.8.1"
89
89
  types-pytz = ">=2023.3,<2026.0"
90
90
  types-chardet = "^5.0.4.6"
@@ -0,0 +1,31 @@
1
+ # System Role Definition
2
+ PAPER_IDEA_AGENT_SYSTEM_PROMPT = """
3
+ You are an experienced AI researcher tasked with proposing high-impact research ideas. Your ideas should:
4
+
5
+ - Be novel and creative
6
+ - Think outside conventional boundaries
7
+ - Start from simple, elegant questions or observations
8
+ - Be distinguishable from existing literature
9
+ - Be feasible within academic lab resources
10
+ - Be publishable at top ML conferences
11
+ - Be implementable using the provided codebase
12
+
13
+ Your responses must follow this strict format:
14
+
15
+
16
+ IDEA JSON Structure:
17
+ {
18
+ "Name": "Concise identifier",
19
+ "Title": "Academic paper title",
20
+ "Short Hypothesis": "Core hypothesis in 1-2 sentences",
21
+ "Related Work": "Key papers and how this differs",
22
+ "Abstract": "Complete paper abstract",
23
+ "Experiments": "Detailed experimental plan",
24
+ "Risk Factors and Limitations": "Known challenges and constraints"
25
+ }
26
+
27
+ Important Guidelines:
28
+ - Perform at least one literature search before finalizing any idea
29
+ - Ensure JSON formatting is valid for automated parsing
30
+ - Keep proposals clear and implementable
31
+ """
@@ -1,3 +1,4 @@
1
+ import concurrent.futures
1
2
  import asyncio
2
3
  import json
3
4
  import logging
@@ -13,7 +14,6 @@ from typing import (
13
14
  Callable,
14
15
  Dict,
15
16
  List,
16
- Literal,
17
17
  Optional,
18
18
  Tuple,
19
19
  Union,
@@ -59,6 +59,7 @@ from swarms.utils.file_processing import create_file_in_folder
59
59
  from swarms.utils.formatter import formatter
60
60
  from swarms.utils.history_output_formatter import (
61
61
  history_output_formatter,
62
+ HistoryOutputType,
62
63
  )
63
64
  from swarms.utils.litellm_tokenizer import count_tokens
64
65
  from swarms.utils.litellm_wrapper import LiteLLM
@@ -89,18 +90,6 @@ def exists(val):
89
90
 
90
91
 
91
92
  # Agent output types
92
- # agent_output_type = Union[BaseModel, dict, str]
93
- agent_output_type = Literal[
94
- "string",
95
- "str",
96
- "list",
97
- "json",
98
- "dict",
99
- "yaml",
100
- "json_schema",
101
- "memory-list",
102
- "memory-dict",
103
- ]
104
93
  ToolUsageType = Union[BaseModel, Dict[str, Any]]
105
94
 
106
95
 
@@ -346,7 +335,7 @@ class Agent:
346
335
  # [Tools]
347
336
  custom_tools_prompt: Optional[Callable] = None,
348
337
  tool_schema: ToolUsageType = None,
349
- output_type: agent_output_type = "str",
338
+ output_type: HistoryOutputType = "str",
350
339
  function_calling_type: str = "json",
351
340
  output_cleaner: Optional[Callable] = None,
352
341
  function_calling_format_type: Optional[str] = "OpenAI",
@@ -524,6 +513,7 @@ class Agent:
524
513
  self.no_print = no_print
525
514
  self.tools_list_dictionary = tools_list_dictionary
526
515
  # self.mcp_servers = mcp_servers
516
+
527
517
  self._cached_llm = (
528
518
  None # Add this line to cache the LLM instance
529
519
  )
@@ -558,72 +548,76 @@ class Agent:
558
548
  max_workers=executor_workers
559
549
  )
560
550
 
561
- # Initialize the tool struct
562
- if (
563
- exists(tools)
564
- or exists(list_base_models)
565
- or exists(tool_schema)
566
- ):
567
-
568
- self.tool_struct = BaseTool(
569
- tools=tools,
570
- base_models=list_base_models,
571
- tool_system_prompt=tool_system_prompt,
572
- )
573
-
574
- # Some common configuration settings
575
- threading.Thread(
576
- target=self.setup_config, daemon=True
577
- ).start()
578
-
579
- # If docs folder exists then get the docs from docs folder
580
- if exists(self.docs_folder):
581
- threading.Thread(
582
- target=self.get_docs_from_doc_folders
583
- ).start()
584
-
585
- if tools is not None:
586
- logger.info(
587
- "Tools provided make sure the functions have documentation ++ type hints, otherwise tool execution won't be reliable."
588
- )
589
- # Add the tool prompt to the memory
590
- self.short_memory.add(
591
- role="system", content=tool_system_prompt
592
- )
593
-
594
- # Log the tools
595
- logger.info(
596
- f"Tools provided: Accessing {len(tools)} tools"
597
- )
598
-
599
- # Transform the tools into an openai schema
600
- # self.convert_tool_into_openai_schema()
601
-
602
- # Transform the tools into an openai schema
603
- tool_dict = (
604
- self.tool_struct.convert_tool_into_openai_schema()
605
- )
606
- self.short_memory.add(role="system", content=tool_dict)
551
+ self.init_handling()
607
552
 
608
- # Now create a function calling map for every tools
609
- self.function_map = {
610
- tool.__name__: tool for tool in tools
553
+ def init_handling(self):
554
+ # Define tasks as pairs of (function, condition)
555
+ # Each task will only run if its condition is True
556
+ tasks = [
557
+ (self.setup_config, True), # Always run setup_config
558
+ (
559
+ self.get_docs_from_doc_folders,
560
+ exists(self.docs_folder),
561
+ ),
562
+ (self.handle_tool_init, True), # Always run tool init
563
+ (
564
+ self.handle_tool_schema_ops,
565
+ exists(self.tool_schema)
566
+ or exists(self.list_base_models),
567
+ ),
568
+ (
569
+ self.handle_sop_ops,
570
+ exists(self.sop) or exists(self.sop_list),
571
+ ),
572
+ ]
573
+
574
+ # Filter out tasks whose conditions are False
575
+ filtered_tasks = [
576
+ task for task, condition in tasks if condition
577
+ ]
578
+
579
+ # Execute all tasks concurrently
580
+ with concurrent.futures.ThreadPoolExecutor(
581
+ max_workers=os.cpu_count() * 4
582
+ ) as executor:
583
+ # Map tasks to futures and collect results
584
+ results = {}
585
+ future_to_task = {
586
+ executor.submit(task): task.__name__
587
+ for task in filtered_tasks
611
588
  }
612
589
 
613
- # If the tool schema exists or a list of base models exists then convert the tool schema into an openai schema
614
- if exists(tool_schema) or exists(list_base_models):
615
- threading.Thread(
616
- target=self.handle_tool_schema_ops()
617
- ).start()
590
+ # Wait for each future to complete and collect results/exceptions
591
+ for future in concurrent.futures.as_completed(
592
+ future_to_task
593
+ ):
594
+ task_name = future_to_task[future]
595
+ try:
596
+ result = future.result()
597
+ results[task_name] = result
598
+ logging.info(
599
+ f"Task {task_name} completed successfully"
600
+ )
601
+ except Exception as e:
602
+ results[task_name] = None
603
+ logging.error(
604
+ f"Task {task_name} failed with error: {e}"
605
+ )
606
+
607
+ # Run sequential operations after all concurrent tasks are done
608
+ self.agent_output = self.agent_output_model()
609
+ log_agent_data(self.to_dict())
618
610
 
619
- # If the sop or sop_list exists then handle the sop ops
620
- if exists(self.sop) or exists(self.sop_list):
621
- threading.Thread(target=self.handle_sop_ops()).start()
611
+ if self.llm is None:
612
+ self.llm = self.llm_handling()
622
613
 
614
+ def agent_output_model(self):
623
615
  # Many steps
624
- self.agent_output = ManySteps(
625
- agent_id=agent_id,
626
- agent_name=agent_name,
616
+ id = agent_id()
617
+
618
+ return ManySteps(
619
+ agent_id=id,
620
+ agent_name=self.agent_name,
627
621
  # run_id=run_id,
628
622
  task="",
629
623
  max_loops=self.max_loops,
@@ -637,18 +631,6 @@ class Agent:
637
631
  dynamic_temperature_enabled=self.dynamic_temperature_enabled,
638
632
  )
639
633
 
640
- # Telemetry Processor to log agent data
641
- log_agent_data(self.to_dict())
642
-
643
- if self.llm is None:
644
- self.llm = self.llm_handling()
645
-
646
- # if (
647
- # self.tools_list_dictionary is None
648
- # and self.mcp_servers is not None
649
- # ):
650
- # self.tools_list_dictionary = self.mcp_tool_handling()
651
-
652
634
  def llm_handling(self):
653
635
  # Use cached instance if available
654
636
  if self._cached_llm is not None:
@@ -695,6 +677,48 @@ class Agent:
695
677
  )
696
678
  return None
697
679
 
680
+ def handle_tool_init(self):
681
+ # Initialize the tool struct
682
+ if (
683
+ exists(self.tools)
684
+ or exists(self.list_base_models)
685
+ or exists(self.tool_schema)
686
+ ):
687
+
688
+ self.tool_struct = BaseTool(
689
+ tools=self.tools,
690
+ base_models=self.list_base_models,
691
+ tool_system_prompt=self.tool_system_prompt,
692
+ )
693
+
694
+ if self.tools is not None:
695
+ logger.info(
696
+ "Tools provided make sure the functions have documentation ++ type hints, otherwise tool execution won't be reliable."
697
+ )
698
+ # Add the tool prompt to the memory
699
+ self.short_memory.add(
700
+ role="system", content=self.tool_system_prompt
701
+ )
702
+
703
+ # Log the tools
704
+ logger.info(
705
+ f"Tools provided: Accessing {len(self.tools)} tools"
706
+ )
707
+
708
+ # Transform the tools into an openai schema
709
+ # self.convert_tool_into_openai_schema()
710
+
711
+ # Transform the tools into an openai schema
712
+ tool_dict = (
713
+ self.tool_struct.convert_tool_into_openai_schema()
714
+ )
715
+ self.short_memory.add(role="system", content=tool_dict)
716
+
717
+ # Now create a function calling map for every tools
718
+ self.function_map = {
719
+ tool.__name__: tool for tool in self.tools
720
+ }
721
+
698
722
  # def mcp_execution_flow(self, response: any):
699
723
  # """
700
724
  # Executes the MCP (Model Context Protocol) flow based on the provided response.
@@ -955,14 +979,24 @@ class Agent:
955
979
  agent(task="What is the capital of France?", img="path/to/image.jpg", is_last=True)
956
980
  """
957
981
  try:
958
- self.check_if_no_prompt_then_autogenerate(task)
959
-
960
- # Add task to memory
961
- self.short_memory.add(role=self.user_name, content=task)
982
+ # 1. Batch process initial setup
983
+ setup_tasks = [
984
+ lambda: self.check_if_no_prompt_then_autogenerate(
985
+ task
986
+ ),
987
+ lambda: self.short_memory.add(
988
+ role=self.user_name, content=task
989
+ ),
990
+ lambda: (
991
+ self.plan(task) if self.plan_enabled else None
992
+ ),
993
+ ]
962
994
 
963
- # Plan
964
- if self.plan_enabled is True:
965
- self.plan(task)
995
+ # Execute setup tasks concurrently
996
+ with ThreadPoolExecutor(
997
+ max_workers=len(setup_tasks)
998
+ ) as executor:
999
+ executor.map(lambda f: f(), setup_tasks)
966
1000
 
967
1001
  # Set the loop count
968
1002
  loop_count = 0
@@ -1035,15 +1069,31 @@ class Agent:
1035
1069
  # Convert to a str if the response is not a str
1036
1070
  response = self.parse_llm_output(response)
1037
1071
 
1038
- self.short_memory.add(
1039
- role=self.agent_name, content=response
1040
- )
1072
+ # self.short_memory.add(
1073
+ # role=self.agent_name, content=response
1074
+ # )
1075
+
1076
+ # # Print
1077
+ # self.pretty_print(response, loop_count)
1078
+
1079
+ # # Output Cleaner
1080
+ # self.output_cleaner_op(response)
1041
1081
 
1042
- # Print
1043
- self.pretty_print(response, loop_count)
1082
+ # 9. Batch memory updates and prints
1083
+ update_tasks = [
1084
+ lambda: self.short_memory.add(
1085
+ role=self.agent_name, content=response
1086
+ ),
1087
+ lambda: self.pretty_print(
1088
+ response, loop_count
1089
+ ),
1090
+ lambda: self.output_cleaner_op(response),
1091
+ ]
1044
1092
 
1045
- # Output Cleaner
1046
- self.output_cleaner_op(response)
1093
+ with ThreadPoolExecutor(
1094
+ max_workers=len(update_tasks)
1095
+ ) as executor:
1096
+ executor.map(lambda f: f(), update_tasks)
1047
1097
 
1048
1098
  # Check and execute tools
1049
1099
  if self.tools is not None:
@@ -1120,7 +1170,7 @@ class Agent:
1120
1170
  break
1121
1171
 
1122
1172
  if self.interactive:
1123
- logger.info("Interactive mode enabled.")
1173
+ # logger.info("Interactive mode enabled.")
1124
1174
  user_input = input("You: ")
1125
1175
 
1126
1176
  # User-defined exit command
@@ -1147,10 +1197,21 @@ class Agent:
1147
1197
  if self.autosave is True:
1148
1198
  self.save()
1149
1199
 
1150
- log_agent_data(self.to_dict())
1200
+ # log_agent_data(self.to_dict())
1151
1201
 
1152
- if self.autosave is True:
1153
- self.save()
1202
+ # if self.autosave is True:
1203
+ # self.save()
1204
+
1205
+ # 14. Batch final operations
1206
+ final_tasks = [
1207
+ lambda: log_agent_data(self.to_dict()),
1208
+ lambda: self.save() if self.autosave else None,
1209
+ ]
1210
+
1211
+ with ThreadPoolExecutor(
1212
+ max_workers=len(final_tasks)
1213
+ ) as executor:
1214
+ executor.map(lambda f: f(), final_tasks)
1154
1215
 
1155
1216
  return history_output_formatter(
1156
1217
  self.short_memory, type=self.output_type
@@ -1212,12 +1273,6 @@ class Agent:
1212
1273
  self.run,
1213
1274
  task=task,
1214
1275
  img=img,
1215
- is_last=is_last,
1216
- device=device,
1217
- device_id=device_id,
1218
- all_cores=all_cores,
1219
- do_not_use_cluster_ops=do_not_use_cluster_ops,
1220
- all_gpus=all_gpus,
1221
1276
  *args,
1222
1277
  **kwargs,
1223
1278
  )
@@ -1253,12 +1308,7 @@ class Agent:
1253
1308
  return self.run(
1254
1309
  task=task,
1255
1310
  img=img,
1256
- is_last=is_last,
1257
- device=device,
1258
- device_id=device_id,
1259
- all_cores=all_cores,
1260
- do_not_use_cluster_ops=do_not_use_cluster_ops,
1261
- all_gpus=all_gpus * args,
1311
+ *args,
1262
1312
  **kwargs,
1263
1313
  )
1264
1314
  except Exception as error: