swarms 7.6.4__tar.gz → 7.6.6__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.4 → swarms-7.6.6}/PKG-INFO +2 -1
  2. {swarms-7.6.4 → swarms-7.6.6}/pyproject.toml +3 -1
  3. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/__init__.py +1 -3
  4. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agent.py +167 -38
  5. swarms-7.6.6/swarms/tools/mcp_integration.py +392 -0
  6. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/litellm_wrapper.py +172 -92
  7. swarms-7.6.6/swarms/utils/vllm_wrapper.py +146 -0
  8. swarms-7.6.4/swarms/structs/auto_swarm.py +0 -229
  9. swarms-7.6.4/swarms/tools/mcp_integration.py +0 -554
  10. {swarms-7.6.4 → swarms-7.6.6}/LICENSE +0 -0
  11. {swarms-7.6.4 → swarms-7.6.6}/README.md +0 -0
  12. {swarms-7.6.4 → swarms-7.6.6}/swarms/__init__.py +0 -0
  13. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/__init__.py +0 -0
  14. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/agent_judge.py +0 -0
  15. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/agent_print.py +0 -0
  16. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/ape_agent.py +0 -0
  17. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/auto_generate_swarm_config.py +0 -0
  18. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/consistency_agent.py +0 -0
  19. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/create_agents_from_yaml.py +0 -0
  20. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/flexion_agent.py +0 -0
  21. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/gkp_agent.py +0 -0
  22. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/i_agent.py +0 -0
  23. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/openai_assistant.py +0 -0
  24. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/reasoning_agents.py +0 -0
  25. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/reasoning_duo.py +0 -0
  26. {swarms-7.6.4 → swarms-7.6.6}/swarms/agents/tool_agent.py +0 -0
  27. {swarms-7.6.4 → swarms-7.6.6}/swarms/artifacts/__init__.py +0 -0
  28. {swarms-7.6.4 → swarms-7.6.6}/swarms/artifacts/main_artifact.py +0 -0
  29. {swarms-7.6.4 → swarms-7.6.6}/swarms/cli/__init__.py +0 -0
  30. {swarms-7.6.4 → swarms-7.6.6}/swarms/cli/create_agent.py +0 -0
  31. {swarms-7.6.4 → swarms-7.6.6}/swarms/cli/main.py +0 -0
  32. {swarms-7.6.4 → swarms-7.6.6}/swarms/cli/onboarding_process.py +0 -0
  33. {swarms-7.6.4 → swarms-7.6.6}/swarms/client/__init__.py +0 -0
  34. {swarms-7.6.4 → swarms-7.6.6}/swarms/client/main.py +0 -0
  35. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/__init__.py +0 -0
  36. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/accountant_swarm_prompts.py +0 -0
  37. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/ag_prompt.py +0 -0
  38. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/aga.py +0 -0
  39. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/agent_judge_prompt.py +0 -0
  40. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/agent_prompt.py +0 -0
  41. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/agent_prompts.py +0 -0
  42. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/agent_system_prompts.py +0 -0
  43. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/ai_research_team.py +0 -0
  44. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/aot_prompt.py +0 -0
  45. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/autobloggen.py +0 -0
  46. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/autoswarm.py +0 -0
  47. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/chat_prompt.py +0 -0
  48. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/code_interpreter.py +0 -0
  49. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/code_spawner.py +0 -0
  50. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/debate.py +0 -0
  51. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/documentation.py +0 -0
  52. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/education.py +0 -0
  53. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/finance_agent_prompt.py +0 -0
  54. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/finance_agent_sys_prompt.py +0 -0
  55. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/growth_agent_prompt.py +0 -0
  56. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/idea2img.py +0 -0
  57. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/legal_agent_prompt.py +0 -0
  58. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/logistics.py +0 -0
  59. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/meta_system_prompt.py +0 -0
  60. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/multi_agent_collab_prompt.py +0 -0
  61. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/multi_modal_autonomous_instruction_prompt.py +0 -0
  62. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/multi_modal_prompts.py +0 -0
  63. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/multi_modal_visual_prompts.py +0 -0
  64. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/operations_agent_prompt.py +0 -0
  65. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/personal_stylist.py +0 -0
  66. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/product_agent_prompt.py +0 -0
  67. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/programming.py +0 -0
  68. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/project_manager.py +0 -0
  69. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/prompt.py +0 -0
  70. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/prompt_generator.py +0 -0
  71. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/prompt_generator_optimizer.py +0 -0
  72. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/python.py +0 -0
  73. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/react.py +0 -0
  74. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/reasoning_prompt.py +0 -0
  75. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/refiner_agent_prompt.py +0 -0
  76. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/sales.py +0 -0
  77. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/sales_prompts.py +0 -0
  78. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/security_team.py +0 -0
  79. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/self_operating_prompt.py +0 -0
  80. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/sop_generator_agent_prompt.py +0 -0
  81. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/summaries_prompts.py +0 -0
  82. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/support_agent_prompt.py +0 -0
  83. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/swarm_manager_agent.py +0 -0
  84. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/task_assignment_prompt.py +0 -0
  85. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/tests.py +0 -0
  86. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/tools.py +0 -0
  87. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/urban_planning.py +0 -0
  88. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/visual_cot.py +0 -0
  89. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/worker_prompt.py +0 -0
  90. {swarms-7.6.4 → swarms-7.6.6}/swarms/prompts/xray_swarm_prompt.py +0 -0
  91. {swarms-7.6.4 → swarms-7.6.6}/swarms/schemas/__init__.py +0 -0
  92. {swarms-7.6.4 → swarms-7.6.6}/swarms/schemas/agent_input_schema.py +0 -0
  93. {swarms-7.6.4 → swarms-7.6.6}/swarms/schemas/agent_step_schemas.py +0 -0
  94. {swarms-7.6.4 → swarms-7.6.6}/swarms/schemas/base_schemas.py +0 -0
  95. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agent_builder.py +0 -0
  96. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agent_registry.py +0 -0
  97. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agent_roles.py +0 -0
  98. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agent_router.py +0 -0
  99. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/agents_available.py +0 -0
  100. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/async_workflow.py +0 -0
  101. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/auto_swarm_builder.py +0 -0
  102. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/base_structure.py +0 -0
  103. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/base_swarm.py +0 -0
  104. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/base_workflow.py +0 -0
  105. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/concat.py +0 -0
  106. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/concurrent_workflow.py +0 -0
  107. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/conversation.py +0 -0
  108. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/csv_to_agent.py +0 -0
  109. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/de_hallucination_swarm.py +0 -0
  110. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/deep_research_swarm.py +0 -0
  111. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/dynamic_conversational_swarm.py +0 -0
  112. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/graph_swarm.py +0 -0
  113. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/graph_workflow.py +0 -0
  114. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/groupchat.py +0 -0
  115. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/hiearchical_swarm.py +0 -0
  116. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/hybrid_hiearchical_peer_swarm.py +0 -0
  117. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/majority_voting.py +0 -0
  118. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/malt.py +0 -0
  119. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/matrix_swarm.py +0 -0
  120. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/meme_agent_persona_generator.py +0 -0
  121. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/mixture_of_agents.py +0 -0
  122. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/model_router.py +0 -0
  123. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/multi_agent_collab.py +0 -0
  124. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/multi_agent_exec.py +0 -0
  125. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/multi_agent_orchestrator.py +0 -0
  126. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/octotools.py +0 -0
  127. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/omni_agent_types.py +0 -0
  128. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/output_types.py +0 -0
  129. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/pulsar_swarm.py +0 -0
  130. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/queue_swarm.py +0 -0
  131. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/rearrange.py +0 -0
  132. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/round_robin.py +0 -0
  133. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/safe_loading.py +0 -0
  134. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/sequential_workflow.py +0 -0
  135. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/spreadsheet_swarm.py +0 -0
  136. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/stopping_conditions.py +0 -0
  137. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_arange.py +0 -0
  138. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_builder.py +0 -0
  139. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_eval.py +0 -0
  140. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_id_generator.py +0 -0
  141. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_load_balancer.py +0 -0
  142. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_matcher.py +0 -0
  143. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_output_type.py +0 -0
  144. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_registry.py +0 -0
  145. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarm_router.py +0 -0
  146. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/swarming_architectures.py +0 -0
  147. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/talk_hier.py +0 -0
  148. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/tree_swarm.py +0 -0
  149. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/utils.py +0 -0
  150. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/various_alt_swarms.py +0 -0
  151. {swarms-7.6.4 → swarms-7.6.6}/swarms/structs/workspace_manager.py +0 -0
  152. {swarms-7.6.4 → swarms-7.6.6}/swarms/telemetry/__init__.py +0 -0
  153. {swarms-7.6.4 → swarms-7.6.6}/swarms/telemetry/bootup.py +0 -0
  154. {swarms-7.6.4 → swarms-7.6.6}/swarms/telemetry/main.py +0 -0
  155. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/__init__.py +0 -0
  156. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/base_tool.py +0 -0
  157. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/cohere_func_call_schema.py +0 -0
  158. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/func_calling_utils.py +0 -0
  159. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/func_to_str.py +0 -0
  160. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/function_util.py +0 -0
  161. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/json_former.py +0 -0
  162. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/json_utils.py +0 -0
  163. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/logits_processor.py +0 -0
  164. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/openai_func_calling_schema_pydantic.py +0 -0
  165. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/openai_tool_creator_decorator.py +0 -0
  166. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/py_func_to_openai_func_str.py +0 -0
  167. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/pydantic_to_json.py +0 -0
  168. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/tool_parse_exec.py +0 -0
  169. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/tool_registry.py +0 -0
  170. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/tool_schema_base_model.py +0 -0
  171. {swarms-7.6.4 → swarms-7.6.6}/swarms/tools/tool_utils.py +0 -0
  172. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/__init__.py +0 -0
  173. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/any_to_str.py +0 -0
  174. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/auto_download_check_packages.py +0 -0
  175. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/calculate_func_metrics.py +0 -0
  176. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/data_to_text.py +0 -0
  177. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/disable_logging.py +0 -0
  178. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/file_processing.py +0 -0
  179. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/formatter.py +0 -0
  180. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/function_caller_model.py +0 -0
  181. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/history_output_formatter.py +0 -0
  182. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/litellm_tokenizer.py +0 -0
  183. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/loguru_logger.py +0 -0
  184. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/markdown_message.py +0 -0
  185. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/parse_code.py +0 -0
  186. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/pdf_to_text.py +0 -0
  187. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/str_to_dict.py +0 -0
  188. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/swarm_reliability_checks.py +0 -0
  189. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/try_except_wrapper.py +0 -0
  190. {swarms-7.6.4 → swarms-7.6.6}/swarms/utils/visualizer.py +0 -0
  191. {swarms-7.6.4 → swarms-7.6.6}/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.4
3
+ Version: 7.6.6
4
4
  Summary: Swarms - TGSC
5
5
  Home-page: https://github.com/kyegomez/swarms
6
6
  License: MIT
@@ -23,6 +23,7 @@ Requires-Dist: docstring_parser (==0.16)
23
23
  Requires-Dist: httpx
24
24
  Requires-Dist: litellm
25
25
  Requires-Dist: loguru
26
+ Requires-Dist: mcp
26
27
  Requires-Dist: networkx
27
28
  Requires-Dist: numpy
28
29
  Requires-Dist: psutil
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
5
5
 
6
6
  [tool.poetry]
7
7
  name = "swarms"
8
- version = "7.6.4"
8
+ version = "7.6.6"
9
9
  description = "Swarms - TGSC"
10
10
  license = "MIT"
11
11
  authors = ["Kye Gomez <kye@apac.ai>"]
@@ -77,6 +77,8 @@ numpy = "*"
77
77
  litellm = "*"
78
78
  torch = "*"
79
79
  httpx = "*"
80
+ mcp = "*"
81
+
80
82
  [tool.poetry.scripts]
81
83
  swarms = "swarms.cli.main:main"
82
84
 
@@ -2,7 +2,7 @@ from swarms.structs.agent import Agent
2
2
  from swarms.structs.agent_builder import AgentsBuilder
3
3
  from swarms.structs.agents_available import showcase_available_agents
4
4
  from swarms.structs.async_workflow import AsyncWorkflow
5
- from swarms.structs.auto_swarm import AutoSwarm, AutoSwarmRouter
5
+ from experimental.auto_swarm import AutoSwarm, AutoSwarmRouter
6
6
  from swarms.structs.base_structure import BaseStructure
7
7
  from swarms.structs.base_swarm import BaseSwarm
8
8
  from swarms.structs.base_workflow import BaseWorkflow
@@ -85,8 +85,6 @@ from swarms.structs.swarming_architectures import (
85
85
  __all__ = [
86
86
  "Agent",
87
87
  "AsyncWorkflow",
88
- "AutoSwarm",
89
- "AutoSwarmRouter",
90
88
  "BaseStructure",
91
89
  "BaseSwarm",
92
90
  "BaseWorkflow",
@@ -46,6 +46,11 @@ from swarms.structs.safe_loading import (
46
46
  )
47
47
  from swarms.telemetry.main import log_agent_data
48
48
  from swarms.tools.base_tool import BaseTool
49
+ from swarms.tools.mcp_integration import (
50
+ MCPServerSseParams,
51
+ batch_mcp_flow,
52
+ mcp_flow_get_tool_schema,
53
+ )
49
54
  from swarms.tools.tool_parse_exec import parse_and_execute_json
50
55
  from swarms.utils.any_to_str import any_to_str
51
56
  from swarms.utils.data_to_text import data_to_text
@@ -55,6 +60,7 @@ from swarms.utils.history_output_formatter import (
55
60
  history_output_formatter,
56
61
  )
57
62
  from swarms.utils.litellm_tokenizer import count_tokens
63
+ from swarms.utils.litellm_wrapper import LiteLLM
58
64
  from swarms.utils.pdf_to_text import pdf_to_text
59
65
  from swarms.utils.str_to_dict import str_to_dict
60
66
 
@@ -98,6 +104,51 @@ agent_output_type = Literal[
98
104
  ToolUsageType = Union[BaseModel, Dict[str, Any]]
99
105
 
100
106
 
107
+ # Agent Exceptions
108
+
109
+
110
+ class AgentError(Exception):
111
+ """Base class for all agent-related exceptions."""
112
+
113
+ pass
114
+
115
+
116
+ class AgentInitializationError(AgentError):
117
+ """Exception raised when the agent fails to initialize properly. Please check the configuration and parameters."""
118
+
119
+ pass
120
+
121
+
122
+ class AgentRunError(AgentError):
123
+ """Exception raised when the agent encounters an error during execution. Ensure that the task and environment are set up correctly."""
124
+
125
+ pass
126
+
127
+
128
+ class AgentLLMError(AgentError):
129
+ """Exception raised when there is an issue with the language model (LLM). Verify the model's availability and compatibility."""
130
+
131
+ pass
132
+
133
+
134
+ class AgentToolError(AgentError):
135
+ """Exception raised when the agent fails to utilize a tool. Check the tool's configuration and availability."""
136
+
137
+ pass
138
+
139
+
140
+ class AgentMemoryError(AgentError):
141
+ """Exception raised when the agent encounters a memory-related issue. Ensure that memory resources are properly allocated and accessible."""
142
+
143
+ pass
144
+
145
+
146
+ class AgentLLMInitializationError(AgentError):
147
+ """Exception raised when the LLM fails to initialize properly. Please check the configuration and parameters."""
148
+
149
+ pass
150
+
151
+
101
152
  # [FEAT][AGENT]
102
153
  class Agent:
103
154
  """
@@ -352,6 +403,7 @@ class Agent:
352
403
  role: agent_roles = "worker",
353
404
  no_print: bool = False,
354
405
  tools_list_dictionary: Optional[List[Dict[str, Any]]] = None,
406
+ mcp_servers: List[MCPServerSseParams] = [],
355
407
  *args,
356
408
  **kwargs,
357
409
  ):
@@ -471,6 +523,13 @@ class Agent:
471
523
  self.role = role
472
524
  self.no_print = no_print
473
525
  self.tools_list_dictionary = tools_list_dictionary
526
+ self.mcp_servers = mcp_servers
527
+ self._cached_llm = (
528
+ None # Add this line to cache the LLM instance
529
+ )
530
+ self._default_model = (
531
+ "gpt-4o-mini" # Move default model name here
532
+ )
474
533
 
475
534
  if (
476
535
  self.agent_name is not None
@@ -584,51 +643,119 @@ class Agent:
584
643
  if self.llm is None:
585
644
  self.llm = self.llm_handling()
586
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
+
587
652
  def llm_handling(self):
588
- from swarms.utils.litellm_wrapper import LiteLLM
653
+ # Use cached instance if available
654
+ if self._cached_llm is not None:
655
+ return self._cached_llm
589
656
 
590
657
  if self.model_name is None:
591
- # raise ValueError("Model name cannot be None")
592
658
  logger.warning(
593
- "Model name is not provided, using gpt-4o-mini. You can configure any model from litellm if desired."
659
+ f"Model name is not provided, using {self._default_model}. You can configure any model from litellm if desired."
594
660
  )
595
- self.model_name = "gpt-4o-mini"
661
+ self.model_name = self._default_model
596
662
 
597
663
  try:
664
+ # Simplify initialization logic
665
+ common_args = {
666
+ "model_name": self.model_name,
667
+ "temperature": self.temperature,
668
+ "max_tokens": self.max_tokens,
669
+ "system_prompt": self.system_prompt,
670
+ }
671
+
598
672
  if self.llm_args is not None:
599
- llm = LiteLLM(
600
- model_name=self.model_name, **self.llm_args
673
+ self._cached_llm = LiteLLM(
674
+ **{**common_args, **self.llm_args}
601
675
  )
602
676
  elif self.tools_list_dictionary is not None:
603
-
604
- length_of_tools_list_dictionary = len(
605
- self.tools_list_dictionary
606
- )
607
-
608
- if length_of_tools_list_dictionary > 0:
609
-
610
- parallel_tool_calls = True
611
-
612
- llm = LiteLLM(
613
- model_name=self.model_name,
614
- temperature=self.temperature,
615
- max_tokens=self.max_tokens,
616
- system_prompt=self.system_prompt,
677
+ self._cached_llm = LiteLLM(
678
+ **common_args,
617
679
  tools_list_dictionary=self.tools_list_dictionary,
618
680
  tool_choice="auto",
619
- parallel_tool_calls=parallel_tool_calls,
681
+ parallel_tool_calls=len(
682
+ self.tools_list_dictionary
683
+ )
684
+ > 1,
620
685
  )
621
686
  else:
622
- llm = LiteLLM(
623
- model_name=self.model_name,
624
- temperature=self.temperature,
625
- max_tokens=self.max_tokens,
626
- system_prompt=self.system_prompt,
627
- stream=self.streaming_on,
687
+ self._cached_llm = LiteLLM(
688
+ **common_args, stream=self.streaming_on
628
689
  )
629
- return llm
690
+
691
+ return self._cached_llm
692
+ except AgentLLMInitializationError as e:
693
+ logger.error(
694
+ f"Error in llm_handling: {e} Your current configuration is not supported. Please check the configuration and parameters."
695
+ )
696
+ return None
697
+
698
+ def mcp_execution_flow(self, response: any):
699
+ """
700
+ Executes the MCP (Model Context Protocol) flow based on the provided response.
701
+
702
+ This method takes a response, converts it from a string to a dictionary format,
703
+ and checks for the presence of a tool name or a name in the response. If either
704
+ is found, it retrieves the tool name and proceeds to call the batch_mcp_flow
705
+ function to execute the corresponding tool actions.
706
+
707
+ Args:
708
+ response (any): The response to be processed, which can be in string format
709
+ that represents a dictionary.
710
+
711
+ Returns:
712
+ The output from the batch_mcp_flow function, which contains the results of
713
+ the tool execution. If an error occurs during processing, it logs the error
714
+ and returns None.
715
+
716
+ Raises:
717
+ Exception: Logs any exceptions that occur during the execution flow.
718
+ """
719
+ try:
720
+ response = str_to_dict(response)
721
+
722
+ tool_output = batch_mcp_flow(
723
+ self.mcp_servers,
724
+ function_call=response,
725
+ )
726
+
727
+ return tool_output
630
728
  except Exception as e:
631
- logger.error(f"Error in llm_handling: {e}")
729
+ logger.error(f"Error in mcp_execution_flow: {e}")
730
+ return None
731
+
732
+ def mcp_tool_handling(self):
733
+ """
734
+ Handles the retrieval of tool schemas from the MCP servers.
735
+
736
+ This method iterates over the list of MCP servers, retrieves the tool schema
737
+ for each server using the mcp_flow_get_tool_schema function, and compiles
738
+ these schemas into a list. The resulting list is stored in the
739
+ tools_list_dictionary attribute.
740
+
741
+ Returns:
742
+ list: A list of tool schemas retrieved from the MCP servers. If an error
743
+ occurs during the retrieval process, it logs the error and returns None.
744
+
745
+ Raises:
746
+ Exception: Logs any exceptions that occur during the tool handling process.
747
+ """
748
+ try:
749
+ self.tools_list_dictionary = []
750
+
751
+ for mcp_server in self.mcp_servers:
752
+ tool_schema = mcp_flow_get_tool_schema(mcp_server)
753
+ self.tools_list_dictionary.append(tool_schema)
754
+
755
+ print(self.tools_list_dictionary)
756
+ return self.tools_list_dictionary
757
+ except Exception as e:
758
+ logger.error(f"Error in mcp_tool_handling: {e}")
632
759
  return None
633
760
 
634
761
  def setup_config(self):
@@ -2259,6 +2386,8 @@ class Agent:
2259
2386
 
2260
2387
  Args:
2261
2388
  task (str): The task to be performed by the `llm` object.
2389
+ img (str, optional): Path or URL to an image file.
2390
+ audio (str, optional): Path or URL to an audio file.
2262
2391
  *args: Variable length argument list.
2263
2392
  **kwargs: Arbitrary keyword arguments.
2264
2393
 
@@ -2270,22 +2399,22 @@ class Agent:
2270
2399
  TypeError: If task is not a string or llm object is None.
2271
2400
  ValueError: If task is empty.
2272
2401
  """
2273
- if not isinstance(task, str):
2274
- raise TypeError("Task must be a string")
2402
+ # if not isinstance(task, str):
2403
+ # task = any_to_str(task)
2275
2404
 
2276
- if task is None:
2277
- raise ValueError("Task cannot be None")
2405
+ # if img is not None:
2406
+ # kwargs['img'] = img
2278
2407
 
2279
- # if self.llm is None:
2280
- # raise TypeError("LLM object cannot be None")
2408
+ # if audio is not None:
2409
+ # kwargs['audio'] = audio
2281
2410
 
2282
2411
  try:
2283
- out = self.llm.run(task, *args, **kwargs)
2412
+ out = self.llm.run(task=task, *args, **kwargs)
2284
2413
 
2285
2414
  return out
2286
- except AttributeError as e:
2415
+ except AgentLLMError as e:
2287
2416
  logger.error(
2288
- f"Error calling LLM: {e} You need a class with a run(task: str) method"
2417
+ f"Error calling LLM: {e}. Task: {task}, Args: {args}, Kwargs: {kwargs}"
2289
2418
  )
2290
2419
  raise e
2291
2420