Skip to content

Commit

Permalink
fix: enforce full path usage in patch tool
Browse files Browse the repository at this point in the history
The patch tool sometimes failed to use complete paths when suggesting changes,
leading to potential errors. This change improves the tool's example prompt
to better demonstrate and enforce the use of full paths.

- Updated example to show full path usage (src/hello.py)
- Changed FILENAME to PATH in example prompt to prevent missing path to file
- Added complete file content in example for better context
  • Loading branch information
ErikBjare committed Nov 22, 2024
1 parent b3955d5 commit 2ade667
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions gptme/tools/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
To keep the patch small, try to scope the patch to imports/function/class.
If the patch is large, consider using the save tool to rewrite the whole file.
The $FILENAME parameter MUST be on the same line as the code block start, not on the line after.
The $PATH parameter MUST be on the same line as the code block start, not on the line after.
The patch block should be written in the following format:
{ToolUse("patch", ["$FILENAME"], '''
{ToolUse("patch", ["$PATH"], '''
<<<<<<< ORIGINAL
$ORIGINAL_CONTENT
=======
Expand All @@ -41,14 +41,19 @@


examples = f"""
> User: patch the file `hello.py` to ask for the name of the user
> User: patch `src/hello.py` to ask for the name of the user
```src/hello.py
def hello():
print("Hello world")
if __name__ == "__main__":
hello()
```
> Assistant:
{ToolUse("patch", ["hello.py"], '''
{ToolUse("patch", ["src/hello.py"], '''
<<<<<<< ORIGINAL
def hello():
print("Hello world")
=======
def hello():
name = input("What is your name? ")
print(f"Hello {name}")
>>>>>>> UPDATED
Expand Down

0 comments on commit 2ade667

Please sign in to comment.