diff --git a/pilot/const/function_calls.py b/pilot/const/function_calls.py index 44c2cad9f2..2f2deb4b4b 100644 --- a/pilot/const/function_calls.py +++ b/pilot/const/function_calls.py @@ -394,7 +394,7 @@ DEVELOPMENT_PLAN = { }, 'user_review_goal': { 'type': 'string', - 'description': 'user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human', + 'description': 'User review goal that will determine if a task is done or not, but from a user perspective since it will be reviewed by a human.', } }, 'required': ['description', 'programmatic_goal', 'user_review_goal'], diff --git a/pilot/const/messages.py b/pilot/const/messages.py index 05a1321561..b3f59b3e2b 100644 --- a/pilot/const/messages.py +++ b/pilot/const/messages.py @@ -1,2 +1,4 @@ CHECK_AND_CONTINUE = 'If something is wrong, tell me or type "continue" to continue.' WHEN_USER_DONE = 'Once you\'re done, type "continue"' +AFFIRMATIVE_ANSWERS = ['', 'y', 'yes', 'ok', 'okay', 'sure'] +NEGATIVE_ANSWERS = ['n', 'no', 'skip'] \ No newline at end of file diff --git a/pilot/helpers/AgentConvo.py b/pilot/helpers/AgentConvo.py index fe434ab756..47b2045cc5 100644 --- a/pilot/helpers/AgentConvo.py +++ b/pilot/helpers/AgentConvo.py @@ -81,6 +81,7 @@ class AgentConvo: else: # if we don't, get the response from LLM try: + self.replace_files() response = create_gpt_chat_completion(self.messages, self.high_level_step, self.agent.project, function_calls=function_calls) except TokenLimitError as e: @@ -187,7 +188,7 @@ class AgentConvo: for msg in self.messages: if msg['role'] == 'user': for file in files: - msg['content'] = self.replace_file_content(msg['content'], file['path'], file['content']) + msg['content'] = self.replace_file_content(msg['content'], f"{file['path']}/{file['name']}", file['content']) def escape_specials(self, s): s = s.replace("\\", "\\\\") @@ -213,7 +214,7 @@ class AgentConvo: def replace_file_content(self, message, file_path, new_content): escaped_file_path = re.escape(file_path) - pattern = rf'\*\*{escaped_file_path}\*\*\n```\n(.*?)\n```' + pattern = rf'\*\*{escaped_file_path}\*\*:\n```\n(.*?)\n```' # Escape special characters in new_content for the sake of regex replacement new_content_escaped = self.escape_specials(new_content) diff --git a/pilot/helpers/Debugger.py b/pilot/helpers/Debugger.py index b185797ffb..76a2328107 100644 --- a/pilot/helpers/Debugger.py +++ b/pilot/helpers/Debugger.py @@ -4,9 +4,11 @@ import re from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MAX_RECUSION_LAYER from const.function_calls import DEBUG_STEPS_BREAKDOWN +from const.messages import AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS from helpers.exceptions.TokenLimitError import TokenLimitError from helpers.exceptions.TooDeepRecursionError import TooDeepRecursionError from logger.logger import logger +from prompts.prompts import ask_user class Debugger: @@ -14,7 +16,7 @@ class Debugger: self.agent = agent self.recursion_layer = 0 - def debug(self, convo, command=None, user_input=None, issue_description=None, is_root_task=False): + def debug(self, convo, command=None, user_input=None, issue_description=None, is_root_task=False, ask_before_debug=False): """ Debug a conversation. @@ -24,6 +26,7 @@ class Debugger: user_input (str, optional): User input for debugging. Default is None. Should provide `command` or `user_input`. issue_description (str, optional): Description of the issue to debug. Default is None. + ask_before_debug (bool, optional): True if we have to ask user for permission to start debugging. Returns: bool: True if debugging was successful, False otherwise. @@ -42,6 +45,14 @@ class Debugger: if success: break + if ask_before_debug or i > 0: + print('yes/no', type='button') + answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False) + if answer.lower() in NEGATIVE_ANSWERS: + return True + if answer and answer.lower() not in AFFIRMATIVE_ANSWERS: + user_input = answer + llm_response = convo.send_message('dev_ops/debug.prompt', { 'command': command['command'] if command is not None else None, diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index 07d68b3bba..7774d4b25b 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -4,7 +4,7 @@ from pathlib import Path import re from typing import Tuple -from const.messages import CHECK_AND_CONTINUE +from const.messages import CHECK_AND_CONTINUE, AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS from utils.style import color_yellow_bold, color_cyan, color_white_bold, color_green from const.common import IGNORE_FOLDERS, STEPS from database.database import delete_unconnected_steps_from, delete_all_app_development_data, update_app_status @@ -118,8 +118,9 @@ class Project: delete_all_app_development_data(self.args['app_id']) self.skip_steps = False elif self.skip_until_dev_step is not None: - should_overwrite_files = '' - while should_overwrite_files.lower() not in ['y', 'n']: + should_overwrite_files = None + while should_overwrite_files is None or should_overwrite_files.lower() not in AFFIRMATIVE_ANSWERS + NEGATIVE_ANSWERS: + print('yes/no', type='button') should_overwrite_files = styled_text( self, f'Do you want to overwrite the dev step {self.args["skip_until_dev_step"]} code with system changes? Type y/n', @@ -127,9 +128,9 @@ class Project: ) logger.info('should_overwrite_files: %s', should_overwrite_files) - if should_overwrite_files == 'n': + if should_overwrite_files in NEGATIVE_ANSWERS: break - elif should_overwrite_files == 'y': + elif should_overwrite_files in AFFIRMATIVE_ANSWERS: FileSnapshot.delete().where( FileSnapshot.app == self.app and FileSnapshot.development_step == self.skip_until_dev_step).execute() self.save_files_snapshot(self.skip_until_dev_step) @@ -273,7 +274,8 @@ class Project: for line_number, line_content in inputs_required: user_input = '' print(color_yellow_bold(f'Input required on line {line_number}:\n{line_content}') + '\n') - while user_input.lower() not in ['y']: + while user_input.lower() not in AFFIRMATIVE_ANSWERS: + print('yes', type='button') user_input = styled_text( self, f'Please open the file {data["path"]} on the line {line_number} and add the required input. Once you\'re done, type "y" to continue.', diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index bd69d17d8f..b6644b060e 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -185,7 +185,7 @@ class Developer(Agent): else: data = step['command'] # TODO END - additional_message = 'Let\'s start with the step #0:\n' if i == 0 else f'So far, steps { ", ".join(f"#{j}" for j in range(i+1)) } are finished so let\'s do step #{i + 1} now.\n' + additional_message = '' #'Let\'s start with the step #0:\n' if i == 0 else f'So far, steps { ", ".join(f"#{j}" for j in range(i+1)) } are finished so let\'s do step #{i + 1} now.\n' command_id = data['command_id'] if 'command_id' in data else None success_message = data['success_message'] if 'success_message' in data else None @@ -220,7 +220,7 @@ class Developer(Agent): 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, @@ -459,7 +459,7 @@ class Developer(Agent): 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? @@ -500,8 +500,6 @@ class Developer(Agent): "user_input": user_feedback, }) - # self.debugger.debug(iteration_convo, user_input=user_feedback) - llm_response = iteration_convo.send_message('development/parse_task.prompt', { 'running_processes': running_processes, 'os': platform.system(), diff --git a/pilot/helpers/agents/TechLead.py b/pilot/helpers/agents/TechLead.py index ff19ab917f..1f3c06d475 100644 --- a/pilot/helpers/agents/TechLead.py +++ b/pilot/helpers/agents/TechLead.py @@ -39,7 +39,8 @@ class TechLead(Agent): "clarifications": self.project.clarifications, "user_stories": self.project.user_stories, "user_tasks": self.project.user_tasks, - "technologies": self.project.architecture + "technologies": self.project.architecture, + "task_type": 'app', }, DEVELOPMENT_PLAN) self.project.development_plan = llm_response['plan'] @@ -69,6 +70,7 @@ class TechLead(Agent): "files": self.project.get_all_coded_files(), "previous_features": previous_features, "feature_description": feature_description, + "task_type": 'feature', }, DEVELOPMENT_PLAN) self.project.development_plan = llm_response['plan'] diff --git a/pilot/helpers/cli.py b/pilot/helpers/cli.py index 2b861bb79a..5b11b4b1e7 100644 --- a/pilot/helpers/cli.py +++ b/pilot/helpers/cli.py @@ -16,6 +16,7 @@ from helpers.exceptions.TokenLimitError import TokenLimitError from helpers.exceptions.CommandFinishedEarly import CommandFinishedEarly from prompts.prompts import ask_user from const.code_execution import MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH +from const.messages import AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS interrupted = False @@ -215,9 +216,9 @@ def execute_command(project, command, timeout=None, success_message=None, comman 'successfully executed.', False, hint=question) # TODO can we use .confirm(question, default='yes').ask() https://questionary.readthedocs.io/en/stable/pages/types.html#confirmation print('answer: ' + answer) - if answer.lower() in ['n', 'no', 'skip']: + if answer.lower() in NEGATIVE_ANSWERS: return None, 'SKIP', None - elif answer.lower() not in ['', 'y', 'yes', 'ok', 'okay', 'sure']: + elif answer.lower() not in AFFIRMATIVE_ANSWERS: # "That's not going to work, let's do X instead" # https://github.com/Pythagora-io/gpt-pilot/issues/198 # https://github.com/Pythagora-io/gpt-pilot/issues/43#issuecomment-1756352056 @@ -510,7 +511,7 @@ def run_command_until_success(convo, command, 'timeout': timeout, 'command_id': command_id, 'success_message': success_message, - }, 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/helpers/test_Debugger.py b/pilot/helpers/test_Debugger.py index 78c932ce39..34fafda0ef 100644 --- a/pilot/helpers/test_Debugger.py +++ b/pilot/helpers/test_Debugger.py @@ -112,6 +112,7 @@ def test_debug_need_to_see_output(mock_save_step, mock_get_completion, mock_get_ debugger = Debugger(developer) convo = AgentConvo(developer) convo.load_branch = MagicMock() + convo.replace_files = MagicMock() # hard-wired LLM responses, 1st response asks to see output mock_get_completion.side_effect = [{'text': json.dumps(response)} for response in [{ 'thoughts': 'Hmmm, testing', diff --git a/pilot/prompts/architecture/technologies.prompt b/pilot/prompts/architecture/technologies.prompt index c6ba2ada7b..17127b6276 100644 --- a/pilot/prompts/architecture/technologies.prompt +++ b/pilot/prompts/architecture/technologies.prompt @@ -2,10 +2,23 @@ You are working in a software development agency and a project manager approache {{ project_details }} -Now, based on the app's description, user stories and user tasks, think step by step and list the names of the technologies that will be used by your development team to create the app "{{ name }}". Do not write any explanations behind your choices but only a list of technologies that will be used. +Now, based on the projects details, think step by step and list the names of the technologies that will be used by your development team to create the app "{{ name }}". Do not give any subjective thoughts or options, give exact technologies, for example: Instead of ["D3.js or other suitable charting library", "axios or other http client library"] answer with ["D3.js", "axios"]. You do not need to list any technologies related to automated tests (like Jest, Cypress, Mocha, Selenium, etc) or any technologies related to deployment (like Heroku). +**Project Technology Guidelines** +Relevance: Only include technologies that are essential and will be actively used in the project. Avoid mentioning any technologies that are not required. For example, don't suggest MongoDB if database is not needed for project. +Compatibility: Ensure that the listed technologies are compatible with each other. Exclude any technologies that cannot be integrated or used in conjunction with others. For example, Pandas (Python library) and Node.js can't be used together. Another example is MongoDB (NoSQL database) and MySQL (SQL database) shouldn't be used together unless that is specified in project description. +Technology Preferences: In scenarios where multiple technology options are available for a specific project component, prioritize the following preferred technologies: +- Node.js, +- MongoDB, +- PeeWee, +- Bootstrap, +- HTML, +- CSS3, +- cronjob, +- Socket.io + {{no_microservices}} diff --git a/pilot/prompts/components/project_tasks.prompt b/pilot/prompts/components/project_tasks.prompt new file mode 100644 index 0000000000..051f5c9e95 --- /dev/null +++ b/pilot/prompts/components/project_tasks.prompt @@ -0,0 +1,42 @@ +Before we go into the coding part, I want you to split the development process of creating this {{ task_type }} into smaller tasks so that it is easier to develop, debug and make the {{ task_type }} work. Each smaller task of this {{ task_type }} has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this {{ task_type }} completely. + +Each task needs to be related only to the development of this {{ task_type }} and nothing else - once the {{ task_type }} is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. + +Now, based on the project details provided{% if task_type == 'feature' %} and new feature description{% endif %}, think task by task and create the entire development plan{% if task_type == 'feature' %} for new feature{% endif %}.{% if task_type == 'app' %} Start from the project setup and specify each task until the moment when the entire app should be fully working.{% endif %} + +**IMPORTANT** +Dividing project into tasks is extremely important job and has to be done carefully while always strictly following all rules listed bellow. + +Rule #1 +There should never be a task that is only testing or ensuring something works, every task must have coding involved. Have this in mind for every task, but it is extremely important for last task of project. Testing if {{ task_type }} works will be done as part of each task. + +Rule #2 +You have to make sure the project is not split into tasks that are too small or simple for no reason but also not too big or complex so that they are hard to develop, debug and review. Here are examples of poorly created tasks: + +**too simple tasks** +- Set up a Node.js project and install all necessary dependencies. +- Establish a MongoDB database connection using Mongoose with the IP '127.0.0.1'. + +**too complex tasks** +- Set up Node.js project with /home, /profile, /register and /login routes that will have user authentication, connection to MongoDB with user schemas, mailing of new users and frontend with nice design. + +You must to avoid creating tasks that are too simple or too complex. You have to aim to create tasks that are medium complexity. Here are examples of tasks that are good: + +**good tasks** +- Set up a Node.js project, install all necessary dependencies and set up an express server with a simple route to `/ping` that returns the status 200. +- Establish a MongoDB database connection and implement the message schema using Mongoose for persistent storage of messages. + +Rule #3 +Every {{ task_type }} should have different number of tasks depending on complexity. Think task by task and create the minimum number of tasks that are relevant for this specific {{ task_type }}.{% if task_type == 'feature' %} If the feature is small, it is ok to have only 1 task.{% endif %} Here are some examples of apps with different complexity that can give you guidance on how many tasks you should create: + +Example #1: +app description: "I want to create an app that will just say 'Hello World' when I open it on my localhost:3000." +number of tasks: 1-3 + +Example #2: +app description: "Create a node.js app that enables users to register and log into the app. On frontend it should have /home (shows user data), /register and /login. It should use sessions to keep user logged in." +number of tasks: 2-6 + +Example #3: +app description: "A cool online shoe store, with a sleek look. In terms of data models, there are shoes, categories and user profiles. For web pages: product listing, details, shopping cart. It must look cool and jazzy." +number of tasks: 5-15 \ No newline at end of file diff --git a/pilot/prompts/dev_ops/debug.prompt b/pilot/prompts/dev_ops/debug.prompt index f4b98a0d6b..a3c97a02db 100644 --- a/pilot/prompts/dev_ops/debug.prompt +++ b/pilot/prompts/dev_ops/debug.prompt @@ -10,12 +10,17 @@ Here is a brief explanation of what's happening: ``` {% endif -%} {{ context }} -I want you to debug this issue by yourself using the `steps` of the `start_debugging` function. +I want you to create a list of steps that are needed to debug this issue. -`command` step will run a command on the machine and will return the CLI output to you so you can see what to do next. Note that the command will run on a {{ os }} machine. +A step can be either a `command` or `code_change`. -`code_change` step will change the code where you just need to thoroughly describe what needs to be implemented, I will implement the requested changes and let you know. When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. +`command` step will run a command on the machine and will return the CLI output to you so you can see what to do next. Note that the command will be run on a {{ os }} machine. -Return a list of steps that are needed to debug this issue. By the time we execute the last step, the issue should be fixed completely. Also, make sure that at least the last step has `check_if_fixed` set to TRUE. +`code_change` step will change the code and you need to thoroughly describe what needs to be implemented. I will implement the requested changes and let you know. + +Also, make sure that at least the last step has `check_if_fixed` set to TRUE. + +**IMPORTANT** +When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. {# After this, you need to decide what to do next. You can rerun the command `{{ command }}` to check if the problem is fixed or run another command with `run_command` or change more code with `implement_code_changes`. #} diff --git a/pilot/prompts/development/define_user_review_goal.prompt b/pilot/prompts/development/define_user_review_goal.prompt index 715f077639..7039d9f83c 100644 --- a/pilot/prompts/development/define_user_review_goal.prompt +++ b/pilot/prompts/development/define_user_review_goal.prompt @@ -1,8 +1,8 @@ -How can a human user test if this task was completed successfully? If you specify a command that needs to be run or give example, be very specific. You don't want the user to have to think anything through but rather that they just follow your instructions. Note that the command will run on a {{ os }} machine. +How can a human user test if this task was completed successfully? If you specify a command that needs to be run or give example, be very specific. You don't want the user to have to think anything through but rather that they just follow your instructions. Note that any commands will be run on a {{ os }} machine. -!IMPORTANT! +**IMPORTANT** In case the task can be tested by making an API request, do not suggest how can a request be made with Postman but rather write a full cURL command that the user can just run. -!IMPORTANT! +**IMPORTANT** Do not require any code writing form the user for testing this task. -Try your best to avoid this if possible, but if it is very difficult to test the task, you can just answer with only this sentence - `There is nothing specific to test for this task so you can write "continue" and we'll move on to the next task.` \ No newline at end of file +Try your best to avoid this if possible, but if it is very difficult to test the task, you can just answer with only this sentence - `There is nothing specific to test for this task so you can write "continue" and we'll move on to the next task.` diff --git a/pilot/prompts/development/feature_plan.prompt b/pilot/prompts/development/feature_plan.prompt index 0a694cbbf7..e1e24106e8 100644 --- a/pilot/prompts/development/feature_plan.prompt +++ b/pilot/prompts/development/feature_plan.prompt @@ -32,10 +32,4 @@ Finally, here is the description of new feature that needs to be added to {{ app {{ feature_description }} ``` -OK, now, you need to create code to have this feature fully working but before we go into the coding part, I want you to split the development process of creating this feature into smaller tasks so that it is easier to debug and make the feature work. Each smaller task of this feature has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this feature. Make sure that you do NOT split feature into tasks that are too small as well, they need to be split logically for developer to keep track of his progress. - -Each task needs to be related only to the development of this feature and nothing else - once the feature is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. Think task by task and create the minimum number of tasks that are relevant for this specific feature. If the feature is small, it is ok to have only 1 task. - -For each task, there must be a way for human developer to check if the task is done or not. Write how should the developer check if the task is done. - -Now, based on the project details provided and new feature description, think task by task and create the entire development plan for new feature. For each task, write a description and a user-review goal. +{{ project_tasks }} \ No newline at end of file diff --git a/pilot/prompts/development/get_fully_coded_file.prompt b/pilot/prompts/development/get_fully_coded_file.prompt index 030d99b8fa..2b265c3339 100644 --- a/pilot/prompts/development/get_fully_coded_file.prompt +++ b/pilot/prompts/development/get_fully_coded_file.prompt @@ -1,4 +1,4 @@ -Here is how the file `{{ file.path }}` looks like right now: +Here is how the file `{{ file.path }}/{{ file.name }}` looks like right now: ``` {{ file.content }} ``` diff --git a/pilot/prompts/development/get_snippet_from_comment.prompt b/pilot/prompts/development/get_snippet_from_comment.prompt index 90644981c9..fbe8e2dda9 100644 --- a/pilot/prompts/development/get_snippet_from_comment.prompt +++ b/pilot/prompts/development/get_snippet_from_comment.prompt @@ -1,6 +1,6 @@ Here are previously coded files: {% for file in previously_coded_files %} -**{{ file.path }}**: +**{{ file.path }}/{{ file.name }}**: ``` {{ file.content }} ``` @@ -8,7 +8,7 @@ Here are previously coded files: And here are the new implementations of these same files: {% for file in files_with_comments -%} -**{{ file.path }}**: +**{{ file.path }}/{{ file.name }}**: ``` {{ file.content }} ``` @@ -18,7 +18,7 @@ Look at the following lines of code: {% for file in files_with_comments -%} {% if file.comments|length > 0 -%} {%- for comment in file['comments'] -%} -`{{ comment }}` inside `{{ file['path'] }}` +`{{ comment }}` inside `{{ file['path'] }}/{{ file['name'] }}` {% endfor %} {%- endif -%} {%- endfor %} diff --git a/pilot/prompts/development/implement_changes.prompt b/pilot/prompts/development/implement_changes.prompt index 07b7ea2b48..5665499347 100644 --- a/pilot/prompts/development/implement_changes.prompt +++ b/pilot/prompts/development/implement_changes.prompt @@ -10,7 +10,7 @@ This task is broken down into steps. Please tell me the changes needed to implem {{ step_description }} ``` -Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Finally, you can save the modified files on the disk by calling `save_files` function. +Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Just make sure that you put comments only inside files that support comments (e.g. not in JSON files).. **IMPORTANT** When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. diff --git a/pilot/prompts/development/iteration.prompt b/pilot/prompts/development/iteration.prompt index 0c4f3fa489..c94a565e6f 100644 --- a/pilot/prompts/development/iteration.prompt +++ b/pilot/prompts/development/iteration.prompt @@ -13,7 +13,7 @@ Here are the technologies that you need to use for this project: {% if development_tasks and current_task %} Development process of this app was split into smaller tasks. Here is the list of all tasks: ```{% for task in development_tasks %} -- {{ loop.index }}. {{ task['description'] }} +{{ loop.index }}. {{ task['description'] }} {% endfor %} ``` You are currently working on task "{{ current_task.description }}" and you have to focus only on that task. diff --git a/pilot/prompts/development/parse_task.prompt b/pilot/prompts/development/parse_task.prompt index 02cdd244dc..f01d819abb 100644 --- a/pilot/prompts/development/parse_task.prompt +++ b/pilot/prompts/development/parse_task.prompt @@ -1,7 +1,7 @@ Ok, now, take your previous message and convert it to actionable items. An item might be a code change or a command run. When you need to change code, make sure that you put the entire content of the file in the value of `content` key even though you will likely copy and paste the most of the previous message. The commands must be able to run on a {{ os }} machine. **IMPORTANT** -Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Finally, you can save the modified files on the disk by calling `save_files` function. +Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Just make sure that you put comments only inside files that support comments (e.g. not in JSON files). **IMPORTANT** When you want to add a comment that tells the user to add the previous implementation at that place, make sure that the comment starts with `[OLD CODE]` and add a description of what old code should be inserted here. For example, `[OLD CODE] Login route`. diff --git a/pilot/prompts/development/plan.prompt b/pilot/prompts/development/plan.prompt index 7c39950e27..a77d8bfcca 100644 --- a/pilot/prompts/development/plan.prompt +++ b/pilot/prompts/development/plan.prompt @@ -2,10 +2,4 @@ You are working in a software development agency and a project manager and softw {{ project_details }} -OK, now, you need to create code to have this app fully working but before we go into the coding part, I want you to split the development process of creating this app into smaller tasks so that it is easier to debug and make the app work. Each smaller task of this project has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this app completely. Also, make sure it is not be split into tasks that are too small for no reason. - -Each task needs to be related only to the development of this app and nothing else - once the app is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. Think task by task and create the least number of tasks that are relevant for this specific app. - -For each task, there must be a way for human developer to check if the task is done or not. Write how should the developer check if the task is done. - -Now, based on the app's description,{% if user_stories %} user stories,{% endif %}{% if user_tasks %} user tasks,{% endif %} and the technologies that you need to use, think task by task and create the entire development plan. Start from the project setup and specify each task until the moment when the entire app should be fully working. For each task, write a description and a user-review goal. \ No newline at end of file +{{ project_tasks }} \ No newline at end of file diff --git a/pilot/prompts/development/task/breakdown.prompt b/pilot/prompts/development/task/breakdown.prompt index 646d0ac1b2..4493365800 100644 --- a/pilot/prompts/development/task/breakdown.prompt +++ b/pilot/prompts/development/task/breakdown.prompt @@ -5,7 +5,7 @@ You are working on a {{ app_type }} called "{{ name }}" and you need to write co {% if current_task_index != 0 or task_type == 'feature' %} So far, this code has been implemented: {% for file in files %} -**{{ file.path }}/{{ file.name }}** +**{{ file.path }}/{{ file.name }}**: ```{# file.language #} {{ file.content }} ``` @@ -15,11 +15,11 @@ So far, this code has been implemented: We've broken the development of this {{ task_type }} down to these tasks: ```{% for task in development_tasks %} -- {{ loop.index }}. {{ task['description'] }} +{{ loop.index }}. {{ task['description'] }} {% endfor %} ``` -You are currently working on task {{ current_task_index + 1 }} with the following description: +You are currently working on task #{{ current_task_index + 1 }} with the following description: ``` {{ development_tasks[current_task_index]['description'] }} ``` @@ -32,9 +32,10 @@ Now, tell me all the code that needs to be written to implement ONLY this task a When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. **IMPORTANT** -{% if task_type == 'app' %} +{%- if task_type == 'app' %} Remember, I created an empty folder where I will start writing files that you tell me and that are needed for this app. You do not need to make any automated tests work. {% endif %} DO NOT specify commands to create any folders or files, they will be created automatically - just specify the relative path to each file that needs to be written. + Never use the port 5000 to run the app, it's reserved. diff --git a/pilot/prompts/development/task/next_step.prompt b/pilot/prompts/development/task/next_step.prompt index 28d97ab175..f6f73fca42 100644 --- a/pilot/prompts/development/task/next_step.prompt +++ b/pilot/prompts/development/task/next_step.prompt @@ -1,13 +1,13 @@ {% if step_index != 0 %} So far, steps {{ finished_steps }} are finished so let's do {% else %} -Let's start with the{% endif %} step #{{ step_index }}: +Let's start with the{% endif %} step #{{ step_index }}. Here is the description of this step: ``` {{ step_description }} ``` -This step by step about what needs to be done to fulfill this step. +Think step by step about what needs to be done to fulfill this step. {% if step_type == 'COMMAND' %} -Respond with all commands that need to be run to fulfill this step. In case this is a complex step that can't be completed by only running commands (maybe it requires some code changes or user review), respond with an array with only one item `COMPLEX`. Like this - `[{"command": "COMPLEX", "timeout": 0}]` +Respond with all commands that need to be run to fulfill this step. {% elif step_type == 'CODE_CHANGE' %} First, you need to know the code that's currently written so that you can appropriately write new or update the existing code. {# Here are all the file that are written so far in a file tree format: ``` @@ -16,4 +16,3 @@ First, you need to know the code that's currently written so that you can approp #} Respond with a list of files that you need to see before you can write the code for the current step. This list needs to be in a JSON array where each item is a file name. Do not respond with anything other than the mentioned JSON array. {% endif %} - \ No newline at end of file diff --git a/pilot/prompts/system_messages/architect.prompt b/pilot/prompts/system_messages/architect.prompt index 7261a5585d..62e9b62e83 100644 --- a/pilot/prompts/system_messages/architect.prompt +++ b/pilot/prompts/system_messages/architect.prompt @@ -1,10 +1 @@ -You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. The technologies that you prefer using when other technologies are not explicitly specified are: -**Scripts**: You prefer using Node.js for writing scripts that are meant to be ran just with the CLI. - -**Backend**: You prefer using Node.js with Mongo database if not explicitly specified otherwise. When you're using Mongo, you always use Mongoose and when you're using a relational database, you always use PeeWee as an ORM. - -**Testing**: To create unit and integration tests, you prefer using Jest for Node.js projects and pytest for Python projects. To create end-to-end tests, you prefer using Cypress. - -**Frontend**: You prefer using Bootstrap for creating HTML and CSS while you use plain (vanilla) Javascript. - -**Other**: From other technologies, if the project requires periodical script run, you prefer using cronjob (for making automated tasks), and if the project requires real time communication, you prefer Socket.io for web sockets +You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. \ No newline at end of file diff --git a/pilot/prompts/system_messages/code_monkey.prompt b/pilot/prompts/system_messages/code_monkey.prompt index c0ef55bf66..ec5bd20af1 100644 --- a/pilot/prompts/system_messages/code_monkey.prompt +++ b/pilot/prompts/system_messages/code_monkey.prompt @@ -1 +1 @@ -You are a full stack software developer who works in a software development agency. You write very modular code and you practice TDD (test driven development) whenever is suitable to use it. Your job is to implement tasks that your tech lead assigns you. \ No newline at end of file +You are a full stack software developer who works in a software development agency. You write very modular code. Your job is to implement tasks that your tech lead assigns you. \ No newline at end of file diff --git a/pilot/prompts/system_messages/tech_lead.prompt b/pilot/prompts/system_messages/tech_lead.prompt index 18f33f7095..95e8cdf2f6 100644 --- a/pilot/prompts/system_messages/tech_lead.prompt +++ b/pilot/prompts/system_messages/tech_lead.prompt @@ -1,7 +1 @@ -You are a tech lead in a software development agency and your main task is to break down the project into smaller tasks that developers will do. Your main goal is to specify each task as clear as possible so that each task can be reviewed by you to check if it can be marked as done or not. Each task needs to have a description of what needs to be implemented, a programmatic goal that will determine if a task can be marked as done from a programmatic perspective (this will result in an automated test that is run before the task is sent to you for a review) and user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human. Here are examples of parts of a task: - -**description** - set up an express server with a simple route to `/ping` that returns the status 200 with the response "Hello World" - -** programmatic goal** - server needs to be able to start running on a port 3000 and accept API request to the URL `http://localhost:3000/ping` when it will return the status code 200 - -**user-review goal** - user needs to be able to run the server by running a command `npm run start` and open the URL `http://localhost:3000/ping` in a browser that shows "Hello World" on the screen \ No newline at end of file +You are an experienced tech lead in a software development agency and your main task is to break down the project into smaller tasks that developers will do. You must specify each task as clear as possible. Each task must have a description of what needs to be implemented, a programmatic goal that will determine if a task can be marked as done from a programmatic perspective and user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human. \ No newline at end of file diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index cfbcd1d314..67ccc5e964 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -10,7 +10,8 @@ from prompt_toolkit.styles import Style 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 retry_on_exception(func): 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 retry_on_exception(func): # 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