diff --git a/loopgpt/agent.py b/loopgpt/agent.py index f07d8f4..247b15d 100644 --- a/loopgpt/agent.py +++ b/loopgpt/agent.py @@ -59,6 +59,7 @@ def __init__( self.next_prompt = NEXT_PROMPT self.progress = [] self.plan = [] + self.criticism = None self.constraints = [] self.state = AgentStates.START @@ -125,6 +126,7 @@ def _get_compressed_history(self): thoughts.pop("speak", None) thoughts.pop("text", None) thoughts.pop("plan", None) + thoughts.pop("criticism", None) entry["content"] = json.dumps(respd, indent=2) hist[i] = entry except: @@ -227,6 +229,9 @@ def chat( self.plan = [plan] if isinstance(plan, list): self.plan = plan + criticism = resp.get("thoughts", {}).get("criticism") + if criticism: + self.criticism = criticism except: pass self.history.append({"role": "user", "content": message}) @@ -343,6 +348,7 @@ def clear_state(self): self.staging_tool = None self.staging_response = None self.tool_response = None + self.criticism = None self.progress = None self.state = AgentStates.START self.history.clear() @@ -361,6 +367,8 @@ def header_prompt(self): prompt.append(self.constraints_prompt()) if self.plan: prompt.append(self.plan_prompt()) + if self.criticism: + prompt.append(self.criticism_prompt()) if self.progress: prompt.append(self.progress_prompt()) return "\n".join(prompt) + "\n" @@ -379,6 +387,10 @@ def plan_prompt(self): plan = "\n".join(self.plan) return f"CURRENT PLAN:\n{plan}\n" + def criticism_prompt(self): + criticism = self.criticism + return f"CRITICISM: {criticism}" + def goals_prompt(self): prompt = [] prompt.append(f"GOALS:") diff --git a/loopgpt/constants.py b/loopgpt/constants.py index ca2d50a..780d34a 100644 --- a/loopgpt/constants.py +++ b/loopgpt/constants.py @@ -9,8 +9,9 @@ "thoughts": { "text": "What do you want to say to the user?", "reasoning": "Why do you want to say this?", - "progress": "- A detailed list\n - of everything you have done so far", + "progress": "- A detailed list\n - of everything you have completed so far", "plan": "- short bulleted\n- list that conveys\n- long-term plan", + "criticism": "- A detailed list\n- of potential issues or inefficiencies\n- with your plan and reasoning", "speak": "thoughts summary to say to user", }, "command": {"name": "next command in your plan", "args": {"arg name": "value"}}, diff --git a/loopgpt/loops/repl.py b/loopgpt/loops/repl.py index d28cb7c..c48eb05 100644 --- a/loopgpt/loops/repl.py +++ b/loopgpt/loops/repl.py @@ -20,6 +20,7 @@ LOOP_GPT = Fore.GREEN + "LoopGPT" REASONING = Fore.LIGHTBLUE_EX + "REASONING" PLAN = Fore.LIGHTYELLOW_EX + "PLAN" +CRITICISM = Fore.RED + "CRITICISM" PROGRESS = Fore.LIGHTRED_EX + "PROGRESS" SPEAK = Fore.LIGHTGREEN_EX + "SPEAK" COMMAND = Fore.LIGHTMAGENTA_EX + "NEXT_COMMAND" @@ -30,6 +31,7 @@ "loopgpt": LOOP_GPT, "reasoning": REASONING, "plan": PLAN, + "criticism": CRITICISM, "progress": PROGRESS, "speak": SPEAK, "command": COMMAND, @@ -132,6 +134,8 @@ def cli(agent, continuous=False): if isinstance(thoughts["plan"], str) else thoughts["plan"] ) + if "criticism" in thoughts: + msgs["criticism"] = thoughts["criticism"] if "progress" in thoughts: msgs["progress"] = thoughts["progress"] if "speak" in thoughts: