s-kostyaev / ellama

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

If a user changed or removed the session file, chat won't work next time. #144

Open hwiorn opened 4 months ago

hwiorn commented 4 months ago
Debugger entered--Lisp error: (wrong-type-argument ellama-session nil)
  signal(wrong-type-argument (ellama-session nil))
  (or (progn (and (memq (type-of session) cl-struct-ellama-session-tags) t)) (signal 'wrong-type-argument (list 'ellama-session session)))
  (progn (or (progn (and (memq (type-of session) cl-struct-ellama-session-tags) t)) (signal 'wrong-type-argument (list 'ellama-session session))) (aref session 1))
  (ellama-get-session-buffer (progn (or (progn (and (memq (type-of session) cl-struct-ellama-session-tags) t)) (signal 'wrong-type-argument (list 'ellama-session session))) (aref session 1)))
  (let* ((providers (append (list '("default model" . ellama-provider) (if (and ellama-ollama-binary (file-exists-p ellama-ollama-binary)) '("ollama model" ellama-get-ollama-local-model))) ellama-providers)) (variants (mapcar #'car providers)) (donecb (plist-get args :on-done)) (provider (if current-prefix-arg (progn (setq current-prefix-arg nil) (eval (alist-get (completing-read "Select model: " variants) providers nil nil #'string=))) (or (plist-get args :provider) ellama-provider))) (session (if (or create-session current-prefix-arg (and provider (or (plist-get args :provider) (not ...)) ellama--current-session-id (save-current-buffer (set-buffer ...) (not ...))) (and (not ellama--current-session) (not ellama--current-session-id))) (ellama-new-session provider prompt) (or ellama--current-session (save-current-buffer (set-buffer (ellama-get-session-buffer ellama--current-session-id)) ellama--current-session)))) (buffer (ellama-get-session-buffer (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... session))) (aref session 1)))) (file-name (progn (or (progn (and (memq ... cl-struct-ellama-session-tags) t)) (signal 'wrong-type-argument (list 'ellama-session session))) (aref session 3))) (translation-buffer (if ellama-chat-translation-enabled (progn (if file-name (progn (find-file-noselect ...)) (get-buffer-create (progn ... ...))))))) (if ellama-chat-translation-enabled (ellama--translate-interaction prompt translation-buffer buffer session) (display-buffer buffer) (save-current-buffer (set-buffer buffer) (save-excursion (goto-char (point-max)) (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n" (ellama--format-context session) (ellama--fill-long-lines prompt) "\n\n" (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick ":\n") (ellama-stream prompt :session session :on-done (if donecb (list 'ellama-chat-done donecb) 'ellama-chat-done) :filter (if (derived-mode-p 'org-mode) (progn #'ellama--translate-markdown-to-org-filter)))))))
  ellama-chat("XXXXXXXXXX")
  funcall-interactively(ellama-chat "XXXXXXXXXX")
  command-execute(ellama-chat record)
  execute-extended-command(nil "ellama-chat" nil)
  funcall-interactively(execute-extended-command nil "ellama-chat" nil)
  command-execute(execute-extended-command)

The workaround is:

(setq ellama--active-sessions (make-hash-table :test #'equal)
      ellama--current-session-id nil)
s-kostyaev commented 4 months ago

@hwiorn Thank you. I will think how to fix it automatically in runtime.

mberrueta commented 4 months ago

In my case I didn't modified or deleted any file. and even if I exec

(setq ellama--active-sessions (make-hash-table :test #'equal)
      ellama--current-session-id nil)

the issue still persist

s-kostyaev commented 4 months ago

@mberrueta very strange. Could you please share your full ellama configuration (with replaced keys)?