From 2ade6677b75306638db9ec9533825264971000cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 22 Nov 2024 14:38:03 +0100 Subject: [PATCH] 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 --- gptme/tools/patch.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gptme/tools/patch.py b/gptme/tools/patch.py index 1c0214ef..7b263451 100644 --- a/gptme/tools/patch.py +++ b/gptme/tools/patch.py @@ -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 ======= @@ -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