AutoGPT: Use watchdog to mitigate empty commands

pull/5797/head
Reinier van der Leer 2023-10-17 21:22:44 -07:00
parent 21a014790f
commit d617c3fa2f
No known key found for this signature in database
GPG Key ID: CDC1180FDAE06193
1 changed files with 21 additions and 13 deletions

View File

@ -37,20 +37,28 @@ class WatchdogMixin:
WatchdogMixin, self
).propose_action(*args, **kwargs)
if (
not self.config.big_brain
and len(self.event_history) > 1
and self.config.fast_llm != self.config.smart_llm
):
# Detect repetitive commands
previous_cycle = self.event_history.episodes[self.event_history.cursor - 1]
if (
command_name == previous_cycle.action.name
and command_args == previous_cycle.action.args
if not self.config.big_brain and self.config.fast_llm != self.config.smart_llm:
previous_command, previous_command_args = None, None
if len(self.event_history) > 1:
# Detect repetitive commands
previous_cycle = self.event_history.episodes[
self.event_history.cursor - 1
]
previous_command = previous_cycle.action.name
previous_command_args = previous_cycle.action.args
rethink_reason = ""
if not command_name:
rethink_reason = "AI did not specify a command"
elif (
command_name == previous_command
and command_args == previous_command_args
):
logger.info(
f"Repetitive command detected ({command_name}), re-thinking with SMART_LLM..."
)
rethink_reason = f"Repititive command detected ({command_name})"
if rethink_reason:
logger.info(f"{rethink_reason}, re-thinking with SMART_LLM...")
with ExitStack() as stack:
@stack.callback