From 6e1f7845bf25fcccc6217e5b6f1d0b737453184a Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Fri, 8 Dec 2023 20:15:15 +0000 Subject: [PATCH] fixes for extension part1 - add buttons, fix asking to debug --- pilot/helpers/agents/Developer.py | 4 ++-- pilot/helpers/cli.py | 3 +-- pilot/utils/llm_connection.py | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 039f93f7c..794618b79 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -208,7 +208,7 @@ def step_human_intervention(self, convo, step: dict): if (self.project.ipc_client_instance is None or self.project.ipc_client_instance.client is None): human_intervention_description += color_yellow_bold('\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`') else: - print(self.run_command, type="run_command") + print(self.run_command, type='run_command') response = self.project.ask_for_human_intervention('I need human intervention:', human_intervention_description, @@ -447,7 +447,7 @@ def continue_development(self, iteration_convo, last_branch_name, continue_descr if self.project.ipc_client_instance is None or self.project.ipc_client_instance.client is None: user_description += color_yellow_bold('\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`') else: - print(self.run_command, type="run_command") + print(self.run_command, type='run_command') # continue_description = '' # TODO: Wait for a specific string in the output or timeout? diff --git a/pilot/helpers/cli.py b/pilot/helpers/cli.py index 13d7d06c9..5b11b4b1e 100644 --- a/pilot/helpers/cli.py +++ b/pilot/helpers/cli.py @@ -511,8 +511,7 @@ def run_command_until_success(convo, command, 'timeout': timeout, 'command_id': command_id, 'success_message': success_message, - 'ask_before_debug': True, - }, user_input=cli_response, is_root_task=is_root_task) + },user_input=cli_response, is_root_task=is_root_task, ask_before_debug=True) return {'success': success, 'cli_response': cli_response} except TooDeepRecursionError as e: # this is only to put appropriate message in the response after TooDeepRecursionError is raised diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index cfbcd1d31..67ccc5e96 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -10,7 +10,8 @@ from jsonschema import validate, ValidationError from utils.style import color_red from typing import List -from const.llm import MIN_TOKENS_FOR_GPT_RESPONSE, MAX_GPT_MODEL_TOKENS +from const.llm import MAX_GPT_MODEL_TOKENS +from const.messages import AFFIRMATIVE_ANSWERS from logger.logger import logger, logging from helpers.exceptions import TokenLimitError, ApiKeyNotDefinedError from utils.utils import fix_json, get_prompt @@ -236,6 +237,7 @@ def wrapper(*args, **kwargs): logger.error(f'There was a problem with request to openai API: {err_str}') project = args[2] + print('yes/no', type='button') user_message = styled_text( project, 'Do you want to try make the same request again? If yes, just press ENTER. Otherwise, type "no".', @@ -247,7 +249,7 @@ def wrapper(*args, **kwargs): # TODO: take user's input into consideration - send to LLM? # https://github.com/Pythagora-io/gpt-pilot/issues/122 - if user_message != '': + if user_message.lower() not in AFFIRMATIVE_ANSWERS: return {} return wrapper