From f5bc046e1ce44a54acdbfc1e54bf2daecae66494 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Thu, 3 Aug 2023 11:19:15 +0200 Subject: [PATCH] Fixed code changes prompt for Code Monkey --- euclid/const/function_calls.py | 46 +++++++++++++++++++ euclid/helpers/agents/CodeMonkey.py | 7 +-- .../task/break_down_code_changes.prompt | 9 ++++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/euclid/const/function_calls.py b/euclid/const/function_calls.py index f487c60..88e3a55 100644 --- a/euclid/const/function_calls.py +++ b/euclid/const/function_calls.py @@ -178,6 +178,52 @@ DEV_STEPS = { }, } +CODE_CHANGES = { + 'definitions': [ + { + 'name': 'break_down_development_task', + 'description': 'Implements all the smaller tasks that need to be done to complete the entire development task.', + 'parameters': { + 'type': 'object', + "properties": { + "tasks": { + 'type': 'array', + 'description': 'List of smaller development steps that need to be done to complete the entire task.', + 'items': { + 'type': 'object', + 'description': 'A smaller development step that needs to be done to complete the entire task. Remember, if you need to run a command that doesnt\'t finish by itself (eg. a command to run an app), put the timeout to 3 seconds.', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['command', 'code_change'], + 'description': 'Type of the development step that needs to be done to complete the entire task - it can be "command" or "code_change".', + }, + 'command': { + 'type': 'string', + 'description': 'Command that needs to be run to complete the current task. This should be used only if the task is of a type "command".', + }, + 'command_timeout': { + 'type': 'number', + 'description': 'Timeout in seconds that represent the approximate time the command takes to finish. This should be used only if the task is of a type "command". If you need to run a command that doesnt\'t finish by itself (eg. a command to run an app), put the timeout to 3 seconds.', + }, + 'code_change_description': { + 'type': 'string', + 'description': 'Description of a the development step that needs to be done. This should be used only if the task is of a type "code_change" and it should thoroughly describe what needs to be done to implement the code change.', + }, + }, + 'required': ['type'], + } + } + }, + "required": ['tasks'], + }, + } + ], + 'functions': { + 'break_down_development_task': lambda tasks: tasks, + }, +} + DEVELOPMENT_PLAN = { 'definitions': [{ 'name': 'implement_development_plan', diff --git a/euclid/helpers/agents/CodeMonkey.py b/euclid/helpers/agents/CodeMonkey.py index dddb943..bcbda4c 100644 --- a/euclid/helpers/agents/CodeMonkey.py +++ b/euclid/helpers/agents/CodeMonkey.py @@ -1,4 +1,4 @@ -from const.function_calls import GET_FILES, DEV_STEPS, IMPLEMENT_CHANGES +from const.function_calls import GET_FILES, DEV_STEPS, IMPLEMENT_CHANGES, CODE_CHANGES from helpers.files import update_file from helpers.cli import run_command_until_success from helpers.cli import build_directory_tree @@ -12,10 +12,11 @@ class CodeMonkey(Agent): def implement_code_changes(self, code_changes_description): convo = AgentConvo(self) - steps, type = convo.send_message('development/task/break_down_code_changes.prompt', { + steps = convo.send_message('development/task/break_down_code_changes.prompt', { "instructions": code_changes_description, "directory_tree": self.project.get_directory_tree(), - }, DEV_STEPS) + "technologies": self.project.architecture + }, CODE_CHANGES) convo.save_branch('after_code_changes_breakdown') diff --git a/euclid/prompts/development/task/break_down_code_changes.prompt b/euclid/prompts/development/task/break_down_code_changes.prompt index 2c2d1f2..fbda8dc 100644 --- a/euclid/prompts/development/task/break_down_code_changes.prompt +++ b/euclid/prompts/development/task/break_down_code_changes.prompt @@ -8,6 +8,13 @@ Here is the current folder tree: {{ directory_tree }} ``` +Here are technologies that you can use: +``` +{% for technology in technologies %} +- {{ technology }} +{% endfor %} +``` + First, you need to break down these instructions into actionable steps that can be made. There are 2 types of steps. If a step requires a change in a file content, that step is of a type `code_change` and if a change requires a command to be run (eg. to create a file or a folder), that step is of a type `run_command`. For a step to be actionable, it cannot have a vague description but a clear explanation of what needs to be done to finish that step. Here are a couple of examples of good and bad steps: BAD STEP: `Set up mongo database` @@ -17,4 +24,6 @@ When thinking about steps, first think about what files need to changed to finis So, each step of type `code_change` can contain ALL changes that need to be made to a single file. If changes need to be made to multiple different files, they need to be split across multiple steps where each step contains all changes that need ot be made to a single file. +Remember, all commands will be run from the project root folder. + Now, think step by step and return a list of steps that need to be run. \ No newline at end of file