ErikBjare / gptme

Your agent in your terminal, equipped with local tools: writes code, uses the terminal, browses the web, vision.
https://gptme.org/docs/
MIT License
2.67k stars 180 forks source link

Fails if trying to apply patch without file name #153

Closed brayo-pip closed 1 day ago

brayo-pip commented 1 month ago
The error is due to the incorrect use of `ifeq` and `else` in the `Makefile`. The `ifeq` directive should be properly indented, and the `else` and `endif` should align with the `ifeq`. Let's correct this by adjusting the indentation. Here's the corrected section of the `Makefile`: ```makefile install: ifeq ($(SKIP_INSTALL),true) @echo "Skipping npm install" else npm ci (cd aw-client-js; npm ci; npm run compile) endif ``` Let's apply this patch to the `Makefile`. ```patch Makefile <<<<<<< ORIGINAL install: ifeq ($(SKIP_INSTALL),true) @echo "Skipping npm install" else npm ci (cd aw-client-js; npm ci; npm run compile) endif ======= install: ifeq ($(SKIP_INSTALL),true) @echo "Skipping npm install" else npm ci (cd aw-client-js; npm ci; npm run compile) endif >>>>>>> UPDATED ``` Skipped 1 hidden system messages, show with --show-hidden --- ^^^ past messages ^^^ --- User: fix it Assistant: Let's apply the patch to correct the indentation issue in the `Makefile`. ```patch Makefile <<<<<<< ORIGINAL install: ifeq ($(SKIP_INSTALL),true) @echo "Skipping npm install" else npm ci (cd aw-client-js; npm ci; npm run compile) endif ======= install: ifeq ($(SKIP_INSTALL),true) @echo "Skipping npm install" else npm ci (cd aw-client-js; npm ci; npm run compile) endif >>>>>>> UPDATED ``` Traceback (most recent call last): File "/home/brayo/.local/bin/gptme", line 8, in sys.exit(main()) ^^^^^^ File "/usr/lib/python3.12/site-packages/click/core.py", line 1157, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/brayo/Repos/gptme/gptme/cli.py", line 245, in main chat( File "/home/brayo/Repos/gptme/gptme/cli.py", line 416, in chat for msg in step(log, no_confirm, stream=stream): # pragma: no cover ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/brayo/Repos/gptme/gptme/cli.py", line 463, in step yield from execute_msg(msg_response, ask=not no_confirm) File "/home/brayo/Repos/gptme/gptme/tools/__init__.py", line 86, in execute_msg yield from tooluse.execute(ask) File "/home/brayo/Repos/gptme/gptme/tools/base.py", line 85, in execute yield from tool.execute(self.content, ask, self.args) File "/home/brayo/Repos/gptme/gptme/tools/patch.py", line 166, in execute_patch assert fn, "No filename provided" ^^ AssertionError: No filename provided
brayo-pip commented 1 month ago

I was trying to fix a Makefile. Used ls to find the makefile and cat to view it. But it failed to apply the patch because filename was not provided. Not sure how to reproduce because it has only happened once so far.

ErikBjare commented 1 month ago

I've noticed how LLMs sometimes output saves and patches on a variety of other formats, including these two:

file.txt:
```patch
...
```
```patch
# file.txt
...
```

Perhaps we should try to gracefully handle these? Could add message-rewrite rules, as proposed for save/patch in #152.

They usually recover from it, but I've had it happen once or twice that it just won't use the correct format. Not sure why.

brayo-pip commented 1 day ago

Not experienced this in a really long time. I consider it closed. Can always reopen if anyone reports it again.