From d9ac19473033879f1b1ceddfb96969839b561747 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Thu, 9 May 2024 09:00:50 +0100 Subject: [PATCH 1/2] update alternative solutions when user is stuck in a loop --- pilot/helpers/agents/Developer.py | 6 +++- pilot/prompts/development/filter_files.prompt | 4 ++- .../get_alternative_solutions.prompt | 35 +++++-------------- pilot/prompts/development/iteration.prompt | 5 ++- pilot/prompts/development/review_task.prompt | 5 ++- 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 40022388..fc93a4de 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -1090,9 +1090,13 @@ class Developer(Agent): "directory_tree": self.project.get_directory_tree(True), "current_task": development_task, "development_tasks": self.project.development_plan, - "files": self.project.get_all_coded_files(), + "files": self.project.get_all_coded_files(relevant_files=self.relevant_files), + "file_summaries": self.project.get_file_summaries(), "user_input": user_feedback, "previous_solutions": previous_solutions, + # TODO tried_alternative_solutions_to_current_issue is not used in prompt anymore because in case multiple + # different issues are being solved, LLM gets confused and doesn't know which one to focus on. Long term + # solution is to know when issues is solved and then clear tried_alternative_solutions_to_current_issue. "tried_alternative_solutions_to_current_issue": tried_alternative_solutions_to_current_issue, "previous_features": self.project.previous_features, "current_feature": self.project.current_feature, diff --git a/pilot/prompts/development/filter_files.prompt b/pilot/prompts/development/filter_files.prompt index ad4f7853..816c8c50 100644 --- a/pilot/prompts/development/filter_files.prompt +++ b/pilot/prompts/development/filter_files.prompt @@ -7,7 +7,9 @@ Here is a high level description of "{{ name }}": {{ features_list }} You are currently working on, and have to focus only on, this task: -`{{ current_task.description }}` +``` +{{ current_task.description }} +``` A part of the app is already finished. Here is the list of files and descriptions that the app currently contains: {% for fpath, summary in file_summaries.items() %} diff --git a/pilot/prompts/development/get_alternative_solutions.prompt b/pilot/prompts/development/get_alternative_solutions.prompt index 73571602..24f671c6 100644 --- a/pilot/prompts/development/get_alternative_solutions.prompt +++ b/pilot/prompts/development/get_alternative_solutions.prompt @@ -5,36 +5,20 @@ Here is a high level description of "{{ name }}": {{ app_summary }} ``` {{ features_list }} -Project architecture: -{{ architecture }} -Here are the technologies that you need to use for this project: -{% for tech in technologies %} -* {{ tech["name"] }} - {{ tech["description"] }}{% endfor %} - -{% 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'] }} -{% endfor %} +{% if current_task %} +You are currently working on, and have to focus only on, this task: +``` +{{ current_task.description }} ``` -You are currently working on task "{{ current_task.description }}" and you have to focus only on that task. {% endif %} A part of the app is already finished. {{ files_list }} -You are trying to solve an issue that your colleague is reporting. You tried {{ previous_solutions|length }} times to solve it but it was unsuccessful. -{% if tried_alternative_solutions_to_current_issue|length > 0 %} - -Here are the alternative solutions that you tried to solve the issue: -{% for solution in tried_alternative_solutions_to_current_issue %} -----------------------------start_of_solution_{{ loop.index }}---------------------------- -{{ solution }} -----------------------------end_of_solution_{{ loop.index }}---------------------------- -{% endfor %} -{% elif previous_solutions|length > 0 %} -First time, your colleague gave you this report: +You are trying to solve an issue that your colleague is reporting. +{% if previous_solutions|length > 0 %} +You tried {{ previous_solutions|length }} times to solve it but it was unsuccessful. In last few attempts, your colleague gave you this report: {% for solution in previous_solutions[-3:] %} ----------------------------start_of_report_{{ loop.index }}---------------------------- {{ solution['user_feedback'] }} @@ -52,7 +36,7 @@ Then, upon implementing these changes, your colleague came back with the followi {% endif %} {% if user_input != '' %} -After implementing these changes as well, your colleague who is testing the app "{{ name }}" sent you this report now: +Your colleague who is testing the app "{{ name }}" sent you this report now: ``` {{ user_input }} ``` @@ -62,9 +46,8 @@ You tried to solve this problem before but your colleague is telling you that yo It seems that the solutions you're proposing aren't working. -Now, think about 5 alternative solutions to get this code to work that are most probable to solve this issue. +Now, think step by step about 5 alternative solutions to get this code to work that are most probable to solve this issue. Every proposed solution needs to be concrete and not vague (eg, it cannot be "Review and change apps functionality") and based on the code changes. A solution can be complex if it's related to the same part of the code (eg. "Try changing the input variables X, Y and Z to a method N"). Order them in the order of the biggest probability of fixing the problem. A developer will then go through this list item by item, try to implement it, and check if it solved the issue until the end of the list. -Let's think step by step. diff --git a/pilot/prompts/development/iteration.prompt b/pilot/prompts/development/iteration.prompt index 79ca3d13..cc737a3a 100644 --- a/pilot/prompts/development/iteration.prompt +++ b/pilot/prompts/development/iteration.prompt @@ -18,7 +18,10 @@ Development process of this app was split into smaller tasks. Here is the list o {{ loop.index }}. {{ task['description'] }} {% endfor %} ``` -You are currently working on task "{{ current_task.description }}" and you have to focus only on that task. +You are currently working on, and have to focus only on, this task: +``` +{{ current_task.description }} +``` {% endif %} A part of the app is already finished. diff --git a/pilot/prompts/development/review_task.prompt b/pilot/prompts/development/review_task.prompt index a9ac84e3..474a8694 100644 --- a/pilot/prompts/development/review_task.prompt +++ b/pilot/prompts/development/review_task.prompt @@ -10,7 +10,10 @@ Development process of this app was split into smaller tasks. Here is the list o {{ loop.index }}. {{ task['description'] }} {% endfor %} ``` -You are currently working on task "{{ current_task }}" and you have to focus only on that task. +You are currently working on, and have to focus only on, this task: +``` +{{ current_task }} +``` A part of the app is already finished. {{ files_list }} From de16fc77d810809a80b807e3f65c8014ba799dab Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Mon, 13 May 2024 14:04:05 +0100 Subject: [PATCH 2/2] fix bug where self.is_complex_app doesn't exist --- pilot/helpers/Project.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index e8edb4f9..d627b92f 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -93,6 +93,7 @@ class Project: self.development_plan = None self.previous_features = None self.current_feature = None + self.is_complex_app = True self.dot_pilot_gpt = DotGptPilot(log_chat_completions=True) if os.getenv("AUTOFIX_FILE_PATHS", "").lower() in ["true", "1", "yes"]: