From a558c9fd0462d57863f62890e3cf8f362d98cde6 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Mon, 16 Oct 2023 15:58:06 -0700 Subject: [PATCH] AutoGPT: Clean up CLI prompts --- autogpts/autogpt/autogpt/app/main.py | 4 ++-- autogpts/autogpt/autogpt/app/setup.py | 10 +++++----- autogpts/autogpt/autogpt/app/utils.py | 2 +- autogpts/autogpt/autogpt/commands/user_interaction.py | 5 ++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py index 59e4d305..b184c29b 100644 --- a/autogpts/autogpt/autogpt/app/main.py +++ b/autogpts/autogpt/autogpt/app/main.py @@ -476,7 +476,7 @@ async def get_user_feedback( console_input = await clean_input(config, "Waiting for your response...") else: console_input = await clean_input( - config, Fore.MAGENTA + "Input: " + Style.RESET_ALL + config, Fore.MAGENTA + "Input:" + Style.RESET_ALL ) # Parse user input @@ -551,7 +551,7 @@ Name: {ai_config.ai_name} Role: {ai_config.ai_role} Goals: {ai_config.ai_goals} API Budget: {"infinite" if ai_config.api_budget <= 0 else f"${ai_config.api_budget}"} -Continue ({config.authorise_key}/{config.exit_key}): """, +Continue ({config.authorise_key}/{config.exit_key}):""", ) if should_continue.lower() == config.exit_key: ai_config = AIConfig() diff --git a/autogpts/autogpt/autogpt/app/setup.py b/autogpts/autogpt/autogpt/app/setup.py index b07c8cce..06cead2e 100644 --- a/autogpts/autogpt/autogpt/app/setup.py +++ b/autogpts/autogpt/autogpt/app/setup.py @@ -60,7 +60,7 @@ async def interactive_ai_config_setup( ) user_desire = await utils.clean_input( - config, f"{Fore.LIGHTBLUE_EX}I want AutoGPT to{Style.RESET_ALL}: " + config, f"{Fore.LIGHTBLUE_EX}I want AutoGPT to{Style.RESET_ALL}:" ) if user_desire.strip() == "": @@ -125,7 +125,7 @@ async def generate_aiconfig_manual( message="For example, 'Entrepreneur-GPT'", title_color=Fore.GREEN, ) - ai_name = await utils.clean_input(config, "AI Name: ") + ai_name = await utils.clean_input(config, "AI Name:") if ai_name == "": ai_name = "Entrepreneur-GPT" @@ -145,7 +145,7 @@ async def generate_aiconfig_manual( " the sole goal of increasing your net worth.'", title_color=Fore.GREEN, ) - ai_role = await utils.clean_input(config, f"{ai_name} is: ") + ai_role = await utils.clean_input(config, f"{ai_name} is:") if ai_role == "": ai_role = "an AI designed to autonomously develop and run businesses with the" " sole goal of increasing your net worth." @@ -164,7 +164,7 @@ async def generate_aiconfig_manual( ai_goals = [] for i in range(5): ai_goal = await utils.clean_input( - config, f"{Fore.LIGHTBLUE_EX}Goal{Style.RESET_ALL} {i+1}: " + config, f"{Fore.LIGHTBLUE_EX}Goal{Style.RESET_ALL} {i+1}:" ) if ai_goal == "": break @@ -184,7 +184,7 @@ async def generate_aiconfig_manual( ) logger.info("Enter nothing to let the AI run without monetary limit") api_budget_input = await utils.clean_input( - config, f"{Fore.LIGHTBLUE_EX}Budget{Style.RESET_ALL}: $" + config, f"{Fore.LIGHTBLUE_EX}Budget ($){Style.RESET_ALL}:" ) if api_budget_input == "": api_budget = 0.0 diff --git a/autogpts/autogpt/autogpt/app/utils.py b/autogpts/autogpt/autogpt/app/utils.py index 3575490e..cfa00ff8 100644 --- a/autogpts/autogpt/autogpt/app/utils.py +++ b/autogpts/autogpt/autogpt/app/utils.py @@ -50,7 +50,7 @@ async def clean_input(config: Config, prompt: str = ""): # handle_sigint must be set to False, so the signal handler in the # autogpt/main.py could be employed properly. This referes to # https://github.com/Significant-Gravitas/AutoGPT/pull/4799/files/3966cdfd694c2a80c0333823c3bc3da090f85ed3#r1264278776 - answer = await session.prompt_async(ANSI(prompt), handle_sigint=False) + answer = await session.prompt_async(ANSI(prompt + " "), handle_sigint=False) return answer except KeyboardInterrupt: logger.info("You interrupted AutoGPT") diff --git a/autogpts/autogpt/autogpt/commands/user_interaction.py b/autogpts/autogpt/autogpt/commands/user_interaction.py index 2618f0c6..bb5055fd 100644 --- a/autogpts/autogpt/autogpt/commands/user_interaction.py +++ b/autogpts/autogpt/autogpt/commands/user_interaction.py @@ -27,7 +27,6 @@ from autogpt.core.utils.json_schema import JSONSchema enabled=lambda config: not config.noninteractive_mode, ) async def ask_user(question: str, agent: Agent) -> str: - resp = await clean_input( - agent.legacy_config, f"{agent.ai_config.ai_name} asks: '{question}': " - ) + print(f"\nQ: {question}") + resp = await clean_input(agent.legacy_config, "A:") return f"The user's answer: '{resp}'"