Changed logs and removed unused parts

This commit is contained in:
Zvonimir Sabljic
2023-08-16 13:02:28 +02:00
parent 7ccec32721
commit 367d6d132b
10 changed files with 18 additions and 45 deletions

View File

@@ -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:

View File

@@ -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):

View File

@@ -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

View File

@@ -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',

View File

@@ -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':

View File

@@ -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',

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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