Skip to content

Commit

Permalink
Merge pull request #918 from Pythagora-io/prompts
Browse files Browse the repository at this point in the history
update alternative solutions when user is stuck in a loop
  • Loading branch information
LeonOstrez committed May 13, 2024
2 parents 9eba9cf + d9ac194 commit 6392899
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
6 changes: 5 additions & 1 deletion pilot/helpers/agents/Developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,13 @@ def get_alternative_solutions(self, development_task, user_feedback, previous_so
"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,
Expand Down
4 changes: 3 additions & 1 deletion pilot/prompts/development/filter_files.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -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() %}
Expand Down
35 changes: 9 additions & 26 deletions pilot/prompts/development/get_alternative_solutions.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}
Expand All @@ -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 }}
```
Expand All @@ -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.
5 changes: 4 additions & 1 deletion pilot/prompts/development/iteration.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion pilot/prompts/development/review_task.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 6392899

Please sign in to comment.