swarms 7.5.4__tar.gz → 7.5.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 (182) hide show
  1. {swarms-7.5.4 → swarms-7.5.6}/PKG-INFO +1 -1
  2. {swarms-7.5.4 → swarms-7.5.6}/pyproject.toml +1 -1
  3. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/__init__.py +14 -9
  4. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/consistency_agent.py +11 -13
  5. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/i_agent.py +18 -18
  6. swarms-7.5.6/swarms/agents/reasoning_agents.py +130 -0
  7. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/reasoning_duo.py +33 -8
  8. swarms-7.5.6/swarms/utils/history_output_formatter.py +14 -0
  9. {swarms-7.5.4 → swarms-7.5.6}/LICENSE +0 -0
  10. {swarms-7.5.4 → swarms-7.5.6}/README.md +0 -0
  11. {swarms-7.5.4 → swarms-7.5.6}/swarms/__init__.py +0 -0
  12. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/agent_print.py +0 -0
  13. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/ape_agent.py +0 -0
  14. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/auto_generate_swarm_config.py +0 -0
  15. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/create_agents_from_yaml.py +0 -0
  16. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/openai_assistant.py +0 -0
  17. {swarms-7.5.4 → swarms-7.5.6}/swarms/agents/tool_agent.py +0 -0
  18. {swarms-7.5.4 → swarms-7.5.6}/swarms/artifacts/__init__.py +0 -0
  19. {swarms-7.5.4 → swarms-7.5.6}/swarms/artifacts/main_artifact.py +0 -0
  20. {swarms-7.5.4 → swarms-7.5.6}/swarms/cli/__init__.py +0 -0
  21. {swarms-7.5.4 → swarms-7.5.6}/swarms/cli/create_agent.py +0 -0
  22. {swarms-7.5.4 → swarms-7.5.6}/swarms/cli/main.py +0 -0
  23. {swarms-7.5.4 → swarms-7.5.6}/swarms/cli/onboarding_process.py +0 -0
  24. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/__init__.py +0 -0
  25. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/accountant_swarm_prompts.py +0 -0
  26. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/ag_prompt.py +0 -0
  27. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/aga.py +0 -0
  28. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/agent_prompt.py +0 -0
  29. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/agent_prompts.py +0 -0
  30. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/agent_system_prompts.py +0 -0
  31. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/ai_research_team.py +0 -0
  32. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/aot_prompt.py +0 -0
  33. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/autobloggen.py +0 -0
  34. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/autoswarm.py +0 -0
  35. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/chat_prompt.py +0 -0
  36. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/code_interpreter.py +0 -0
  37. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/code_spawner.py +0 -0
  38. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/debate.py +0 -0
  39. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/documentation.py +0 -0
  40. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/education.py +0 -0
  41. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/finance_agent_prompt.py +0 -0
  42. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/finance_agent_sys_prompt.py +0 -0
  43. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/growth_agent_prompt.py +0 -0
  44. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/idea2img.py +0 -0
  45. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/legal_agent_prompt.py +0 -0
  46. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/logistics.py +0 -0
  47. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/meta_system_prompt.py +0 -0
  48. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/multi_modal_autonomous_instruction_prompt.py +0 -0
  49. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/multi_modal_prompts.py +0 -0
  50. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/multi_modal_visual_prompts.py +0 -0
  51. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/operations_agent_prompt.py +0 -0
  52. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/personal_stylist.py +0 -0
  53. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/product_agent_prompt.py +0 -0
  54. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/programming.py +0 -0
  55. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/project_manager.py +0 -0
  56. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/prompt.py +0 -0
  57. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/prompt_generator.py +0 -0
  58. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/prompt_generator_optimizer.py +0 -0
  59. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/python.py +0 -0
  60. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/react.py +0 -0
  61. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/reasoning_prompt.py +0 -0
  62. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/refiner_agent_prompt.py +0 -0
  63. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/sales.py +0 -0
  64. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/sales_prompts.py +0 -0
  65. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/security_team.py +0 -0
  66. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/self_operating_prompt.py +0 -0
  67. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/sop_generator_agent_prompt.py +0 -0
  68. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/summaries_prompts.py +0 -0
  69. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/support_agent_prompt.py +0 -0
  70. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/swarm_manager_agent.py +0 -0
  71. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/task_assignment_prompt.py +0 -0
  72. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/tests.py +0 -0
  73. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/tools.py +0 -0
  74. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/urban_planning.py +0 -0
  75. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/visual_cot.py +0 -0
  76. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/worker_prompt.py +0 -0
  77. {swarms-7.5.4 → swarms-7.5.6}/swarms/prompts/xray_swarm_prompt.py +0 -0
  78. {swarms-7.5.4 → swarms-7.5.6}/swarms/schemas/__init__.py +0 -0
  79. {swarms-7.5.4 → swarms-7.5.6}/swarms/schemas/agent_input_schema.py +0 -0
  80. {swarms-7.5.4 → swarms-7.5.6}/swarms/schemas/agent_step_schemas.py +0 -0
  81. {swarms-7.5.4 → swarms-7.5.6}/swarms/schemas/base_schemas.py +0 -0
  82. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/__init__.py +0 -0
  83. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent.py +0 -0
  84. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent_builder.py +0 -0
  85. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent_registry.py +0 -0
  86. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent_roles.py +0 -0
  87. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent_router.py +0 -0
  88. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agent_security.py +0 -0
  89. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/agents_available.py +0 -0
  90. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/airflow_swarm.py +0 -0
  91. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/async_workflow.py +0 -0
  92. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/auto_swarm.py +0 -0
  93. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/auto_swarm_builder.py +0 -0
  94. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/base_structure.py +0 -0
  95. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/base_swarm.py +0 -0
  96. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/base_workflow.py +0 -0
  97. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/concat.py +0 -0
  98. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/concurrent_workflow.py +0 -0
  99. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/conversation.py +0 -0
  100. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/csv_to_agent.py +0 -0
  101. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/de_hallucination_swarm.py +0 -0
  102. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/graph_swarm.py +0 -0
  103. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/graph_workflow.py +0 -0
  104. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/groupchat.py +0 -0
  105. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/hiearchical_swarm.py +0 -0
  106. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/majority_voting.py +0 -0
  107. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/malt.py +0 -0
  108. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/matrix_swarm.py +0 -0
  109. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/meme_agent_persona_generator.py +0 -0
  110. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/mixture_of_agents.py +0 -0
  111. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/model_router.py +0 -0
  112. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/multi_agent_collab.py +0 -0
  113. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/multi_agent_exec.py +0 -0
  114. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/multi_agent_orchestrator.py +0 -0
  115. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/octotools.py +0 -0
  116. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/omni_agent_types.py +0 -0
  117. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/output_type.py +0 -0
  118. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/output_types.py +0 -0
  119. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/pulsar_swarm.py +0 -0
  120. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/queue_swarm.py +0 -0
  121. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/rearrange.py +0 -0
  122. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/round_robin.py +0 -0
  123. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/safe_loading.py +0 -0
  124. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/sequential_workflow.py +0 -0
  125. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/spreadsheet_swarm.py +0 -0
  126. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/stopping_conditions.py +0 -0
  127. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_arange.py +0 -0
  128. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_builder.py +0 -0
  129. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_eval.py +0 -0
  130. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_id_generator.py +0 -0
  131. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_load_balancer.py +0 -0
  132. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_matcher.py +0 -0
  133. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_output_type.py +0 -0
  134. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_registry.py +0 -0
  135. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarm_router.py +0 -0
  136. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarming_architectures.py +0 -0
  137. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/swarms_api.py +0 -0
  138. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/talk_hier.py +0 -0
  139. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/tree_swarm.py +0 -0
  140. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/utils.py +0 -0
  141. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/various_alt_swarms.py +0 -0
  142. {swarms-7.5.4 → swarms-7.5.6}/swarms/structs/workspace_manager.py +0 -0
  143. {swarms-7.5.4 → swarms-7.5.6}/swarms/telemetry/__init__.py +0 -0
  144. {swarms-7.5.4 → swarms-7.5.6}/swarms/telemetry/bootup.py +0 -0
  145. {swarms-7.5.4 → swarms-7.5.6}/swarms/telemetry/main.py +0 -0
  146. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/__init__.py +0 -0
  147. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/base_tool.py +0 -0
  148. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/cohere_func_call_schema.py +0 -0
  149. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/func_calling_utils.py +0 -0
  150. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/func_to_str.py +0 -0
  151. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/function_util.py +0 -0
  152. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/json_former.py +0 -0
  153. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/json_utils.py +0 -0
  154. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/logits_processor.py +0 -0
  155. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/openai_func_calling_schema_pydantic.py +0 -0
  156. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/openai_tool_creator_decorator.py +0 -0
  157. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/py_func_to_openai_func_str.py +0 -0
  158. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/pydantic_to_json.py +0 -0
  159. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/tool_parse_exec.py +0 -0
  160. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/tool_registry.py +0 -0
  161. {swarms-7.5.4 → swarms-7.5.6}/swarms/tools/tool_utils.py +0 -0
  162. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/__init__.py +0 -0
  163. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/agent_ops_check.py +0 -0
  164. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/any_to_str.py +0 -0
  165. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/auto_download_check_packages.py +0 -0
  166. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/calculate_func_metrics.py +0 -0
  167. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/data_to_text.py +0 -0
  168. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/disable_logging.py +0 -0
  169. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/file_processing.py +0 -0
  170. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/formatter.py +0 -0
  171. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/function_caller_model.py +0 -0
  172. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/litellm_tokenizer.py +0 -0
  173. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/litellm_wrapper.py +0 -0
  174. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/loguru_logger.py +0 -0
  175. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/markdown_message.py +0 -0
  176. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/pandas_utils.py +0 -0
  177. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/parse_code.py +0 -0
  178. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/pdf_to_text.py +0 -0
  179. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/swarm_reliability_checks.py +0 -0
  180. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/try_except_wrapper.py +0 -0
  181. {swarms-7.5.4 → swarms-7.5.6}/swarms/utils/visualizer.py +0 -0
  182. {swarms-7.5.4 → swarms-7.5.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.5.4
3
+ Version: 7.5.6
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.5.4"
8
+ version = "7.5.6"
9
9
  description = "Swarms - TGSC"
10
10
  license = "MIT"
11
11
  authors = ["Kye Gomez <kye@apac.ai>"]
@@ -1,3 +1,15 @@
1
+ from swarms.agents.consistency_agent import SelfConsistencyAgent
2
+
3
+ # from swarms.agents.tool_agent import ToolAgent
4
+ from swarms.agents.create_agents_from_yaml import (
5
+ create_agents_from_yaml,
6
+ )
7
+ from swarms.agents.i_agent import IterativeReflectiveExpansion
8
+ from swarms.agents.reasoning_agents import (
9
+ ReasoningAgentRouter,
10
+ agent_types as reasoning_agent_types,
11
+ )
12
+ from swarms.agents.reasoning_duo import ReasoningDuo
1
13
  from swarms.structs.stopping_conditions import (
2
14
  check_cancelled,
3
15
  check_complete,
@@ -11,15 +23,6 @@ from swarms.structs.stopping_conditions import (
11
23
  check_success,
12
24
  )
13
25
 
14
- # from swarms.agents.tool_agent import ToolAgent
15
- from swarms.agents.create_agents_from_yaml import (
16
- create_agents_from_yaml,
17
- )
18
-
19
- from swarms.agents.i_agent import IterativeReflectiveExpansion
20
- from swarms.agents.consistency_agent import SelfConsistencyAgent
21
- from swarms.agents.reasoning_duo import ReasoningDuo
22
-
23
26
  __all__ = [
24
27
  # "ToolAgent",
25
28
  "check_done",
@@ -36,4 +39,6 @@ __all__ = [
36
39
  "IterativeReflectiveExpansion",
37
40
  "SelfConsistencyAgent",
38
41
  "ReasoningDuo",
42
+ "ReasoningAgentRouter",
43
+ "reasoning_agent_types",
39
44
  ]
@@ -7,7 +7,11 @@ from loguru import logger
7
7
  from swarms.structs.agent import Agent
8
8
  from swarms.structs.conversation import Conversation
9
9
  from swarms.structs.malt import majority_voting_prompt
10
+ from swarms.structs.output_types import OutputType
10
11
  from swarms.utils.any_to_str import any_to_str
12
+ from swarms.utils.history_output_formatter import (
13
+ history_output_formatter,
14
+ )
11
15
 
12
16
  CONSISTENCY_SYSTEM_PROMPT = """
13
17
  You are a reasoning agent designed for complex problem-solving and decision-making. Your objective is to provide clear and reliable responses through structured reasoning. Begin by thoroughly understanding the problem, rephrasing it for clarity, and identifying key components. Develop a logical plan that breaks the problem into manageable steps, detailing your approach and any assumptions made. Validate your information with reliable sources and assess the accuracy of your calculations. Explore multiple solutions, weighing their pros and cons, and maintain transparency by documenting your reasoning process, uncertainties, and biases. Summarize your findings in a concise final answer that reflects your thorough analysis, ensuring it is well-organized and accessible. Adapt your reasoning to the context of the problem, integrating new information as needed, and implement error-handling strategies to address any issues that arise. Finally, reflect on your reasoning process to identify areas for improvement and ensure consistency across all reasoning paths.
@@ -42,13 +46,12 @@ class SelfConsistencyAgent(Agent):
42
46
  self,
43
47
  name: str = "Self-Consistency-Agent",
44
48
  description: str = "An agent that uses self consistency to generate a final answer.",
49
+ system_prompt: str = CONSISTENCY_SYSTEM_PROMPT,
45
50
  num_samples: int = 5,
46
- return_list: bool = False,
47
51
  max_loops: int = 1,
48
- return_dict: bool = False,
49
- return_json: bool = False,
50
52
  majority_voting_prompt: str = None,
51
53
  eval: bool = False,
54
+ output_type: OutputType = "dict",
52
55
  **kwargs,
53
56
  ):
54
57
  """
@@ -61,17 +64,15 @@ class SelfConsistencyAgent(Agent):
61
64
  super().__init__(
62
65
  name=name,
63
66
  description=description,
64
- system_prompt=CONSISTENCY_SYSTEM_PROMPT,
65
67
  **kwargs,
66
68
  )
67
69
  self.num_samples = num_samples
68
70
  self.conversation = Conversation()
69
- self.return_list = return_list
70
71
  self.max_loops = max_loops
71
- self.return_dict = return_dict
72
- self.return_json = return_json
73
72
  self.majority_voting_prompt = majority_voting_prompt
74
73
  self.eval = eval
74
+ self.output_type = output_type
75
+ self.system_prompt = system_prompt
75
76
 
76
77
  def run(
77
78
  self, task: str, answer: str = None, *args, **kwargs
@@ -124,12 +125,9 @@ class SelfConsistencyAgent(Agent):
124
125
  role="Majority Voting Agent", content=final_answer
125
126
  )
126
127
 
127
- if self.return_list:
128
- self.conversation.return_messages_as_list()
129
- elif self.return_dict:
130
- self.conversation.return_json()
131
- else:
132
- return final_answer
128
+ return history_output_formatter(
129
+ self.conversation, self.output_type
130
+ )
133
131
 
134
132
  def aggregate(self, responses: List[str]) -> str:
135
133
  """
@@ -22,6 +22,10 @@ from typing import List, Tuple
22
22
  from loguru import logger
23
23
  from swarms.structs.agent import Agent
24
24
  from swarms.structs.conversation import Conversation
25
+ from swarms.structs.output_types import OutputType
26
+ from swarms.utils.history_output_formatter import (
27
+ history_output_formatter,
28
+ )
25
29
 
26
30
  # Define a new system prompt for general problem solving
27
31
  GENERAL_REASONING_AGENT_SYS_PROMPT = """
@@ -43,12 +47,13 @@ class IterativeReflectiveExpansion:
43
47
 
44
48
  def __init__(
45
49
  self,
50
+ agent_name: str = "General-Reasoning-Agent",
51
+ description: str = "A reasoning agent that can answer questions and help with tasks.",
46
52
  agent: Agent = None,
47
53
  max_iterations: int = 5,
48
- return_list: bool = False,
49
- return_dict: bool = False,
50
- prompt: str = GENERAL_REASONING_AGENT_SYS_PROMPT,
54
+ system_prompt: str = GENERAL_REASONING_AGENT_SYS_PROMPT,
51
55
  model_name: str = "gpt-4o-mini",
56
+ output_type: OutputType = "dict",
52
57
  ) -> None:
53
58
  """
54
59
  Initialize the Iterative Reflective Expansion engine.
@@ -56,16 +61,17 @@ class IterativeReflectiveExpansion:
56
61
  :param agent: The Swarms agent instance used to perform reasoning tasks.
57
62
  :param max_iterations: Maximum number of iterations for the reasoning process.
58
63
  """
64
+ self.agent_name = agent_name
65
+ self.description = description
59
66
  self.agent = agent
60
67
  self.max_iterations = max_iterations
61
- self.return_list = return_list
62
- self.return_dict = return_dict
63
-
68
+ self.output_type = output_type
69
+ self.system_prompt = system_prompt
64
70
  self.conversation = Conversation()
65
71
 
66
72
  self.agent = Agent(
67
- agent_name="General-Reasoning-Agent",
68
- system_prompt=prompt,
73
+ agent_name=self.agent_name,
74
+ system_prompt=self.system_prompt,
69
75
  model_name=model_name,
70
76
  max_loops=1,
71
77
  dynamic_temperature_enabled=True,
@@ -273,18 +279,12 @@ class IterativeReflectiveExpansion:
273
279
  f"Candidate paths for next iteration: {candidate_paths}"
274
280
  )
275
281
 
276
- final_solution = self.synthesize_solution(
277
- candidate_paths, memory_pool
278
- )
282
+ self.synthesize_solution(candidate_paths, memory_pool)
279
283
  logger.info("Final solution generated.")
280
284
 
281
- if self.return_list:
282
- return self.conversation.return_messages_as_list()
283
- elif self.return_dict:
284
- return self.conversation.return_messages_as_dict()
285
-
286
- else:
287
- return final_solution
285
+ return history_output_formatter(
286
+ self.conversation, self.output_type
287
+ )
288
288
 
289
289
 
290
290
  # def main() -> None:
@@ -0,0 +1,130 @@
1
+ from typing import List, Literal
2
+
3
+ from swarms.agents.consistency_agent import SelfConsistencyAgent
4
+ from swarms.agents.i_agent import (
5
+ IterativeReflectiveExpansion as IREAgent,
6
+ )
7
+ from swarms.agents.reasoning_duo import ReasoningDuo
8
+ from swarms.structs.output_types import OutputType
9
+
10
+ agent_types = Literal[
11
+ "reasoning-duo",
12
+ "self-consistency",
13
+ "ire",
14
+ "reasoning-agent",
15
+ "consistency-agent",
16
+ "ire-agent",
17
+ ]
18
+
19
+
20
+ class ReasoningAgentRouter:
21
+ """
22
+ A Reasoning Agent that can answer questions and assist with various tasks using different reasoning strategies.
23
+
24
+ Attributes:
25
+ agent_name (str): The name of the agent.
26
+ description (str): A brief description of the agent's capabilities.
27
+ model_name (str): The name of the model used for reasoning.
28
+ system_prompt (str): The prompt that guides the agent's reasoning process.
29
+ max_loops (int): The maximum number of loops for the reasoning process.
30
+ swarm_type (agent_types): The type of reasoning swarm to use (e.g., reasoning duo, self-consistency, IRE).
31
+ num_samples (int): The number of samples to generate for self-consistency agents.
32
+ output_type (OutputType): The format of the output (e.g., dict, list).
33
+ """
34
+
35
+ def __init__(
36
+ self,
37
+ agent_name: str = "reasoning_agent",
38
+ description: str = "A reasoning agent that can answer questions and help with tasks.",
39
+ model_name: str = "gpt-4o-mini",
40
+ system_prompt: str = "You are a helpful assistant that can answer questions and help with tasks.",
41
+ max_loops: int = 1,
42
+ swarm_type: agent_types = "reasoning_duo",
43
+ num_samples: int = 1,
44
+ output_type: OutputType = "dict",
45
+ ):
46
+ self.agent_name = agent_name
47
+ self.description = description
48
+ self.model_name = model_name
49
+ self.system_prompt = system_prompt
50
+ self.max_loops = max_loops
51
+ self.swarm_type = swarm_type
52
+ self.num_samples = num_samples
53
+ self.output_type = output_type
54
+
55
+ def select_swarm(self):
56
+ """
57
+ Selects and initializes the appropriate reasoning swarm based on the specified swarm type.
58
+
59
+ Returns:
60
+ An instance of the selected reasoning swarm.
61
+ """
62
+ if (
63
+ self.swarm_type == "reasoning-duo"
64
+ or self.swarm_type == "reasoning-agent"
65
+ ):
66
+ return ReasoningDuo(
67
+ agent_name=self.agent_name,
68
+ agent_description=self.description,
69
+ model_name=[self.model_name, self.model_name],
70
+ system_prompt=self.system_prompt,
71
+ output_type=self.output_type,
72
+ )
73
+
74
+ elif (
75
+ self.swarm_type == "self-consistency"
76
+ or self.swarm_type == "consistency-agent"
77
+ ):
78
+ return SelfConsistencyAgent(
79
+ agent_name=self.agent_name,
80
+ description=self.description,
81
+ model_name=self.model_name,
82
+ system_prompt=self.system_prompt,
83
+ max_loops=self.max_loops,
84
+ num_samples=self.num_samples,
85
+ output_type=self.output_type,
86
+ )
87
+
88
+ elif (
89
+ self.swarm_type == "ire" or self.swarm_type == "ire-agent"
90
+ ):
91
+ return IREAgent(
92
+ agent_name=self.agent_name,
93
+ description=self.description,
94
+ model_name=self.model_name,
95
+ system_prompt=self.system_prompt,
96
+ max_loops=self.max_loops,
97
+ max_iterations=self.num_samples,
98
+ output_type=self.output_type,
99
+ )
100
+
101
+ else:
102
+ raise ValueError(f"Invalid swarm type: {self.swarm_type}")
103
+
104
+ def run(self, task: str, *args, **kwargs):
105
+ """
106
+ Executes the selected swarm's reasoning process on the given task.
107
+
108
+ Args:
109
+ task (str): The task or question to be processed by the reasoning agent.
110
+
111
+ Returns:
112
+ The result of the reasoning process.
113
+ """
114
+ swarm = self.select_swarm()
115
+ return swarm.run(task=task)
116
+
117
+ def batched_run(self, tasks: List[str], *args, **kwargs):
118
+ """
119
+ Executes the reasoning process on a batch of tasks.
120
+
121
+ Args:
122
+ tasks (List[str]): A list of tasks to be processed.
123
+
124
+ Returns:
125
+ List of results from the reasoning process for each task.
126
+ """
127
+ results = []
128
+ for task in tasks:
129
+ results.append(self.run(task, *args, **kwargs))
130
+ return results
@@ -4,6 +4,11 @@ from loguru import logger
4
4
 
5
5
  from swarms.prompts.reasoning_prompt import REASONING_PROMPT
6
6
  from swarms.structs.agent import Agent
7
+ from swarms.structs.output_types import OutputType
8
+ from swarms.structs.conversation import Conversation
9
+ from swarms.utils.history_output_formatter import (
10
+ history_output_formatter,
11
+ )
7
12
 
8
13
 
9
14
  class ReasoningDuo:
@@ -21,14 +26,19 @@ class ReasoningDuo:
21
26
 
22
27
  def __init__(
23
28
  self,
24
- model_name: str = "reasoning-agent-01",
29
+ agent_name: str = "reasoning-agent-01",
30
+ agent_description: str = "A highly intelligent and thoughtful AI designed to provide accurate and well-reasoned answers to the user's questions.",
31
+ model_name: str = "gpt-4o-mini",
25
32
  description: str = "A highly intelligent and thoughtful AI designed to provide accurate and well-reasoned answers to the user's questions.",
26
33
  model_names: list[str] = ["gpt-4o-mini", "gpt-4o"],
27
34
  system_prompt: str = "You are a helpful assistant that can answer questions and help with tasks.",
35
+ output_type: OutputType = "dict",
28
36
  ):
37
+ self.agent_name = agent_name
38
+ self.agent_description = agent_description
29
39
  self.model_name = model_name
30
40
  self.description = description
31
-
41
+ self.output_type = output_type
32
42
  self.reasoning_agent = Agent(
33
43
  agent_name="Your",
34
44
  description="A highly intelligent and thoughtful AI designed to provide accurate and well-reasoned answers to the user's questions.",
@@ -39,14 +49,16 @@ class ReasoningDuo:
39
49
  )
40
50
 
41
51
  self.main_agent = Agent(
42
- agent_name="Main Agent",
43
- description="A highly intelligent and thoughtful AI designed to provide accurate and well-reasoned answers to the user's questions.",
52
+ agent_name=self.agent_name,
53
+ description=self.agent_description,
44
54
  system_prompt=system_prompt,
45
55
  max_loops=1,
46
56
  model_name=model_names[1],
47
57
  dynamic_temperature_enabled=True,
48
58
  )
49
59
 
60
+ self.conversation = Conversation()
61
+
50
62
  def run(self, task: str):
51
63
  """
52
64
  Executes the reasoning and main agents on the provided task.
@@ -58,14 +70,27 @@ class ReasoningDuo:
58
70
  str: The output from the main agent after processing the task.
59
71
  """
60
72
  logger.info(f"Running task: {task}")
73
+
74
+ self.conversation.add(role="user", content=task)
75
+
61
76
  output_reasoner = self.reasoning_agent.run(task)
62
77
 
63
- output_main = self.main_agent.run(
64
- f"Task: {task} \n\n Your thoughts: {output_reasoner}"
78
+ self.conversation.add(
79
+ role=self.reasoning_agent.agent_name,
80
+ content=output_reasoner,
65
81
  )
66
82
 
67
- logger.info(f"Output from main agent: {output_main}")
68
- return output_main
83
+ prompt = f"Task: {task} \n\n Your thoughts: {output_reasoner}"
84
+
85
+ output_main = self.main_agent.run(prompt)
86
+
87
+ self.conversation.add(
88
+ role=self.main_agent.agent_name, content=output_main
89
+ )
90
+
91
+ return history_output_formatter(
92
+ self.conversation, self.output_type
93
+ )
69
94
 
70
95
  def batched_run(self, tasks: List[str]):
71
96
  """
@@ -0,0 +1,14 @@
1
+ from swarms.structs.conversation import Conversation
2
+
3
+
4
+ def history_output_formatter(
5
+ conversation: Conversation, type: str = "list"
6
+ ):
7
+ if type == "list":
8
+ return conversation.return_messages_as_list()
9
+ elif type == "dict":
10
+ return conversation.to_dict()
11
+ elif type == "string" or type == "str":
12
+ return conversation.get_str()
13
+ else:
14
+ raise ValueError(f"Invalid type: {type}")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes