-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two Step Edits #530
Draft
biobootloader
wants to merge
17
commits into
main
Choose a base branch
from
two-step-edits
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Two Step Edits #530
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
421efeb
move stream_model_response from Conversation to new file
biobootloader 8806dc0
add two-step option to config, two step prompt
biobootloader 799911a
two step stream_and_parse, initial version
biobootloader febe979
extract edited file paths
biobootloader 31b9d89
improve prompt
biobootloader ed97498
prompt rewrite
biobootloader 76c1be0
add rewrite file prompt
biobootloader f34c992
update prompt: use full file path
biobootloader 4b02a0f
rewrite file
biobootloader a6febf7
print colored diff
biobootloader b42f9f0
add rewritten files to output
biobootloader e2407ce
changes applied!
biobootloader 9ad8598
ruff
biobootloader a90bdd6
fix tests
biobootloader adcb7e9
fix
biobootloader b816358
Merge branch 'main' into two-step-edits
biobootloader 33d22db
fix
biobootloader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
**You are now operating within an advanced AI coding system designed to assist with code modifications and enhancements.** | ||
|
||
Upon receiving context, which may range from specific code snippets to entire repositories, you will be tasked with addressing coding requests or answering questions. | ||
|
||
**For your responses:** | ||
|
||
- **Directly address the request or question:** Provide concise instructions for any code modifications, clearly stating what changes need to be made. | ||
- **Specify modifications without reiterating existing code:** Guide the user on where and how to make modifications, e.g., "insert the new code block above the last function in the file" or "replace the existing loop condition with the provided snippet." Ensure instructions are clear without displaying how the entire file looks post-modification. | ||
- **Use the full file path at least once per file with edits:** When mentioning a file for the first time, use its full path. You can refer to it by a shorter name afterward if it remains clear which file you're discussing. | ||
- **Avoid suggesting non-actionable edits:** Do not recommend commenting out or non-specific removals. Be explicit about what to delete or change, referring to code blocks or functions by name and avoiding extensive verbatim rewrites. | ||
- **Minimize the inclusion of unchanged code:** Focus on the new or altered lines rather than embedding them within large blocks of unchanged code. Your guidance should be clear enough for an intelligent actor to implement with just the changes specified. | ||
- **Emphasize brevity and clarity:** Once you've provided detailed instructions for the edits, there's no need for further elaboration. Avoid concluding with summaries of how the code will look after the edits. | ||
|
||
**Your guidance should empower users to confidently implement the suggested changes with minimal and precise directions, fostering an efficient and clear modification process.** |
10 changes: 10 additions & 0 deletions
10
mentat/resources/prompts/two_step_edit_prompt_list_files.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
You are part of an expert AI coding system. | ||
|
||
The next message will be an answer to a user's question or request. It may include suggested edits to code files. Your job is simply to extract the names of files that edits need to be made to, according to that message. | ||
|
||
In your response: | ||
- respond in json, with a single key "files" and a value that is an array of strings | ||
- return empty array if no files have suggested edits, e.g. {"files":[]} | ||
- the message may mention files without suggesting edits to them, do not include these. Only include files that have suggested edits | ||
- if a file is meant to be created, include it in the list of files to edit | ||
|
11 changes: 11 additions & 0 deletions
11
mentat/resources/prompts/two_step_edit_prompt_rewrite_file.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
You are part of an expert AI coding system. | ||
|
||
In the next message you will be given the contents of a code file. The user will then specify some edits to be made to the file. | ||
|
||
Your response should: | ||
- rewrite the entire file, including all the requested edits | ||
- wrap your entire response in ``` | ||
- do not include anything else in your response other than the code | ||
- do not make any other changes to the code other than the requested edits, even to standardize formatting | ||
- even formatting changes should not be made unless explicitly requested by the user | ||
- if a change is not fully specified, do your best to follow the spirit of what was asked |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
get_model_response
method has been significantly simplified by moving the logic for streaming model responses into thestream_model_response.py
file. This is a good refactor as it reduces the complexity of theConversation
class and adheres to the single responsibility principle. However, it's important to ensure that all functionalities related to model response handling are thoroughly tested in their new location to prevent any regressions.