karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 113 forks source link

Multiline system directives break org properties #195

Closed martenlienen closed 5 months ago

martenlienen commented 5 months ago

Hello, thanks for the great plugin! One thing that I have noticed in my saved org-mode chats is that gptel-mode would create more and more PROPERTIES blocks at the top every time I save the buffer and today I tracked down the problem.

The root cause is that my system contains a newline \n (because I just read them from files and they happen to have a final newline. However, org-property-drawer-re does not allow for newlines in the values of properties. This leads to the problem that as soon as GPTEL_SYSTEM has been saved to a PROPERTIES block, org-mode does not recognize that block any longer and creates a new one at the top.

I am unsure what the best way to deal with this is for gptel. One way would for gptel to remove any newlines from the system directive, when storing it in an org property. What do you think?

PS: My local workaround is to just remove all newlines with s-replace when I load my systems but it might still be good to prevent this from biting anyone else.

karthink commented 5 months ago

Hi @martenlienen, see #180. A fix is in the works -- actually many different fixes are in the works, so I'm trying to find the best one to maintain backwards compatibility in the future.

I'm closing this, please use #180 for further discussion.