Skip to content

Commit 2ade667

Browse files
committed
fix: enforce full path usage in patch tool
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
1 parent b3955d5 commit 2ade667

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

gptme/tools/patch.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
To keep the patch small, try to scope the patch to imports/function/class.
2323
If the patch is large, consider using the save tool to rewrite the whole file.
2424
25-
The $FILENAME parameter MUST be on the same line as the code block start, not on the line after.
25+
The $PATH parameter MUST be on the same line as the code block start, not on the line after.
2626
2727
The patch block should be written in the following format:
2828
29-
{ToolUse("patch", ["$FILENAME"], '''
29+
{ToolUse("patch", ["$PATH"], '''
3030
<<<<<<< ORIGINAL
3131
$ORIGINAL_CONTENT
3232
=======
@@ -41,14 +41,19 @@
4141

4242

4343
examples = f"""
44-
> User: patch the file `hello.py` to ask for the name of the user
44+
> User: patch `src/hello.py` to ask for the name of the user
45+
```src/hello.py
46+
def hello():
47+
print("Hello world")
48+
49+
if __name__ == "__main__":
50+
hello()
51+
```
4552
> Assistant:
46-
{ToolUse("patch", ["hello.py"], '''
53+
{ToolUse("patch", ["src/hello.py"], '''
4754
<<<<<<< ORIGINAL
48-
def hello():
4955
print("Hello world")
5056
=======
51-
def hello():
5257
name = input("What is your name? ")
5358
print(f"Hello {name}")
5459
>>>>>>> UPDATED

0 commit comments

Comments
 (0)