s-kostyaev / ellama

Ellama is a tool for interacting with large language models from Emacs.
GNU General Public License v3.0
485 stars 30 forks source link

Prefer `read` over `eval` for storing sessions #63

Closed Stebalien closed 8 months ago

Stebalien commented 8 months ago

I see you're saving a file with (setq ellama--current-session .... A slightly safer way to do this is to store just the data and use read to load it. Unlike eval, that won't execute any code (so it's safer to, e.g., share session files with others).

s-kostyaev commented 8 months ago

I have tried it already, but without success. I agree that this is safer.

Stebalien commented 8 months ago

Hm. I did a basic test and it looked like it had no issues reading hash tables. Do you happen to remember the error?

The following should work:

(with-temp-buffer
  (insert-file-contents ".session.el")
  (goto-char (point-min))
  (read (current-buffer)))
s-kostyaev commented 8 months ago

Probably I have used it wrong. It works. I will fix it.