mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
Merge pull request #1016 from josephcmiller2/continuous-mode-limit
Continuous mode limit
This commit is contained in:
@@ -36,6 +36,7 @@ class Config(metaclass=Singleton):
|
|||||||
"""Initialize the Config class"""
|
"""Initialize the Config class"""
|
||||||
self.debug_mode = False
|
self.debug_mode = False
|
||||||
self.continuous_mode = False
|
self.continuous_mode = False
|
||||||
|
self.continuous_limit = 0
|
||||||
self.speak_mode = False
|
self.speak_mode = False
|
||||||
|
|
||||||
self.fast_llm_model = os.getenv("FAST_LLM_MODEL", "gpt-3.5-turbo")
|
self.fast_llm_model = os.getenv("FAST_LLM_MODEL", "gpt-3.5-turbo")
|
||||||
@@ -129,6 +130,10 @@ class Config(metaclass=Singleton):
|
|||||||
"""Set the continuous mode value."""
|
"""Set the continuous mode value."""
|
||||||
self.continuous_mode = value
|
self.continuous_mode = value
|
||||||
|
|
||||||
|
def set_continuous_limit(self, value: int):
|
||||||
|
"""Set the continuous limit value."""
|
||||||
|
self.continuous_limit = value
|
||||||
|
|
||||||
def set_speak_mode(self, value: bool):
|
def set_speak_mode(self, value: bool):
|
||||||
"""Set the speak mode value."""
|
"""Set the speak mode value."""
|
||||||
self.speak_mode = value
|
self.speak_mode = value
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Process arguments.')
|
parser = argparse.ArgumentParser(description='Process arguments.')
|
||||||
parser.add_argument('--continuous', action='store_true', help='Enable Continuous Mode')
|
parser.add_argument('--continuous', action='store_true', help='Enable Continuous Mode')
|
||||||
|
parser.add_argument('--continuous-limit', '-l', type=int, dest="continuous_limit", help='Defines the number of times to run in continuous mode')
|
||||||
parser.add_argument('--speak', action='store_true', help='Enable Speak Mode')
|
parser.add_argument('--speak', action='store_true', help='Enable Speak Mode')
|
||||||
parser.add_argument('--debug', action='store_true', help='Enable Debug Mode')
|
parser.add_argument('--debug', action='store_true', help='Enable Debug Mode')
|
||||||
parser.add_argument('--gpt3only', action='store_true', help='Enable GPT3.5 Only Mode')
|
parser.add_argument('--gpt3only', action='store_true', help='Enable GPT3.5 Only Mode')
|
||||||
@@ -294,6 +295,17 @@ def parse_arguments():
|
|||||||
"Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk.")
|
"Continuous mode is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise. Use at your own risk.")
|
||||||
cfg.set_continuous_mode(True)
|
cfg.set_continuous_mode(True)
|
||||||
|
|
||||||
|
if args.continuous_limit:
|
||||||
|
logger.typewriter_log(
|
||||||
|
"Continuous Limit: ",
|
||||||
|
Fore.GREEN,
|
||||||
|
f"{args.continuous_limit}")
|
||||||
|
cfg.set_continuous_limit(args.continuous_limit)
|
||||||
|
|
||||||
|
# Check if continuous limit is used without continuous mode
|
||||||
|
if args.continuous_limit and not args.continuous:
|
||||||
|
parser.error("--continuous-limit can only be used with --continuous")
|
||||||
|
|
||||||
if args.speak:
|
if args.speak:
|
||||||
logger.typewriter_log("Speak Mode: ", Fore.GREEN, "ENABLED")
|
logger.typewriter_log("Speak Mode: ", Fore.GREEN, "ENABLED")
|
||||||
cfg.set_speak_mode(True)
|
cfg.set_speak_mode(True)
|
||||||
@@ -340,7 +352,14 @@ def main():
|
|||||||
memory = get_memory(cfg, init=True)
|
memory = get_memory(cfg, init=True)
|
||||||
print('Using memory of type: ' + memory.__class__.__name__)
|
print('Using memory of type: ' + memory.__class__.__name__)
|
||||||
# Interaction Loop
|
# Interaction Loop
|
||||||
|
loop_count = 0
|
||||||
while True:
|
while True:
|
||||||
|
# Discontinue if continuous limit is reached
|
||||||
|
loop_count += 1
|
||||||
|
if cfg.continuous_mode and cfg.continuous_limit > 0 and loop_count > cfg.continuous_limit:
|
||||||
|
logger.typewriter_log("Continuous Limit Reached: ", Fore.YELLOW, f"{cfg.continuous_limit}")
|
||||||
|
break
|
||||||
|
|
||||||
# Send message to AI, get response
|
# Send message to AI, get response
|
||||||
with Spinner("Thinking... "):
|
with Spinner("Thinking... "):
|
||||||
assistant_reply = chat.chat_with_ai(
|
assistant_reply = chat.chat_with_ai(
|
||||||
|
|||||||
Reference in New Issue
Block a user