From 30df15f70c5c59be3539dc004293e4f837a34573 Mon Sep 17 00:00:00 2001 From: Kye Date: Tue, 30 Apr 2024 22:20:33 -0400 Subject: [PATCH] [CLEANUP} --- pyproject.toml | 2 +- swarms/prebuilt_swarms/__init__.py | 0 swarms/prompts/aot_prompt.py | 23 +++++++++++++++++++++++ swarms/structs/agent.py | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 swarms/prebuilt_swarms/__init__.py create mode 100644 swarms/prompts/aot_prompt.py diff --git a/pyproject.toml b/pyproject.toml index babbcfcd..cd34274a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "4.8.7" +version = "4.8.8" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/prebuilt_swarms/__init__.py b/swarms/prebuilt_swarms/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/swarms/prompts/aot_prompt.py b/swarms/prompts/aot_prompt.py new file mode 100644 index 00000000..3c7c1522 --- /dev/null +++ b/swarms/prompts/aot_prompt.py @@ -0,0 +1,23 @@ +def algorithm_of_thoughts_sop(objective: str): + AOT_PROMPT = f""" + This function systematically breaks down the given objective into distinct, manageable subtasks. + It structures the problem-solving process through explicit step-by-step exploration, + using a methodical search tree approach. Key steps are numbered to guide the exploration of solutions. + + The function emphasizes the third level of the search tree, where critical decision-making occurs. + Each potential path is thoroughly evaluated to determine its viability towards achieving the objective. + The process includes: + - Identifying initial steps in the search tree. + - Delineating and exploring critical third-level decisions. + - Considering alternative paths if initial trials are not promising. + + The goal is to think atomically and provide solutions for each subtask identified, + leading to a conclusive final result. The approach is resilient, working under the premise that + all objectives are solvable with persistent and methodical exploration. + + ### OBJECTIVE + {objective} + ### + + """ + return AOT_PROMPT diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index e5c86734..a58a88c7 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -33,6 +33,7 @@ from swarms.tools.tool import BaseTool from swarms.utils.data_to_text import data_to_text from swarms.utils.parse_code import extract_code_from_markdown from swarms.utils.pdf_to_text import pdf_to_text +from swarms.prompts.aot_prompt import algorithm_of_thoughts_sop # Utils @@ -229,6 +230,9 @@ class Agent: list_tool_schemas: Optional[List[BaseModel]] = None, metadata_output_type: str = "json", state_save_file_type: str = "json", + chain_of_thoughts: bool = False, + algorithm_of_thoughts: bool = False, + tree_of_thoughts: bool = False, *args, **kwargs, ): @@ -297,6 +301,9 @@ class Agent: self.list_tool_schemas = list_tool_schemas self.metadata_output_type = metadata_output_type self.state_save_file_type = state_save_file_type + self.chain_of_thoughts = chain_of_thoughts + self.algorithm_of_thoughts = algorithm_of_thoughts + self.tree_of_thoughts = tree_of_thoughts # The max_loops will be set dynamically if the dynamic_loop if self.dynamic_loops: @@ -417,6 +424,13 @@ class Agent: # Description self.description = agent_description + # If the algorithm of thoughts is enabled then set the sop to the algorithm of thoughts + if self.algorithm_of_thoughts is not None: + self.short_memory.add( + role=self.agent_name, + content=algorithm_of_thoughts_sop(objective=self.task), + ) + def set_system_prompt(self, system_prompt: str): """Set the system prompt""" self.system_prompt = system_prompt