Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions loopgpt/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
self.next_prompt = NEXT_PROMPT
self.progress = []
self.plan = []
self.criticism = None
self.constraints = []
self.state = AgentStates.START

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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()
Expand All @@ -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"
Expand All @@ -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:")
Expand Down
3 changes: 2 additions & 1 deletion loopgpt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}},
Expand Down
4 changes: 4 additions & 0 deletions loopgpt/loops/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,6 +31,7 @@
"loopgpt": LOOP_GPT,
"reasoning": REASONING,
"plan": PLAN,
"criticism": CRITICISM,
"progress": PROGRESS,
"speak": SPEAK,
"command": COMMAND,
Expand Down Expand Up @@ -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:
Expand Down