diff --git a/euclid/const/function_calls.py b/euclid/const/function_calls.py index aff4c45..304de88 100644 --- a/euclid/const/function_calls.py +++ b/euclid/const/function_calls.py @@ -1,14 +1,14 @@ def process_user_stories(stories): - return stories, None + return stories def process_user_tasks(tasks): - return tasks, None + return tasks def process_os_technologies(technologies): - return technologies, None + return technologies def run_commands(commands): - return commands, None + return commands def return_array_from_prompt(name_plural, name_singular, return_var_name): return { @@ -110,6 +110,6 @@ DEVELOPMENT_PLAN = { }, }], 'functions': { - 'implement_development_plan': lambda plan: (plan, None) + 'implement_development_plan': lambda plan: plan }, } \ No newline at end of file diff --git a/euclid/helpers/AgentConvo.py b/euclid/helpers/AgentConvo.py index e43b3cd..c3a05dc 100644 --- a/euclid/helpers/AgentConvo.py +++ b/euclid/helpers/AgentConvo.py @@ -1,6 +1,5 @@ from utils.llm_connection import get_prompt, create_gpt_chat_completion from utils.utils import get_sys_message, find_role_from_step, capitalize_first_word_with_underscores -from prompts.prompts import execute_chat_prompt from logger.logger import logger from termcolor import colored @@ -59,12 +58,9 @@ class AgentConvo: def postprocess_response(self, response, function_calls): if 'function_calls' in response and function_calls is not None: - if 'send_messages_and_step' in function_calls: - response['function_calls']['arguments']['previous_messages'] = self.messages - response['function_calls']['arguments']['current_step'] = self.high_level_step - response, msgs = function_calls['functions'][response['function_calls']['name']](**response['function_calls']['arguments']) - if msgs is not None: - messages = msgs + if 'send_convo' in function_calls: + response['function_calls']['arguments']['convo'] = self + response = function_calls['functions'][response['function_calls']['name']](**response['function_calls']['arguments']) elif 'text' in response: response = response['text'] diff --git a/euclid/steps/development/development.py b/euclid/steps/development/development.py index f79f454..c6ee5f1 100644 --- a/euclid/steps/development/development.py +++ b/euclid/steps/development/development.py @@ -27,18 +27,18 @@ def implement_task(task): # development/task/step/specs.prompt pass -def execute_command_and_check_cli_response(command, timeout, previous_messages, current_step): +def execute_command_and_check_cli_response(command, timeout, convo): cli_response = execute_command(command, timeout) - response, messages = execute_chat_prompt('dev_ops/ran_command.prompt', - { 'cli_response': cli_response, 'command': command }, current_step, previous_messages) - return response, messages + response = convo.send_message('dev_ops/ran_command.prompt', + { 'cli_response': cli_response, 'command': command }) + return response -def run_command_until_success(command, timeout, previous_messages, current_step): +def run_command_until_success(command, timeout, convo): command_executed = False for _ in range(MAX_COMMAND_DEBUG_TRIES): cli_response = execute_command(command, timeout) - response, previous_messages = execute_chat_prompt('dev_ops/ran_command.prompt', - {'cli_response': cli_response, 'command': command}, current_step, previous_messages) + response = convo.send_message('dev_ops/ran_command.prompt', + {'cli_response': cli_response, 'command': command}) command_executed = response == 'DONE' if command_executed: @@ -52,7 +52,7 @@ def run_command_until_success(command, timeout, previous_messages, current_step) def set_up_environment(technologies, args): current_step = 'environment_setup' - role = find_role_from_step(current_step) + convo_os_specific_tech = AgentConvo(current_step) steps = get_progress_steps(args['app_id'], current_step) if steps and not execute_step(args['step'], current_step): @@ -77,12 +77,12 @@ def set_up_environment(technologies, args): # TODO END os_info = get_os_info() - os_specific_techologies, previous_messages = execute_chat_prompt('development/env_setup/specs.prompt', - { "os_info": os_info, "technologies": technologies }, current_step, function_calls=FILTER_OS_TECHNOLOGIES) + os_specific_techologies = convo_os_specific_tech.send_message('development/env_setup/specs.prompt', + { "os_info": os_info, "technologies": technologies }, FILTER_OS_TECHNOLOGIES) for technology in os_specific_techologies: - llm_response, previous_messages = execute_chat_prompt('development/env_setup/install_next_technology.prompt', - { 'technology': technology}, current_step, previous_messages, function_calls={ + llm_response = convo_os_specific_tech.send_message('development/env_setup/install_next_technology.prompt', + { 'technology': technology}, { 'definitions': [{ 'name': 'execute_command', 'description': f'Executes a command that should check if {technology} is installed on the machine. ', @@ -104,12 +104,12 @@ def set_up_environment(technologies, args): 'functions': { 'execute_command': execute_command_and_check_cli_response }, - 'send_messages_and_step': True + 'send_convo': True }) if not llm_response == 'DONE': - installation_commands, previous_messages = execute_chat_prompt('development/env_setup/unsuccessful_installation.prompt', - { 'technology': technology }, current_step, previous_messages, function_calls={ + installation_commands = convo_os_specific_tech.send_message('development/env_setup/unsuccessful_installation.prompt', + { 'technology': technology }, { 'definitions': [{ 'name': 'execute_commands', 'description': f'Executes a list of commands that should install the {technology} on the machine. ', @@ -138,15 +138,12 @@ def set_up_environment(technologies, args): }, }], 'functions': { - 'execute_commands': lambda commands: (commands, None) + 'execute_commands': lambda commands: commands } }) if installation_commands is not None: for cmd in installation_commands: - run_command_until_success(cmd['command'], cmd['timeout'], previous_messages, current_step) - - - + run_command_until_success(cmd['command'], cmd['timeout'], convo_os_specific_tech) logger.info('The entire tech stack neede is installed and ready to be used.')