-
Couldn't load subscription status.
- Fork 7.3k
Integrate Morph API for code editing #1322
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
Open
SaurabhJain708
wants to merge
3
commits into
AntonOsika:main
Choose a base branch
from
SaurabhJain708:feat/morph-fast-apply
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.
Open
Changes from 2 commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,41 +1,39 @@ | ||
| You will output the content of each file necessary to achieve the goal, including ALL code. | ||
| Output requested code changes and new code in the unified "git diff" syntax. Example: | ||
|
|
||
| ```diff | ||
| --- example.txt | ||
| +++ example.txt | ||
| @@ -6,3 +6,4 @@ | ||
| line content A | ||
| line content B | ||
| + new line added | ||
| - original line X | ||
| + modified line X with changes | ||
| @@ -26,4 +27,5 @@ | ||
| condition check: | ||
| - action for condition A | ||
| + if certain condition is met: | ||
| + alternative action for condition A | ||
| another condition check: | ||
| - action for condition B | ||
| + modified action for condition B | ||
| ``` | ||
|
|
||
| Example of a git diff creating a new file: | ||
|
|
||
| ```diff | ||
| --- /dev/null | ||
| +++ new_file.txt | ||
| @@ -0,0 +1,3 @@ | ||
| +First example line | ||
| + | ||
| +Last example line | ||
| ``` | ||
|
|
||
| RULES: | ||
| -A program will apply the diffs you generate exactly to the code, so diffs must be precise and unambiguous! | ||
| -Every diff must be fenced with triple backtick ```. | ||
| -The file names at the beginning of a diff, (lines starting with --- and +++) is the relative path to the file before and after the diff. | ||
| -LINES TO BE REMOVED (starting with single -) AND LINES TO BE RETAIN (no starting symbol) HAVE TO REPLICATE THE DIFFED HUNK OF THE CODE EXACTLY LINE BY LINE. KEEP THE NUMBER OF RETAIN LINES SMALL IF POSSIBLE. | ||
| -EACH LINE IN THE SOURCE FILES STARTS WITH A LINE NUMBER, WHICH IS NOT PART OF THE SOURCE CODE. NEVER TRANSFER THESE LINE NUMBERS TO THE DIFF HUNKS. | ||
| -AVOID STARTING A HUNK WITH AN EMPTY LINE. | ||
| -ENSURE ALL CHANGES ARE PROVIDED IN A SINGLE DIFF CHUNK PER FILE TO PREVENT MULTIPLE DIFFS ON THE SAME FILE. | ||
| You must produce your output as a JSON array of objects. Each object must have exactly three fields: | ||
|
|
||
| 1. **target_file**: the relative path of the file to edit. | ||
| 2. **instructions**: a brief description of the changes made to this file. | ||
| 3. **code_edit**: the edited content of the file, showing all changes in context. Use the special comment `// ... existing code ...` to represent unchanged spans of code. | ||
|
|
||
| Example JSON output: | ||
| [ | ||
| { | ||
| "target_file": "path/to/file.ext", | ||
| "instructions": "Brief summary of changes", | ||
| "code_edit": "// ... existing code ...\nFIRST_EDIT\n// ... existing code ...\nSECOND_EDIT\n// ... existing code ..." | ||
| } | ||
| ] | ||
|
|
||
| Use this tool to make an edit to an existing file. | ||
|
|
||
| This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write. | ||
| When writing the edit, you should specify each edit in sequence, with the special comment // ... existing code ... to represent unchanged code in between edited lines. | ||
|
|
||
| For example: | ||
|
|
||
| // ... existing code ... | ||
| FIRST_EDIT | ||
| // ... existing code ... | ||
| SECOND_EDIT | ||
| // ... existing code ... | ||
| THIRD_EDIT | ||
| // ... existing code ... | ||
|
|
||
| You should still bias towards repeating as few lines of the original file as possible to convey the change. | ||
| But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity. | ||
| DO NOT omit spans of pre-existing code (or comments) without using the // ... existing code ... comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines. | ||
| If you plan on deleting a section, you must provide context before and after to delete it. If the initial code is ```code \n Block 1 \n Block 2 \n Block 3 \n code```, and you want to remove Block 2, you would output ```// ... existing code ... \n Block 1 \n Block 3 \n // ... existing code ...```. | ||
| Make sure it is clear what the edit should be, and where it should be applied. | ||
| Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once. | ||
|
|
||
|
|
||
| RULES: Only return a JSON object nothing else dont even use markdown syntax and strictly no other text or instructions or formatting |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.