From 367d6d132bda2fa05cc51abe58ae67e5b4dc2116 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Wed, 16 Aug 2023 13:02:28 +0200 Subject: [PATCH] Changed logs and removed unused parts --- euclid/database/database.py | 5 +++-- euclid/helpers/AgentConvo.py | 5 ++--- euclid/helpers/Project.py | 11 ++--------- euclid/helpers/agents/Architect.py | 2 +- euclid/helpers/agents/Developer.py | 12 +----------- euclid/helpers/agents/ProductOwner.py | 4 ++-- euclid/helpers/agents/TechLead.py | 2 +- euclid/helpers/cli.py | 4 ++-- euclid/prompts/prompts.py | 13 ------------- euclid/utils/arguments.py | 5 ++++- 10 files changed, 18 insertions(+), 45 deletions(-) diff --git a/euclid/database/database.py b/euclid/database/database.py index 5f6c1bf..71bcf3a 100644 --- a/euclid/database/database.py +++ b/euclid/database/database.py @@ -4,6 +4,7 @@ from termcolor import colored from functools import reduce import operator from const.common import PROMPT_DATA_TO_IGNORE +from logger.logger import logger from utils.utils import hash_data from database.models.components.base_models import database @@ -185,7 +186,7 @@ def hash_and_save_step(Model, app_id, hash_data_args, data_fields, message): .execute()) record = Model.get_by_id(inserted_id) - print(colored(f"{message} with id {record.id}", "yellow")) + logger.debug(colored(f"{message} with id {record.id}", "yellow")) except IntegrityError: print(f"A record with hash_id {hash_id} already exists for {Model.__name__}.") return None @@ -272,7 +273,7 @@ def delete_all_subsequent_steps(project): def delete_subsequent_steps(model, step): if step is None: return - print(colored(f"Deleting subsequent {model.__name__} steps after {step.id}", "red")) + logger.info(colored(f"Deleting subsequent {model.__name__} steps after {step.id}", "red")) subsequent_steps = model.select().where(model.previous_step == step.id) for subsequent_step in subsequent_steps: if subsequent_step: diff --git a/euclid/helpers/AgentConvo.py b/euclid/helpers/AgentConvo.py index aa3f4c1..471e90a 100644 --- a/euclid/helpers/AgentConvo.py +++ b/euclid/helpers/AgentConvo.py @@ -89,7 +89,7 @@ class AgentConvo: # Continue conversation until GPT response equals END_RESPONSE while response != END_RESPONSE: - print(colored("Do you want to add anything else? If not, just press ENTER.", 'yellow')) + print(colored("Do you want to add anything else? If not, ", 'yellow') + colored('just press ENTER.', 'yellow', attrs=['bold'])) user_message = ask_user(self.agent.project, response, False) if user_message == "": @@ -123,8 +123,7 @@ class AgentConvo: def log_message(self, content): print_msg = capitalize_first_word_with_underscores(self.high_level_step) if self.log_to_user: - print(colored(f"{print_msg}:\n", "green")) - print(f"{content}\n") + print(colored("Dev step ", 'yellow') + colored(self.agent.project.checkpoints['last_development_step'], 'yellow', attrs=['bold']) + f"\n{content}\n") logger.info(f"{print_msg}: {content}\n") def to_playground(self): diff --git a/euclid/helpers/Project.py b/euclid/helpers/Project.py index 080ef0d..e9d1c13 100644 --- a/euclid/helpers/Project.py +++ b/euclid/helpers/Project.py @@ -183,12 +183,5 @@ class Project: if answer in cbs: return cbs[answer]() - - if answer != '' and answer != 'continue': - confirmation = styled_text( - self, - 'Do you want me to debug this by your instructions? If you mistyped and just want to continue, type "continue" and if you want me to debug this, just press ENTER', - ) - if confirmation == '': - print(colored('Ok, just a second.', "yellow")) - return answer + elif answer != '' and answer != 'continue': + return answer diff --git a/euclid/helpers/agents/Architect.py b/euclid/helpers/agents/Architect.py index 6665c7d..6237c4b 100644 --- a/euclid/helpers/agents/Architect.py +++ b/euclid/helpers/agents/Architect.py @@ -27,7 +27,7 @@ class Architect(Agent): return step['architecture'] # ARCHITECTURE - print(colored(f"Planning project architecture...\n", "green")) + print(colored(f"Planning project architecture...\n", "green", attrs=['bold'])) logger.info(f"Planning project architecture...") architecture = self.convo_architecture.send_message('architecture/technologies.prompt', diff --git a/euclid/helpers/agents/Developer.py b/euclid/helpers/agents/Developer.py index 144b058..0ada711 100644 --- a/euclid/helpers/agents/Developer.py +++ b/euclid/helpers/agents/Developer.py @@ -36,13 +36,6 @@ class Developer(Agent): logger.info('The app is DONE!!! Yay...you can use it now.') def implement_task(self): - print(colored('-------------------------', 'green', attrs=['bold'])) - # print(colored(f"Implementing task {current_task_index + 1}...\n", "green", attrs=['bold'])) - print(colored(f"Implementing task...\n", "green", attrs=['bold'])) - # print(colored(sibling_tasks[current_task_index]['description'], 'green', attrs=['bold'])) - # print(colored(task_explanation, 'green', attrs=['bold'])) - print(colored('-------------------------', 'green', attrs=['bold'])) - convo_dev_task = AgentConvo(self) task_description = convo_dev_task.send_message('development/task/breakdown.prompt', { "name": self.project.args['name'], @@ -53,9 +46,6 @@ class Developer(Agent): "technologies": self.project.architecture, "array_of_objects_to_string": array_of_objects_to_string, "directory_tree": self.project.get_directory_tree(True), - # "current_task_index": current_task_index, - # "sibling_tasks": sibling_tasks, - # "parent_task": parent_task, }) task_steps = convo_dev_task.send_message('development/parse_task.prompt', {}, IMPLEMENT_TASK) @@ -124,7 +114,7 @@ class Developer(Agent): def continue_development(self, iteration_convo): while True: user_feedback = self.project.ask_for_human_intervention( - 'Can you check if all this works? If you want to run the app, just type "r" and press ENTER', + 'Can you check if the app works?\nIf you want to run the app, ' + colored('just type "r" and press ENTER', 'yellow', attrs=['bold']), cbs={ 'r': lambda: run_command_until_success(self.run_command, None, iteration_convo, force=True) }) if user_feedback == 'DONE': diff --git a/euclid/helpers/agents/ProductOwner.py b/euclid/helpers/agents/ProductOwner.py index 96badba..c6acceb 100644 --- a/euclid/helpers/agents/ProductOwner.py +++ b/euclid/helpers/agents/ProductOwner.py @@ -72,7 +72,7 @@ class ProductOwner(Agent): # USER STORIES msg = f"Generating USER STORIES...\n" - print(colored(msg, "green")) + print(colored(msg, "green", attrs=['bold'])) logger.info(msg) self.project.user_stories = self.convo_user_stories.continuous_conversation('user_stories/specs.prompt', { @@ -106,7 +106,7 @@ class ProductOwner(Agent): # USER TASKS msg = f"Generating USER TASKS...\n" - print(colored(msg, "green")) + print(colored(msg, "green", attrs=['bold'])) logger.info(msg) self.project.user_tasks = self.convo_user_stories.continuous_conversation('user_stories/user_tasks.prompt', diff --git a/euclid/helpers/agents/TechLead.py b/euclid/helpers/agents/TechLead.py index 81bfc59..9ec5e89 100644 --- a/euclid/helpers/agents/TechLead.py +++ b/euclid/helpers/agents/TechLead.py @@ -29,7 +29,7 @@ class TechLead(Agent): return step['development_plan'] # DEVELOPMENT PLANNING - print(colored(f"Starting to create the action plan for development...\n", "green")) + print(colored(f"Starting to create the action plan for development...\n", "green", attrs=['bold'])) logger.info(f"Starting to create the action plan for development...") # TODO add clarifications diff --git a/euclid/helpers/cli.py b/euclid/helpers/cli.py index 6a6b4a1..40ad602 100644 --- a/euclid/helpers/cli.py +++ b/euclid/helpers/cli.py @@ -45,7 +45,7 @@ def execute_command(project, command, timeout=None, force=False): timeout = min(max(timeout, MIN_COMMAND_RUN_TIME), MAX_COMMAND_RUN_TIME) if not force: - print(colored(f'Can i execute the command: `{command}` with {timeout}ms timeout?', 'white', attrs=['bold'])) + print(colored(f'Can i execute the command: `') + colored(command, 'white', attrs=['bold']) + colored(f'` with {timeout}ms timeout?')) answer = styled_text( project, @@ -72,7 +72,7 @@ def execute_command(project, command, timeout=None, force=False): try: while True and return_value is None: elapsed_time = time.time() - start_time - print(colored(f'\rt: {round(elapsed_time * 1000)}ms', 'white', attrs=['bold']), end='', flush=True) + print(colored(f'\rt: {round(elapsed_time * 1000)}ms : ', 'white', attrs=['bold']), end='', flush=True) # Check if process has finished if process.poll() is not None: # Get remaining lines from the queue diff --git a/euclid/prompts/prompts.py b/euclid/prompts/prompts.py index 0b1826f..f2fe8cd 100644 --- a/euclid/prompts/prompts.py +++ b/euclid/prompts/prompts.py @@ -47,19 +47,6 @@ def ask_for_main_app_definition(project): print("No input provided!") return - while True: - confirmation = styled_text( - project, - "Do you want to add anything else? If not, just press ENTER." - ) - - if confirmation is None or confirmation == '': - break - elif description[-1] not in ['.', '!', '?', ';']: - description += '.' - - description += ' ' + confirmation - logger.info(f"Initial App description done: {description}") return description diff --git a/euclid/utils/arguments.py b/euclid/utils/arguments.py index 286596c..2546aca 100644 --- a/euclid/utils/arguments.py +++ b/euclid/utils/arguments.py @@ -1,6 +1,8 @@ import sys import uuid +from termcolor import colored + from database.database import get_app @@ -47,5 +49,6 @@ def get_arguments(): if 'step' not in arguments: arguments['step'] = None - print(f"If you wish to continue with this project in future run 'python main.py app_id={arguments['app_id']}'") + print(f"If you wish to continue with this project in future run:") + print(colored(f'python main.py app_id={arguments["app_id"]}', 'yellow', attrs=['bold'])) return arguments