karthink / gptel

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

PR #221 broke the package. #224

Closed CsBigDataHub closed 4 months ago

CsBigDataHub commented 4 months ago

Will start off by saying a BIG thank you for all your packages.

Using Ollama.

I had to fork the repo and create a branch with rev sha which was working.
Which is 226f8f0d9091e1feb113623ab6da5fdc471994e8

(package-vc-install
   '(gptel
     :url "https://github.com/CsBigDataHub/gptel"
     :branch "no-error-sha"))

(use-package gptel
    :commands (gptel gptel-send)
    :hook (gptel-mode . visual-line-mode)
    :custom
    (gptel-default-mode 'org-mode)
    :config
    (setq-default gptel-backend
                  (gptel-make-ollama "ollama"             ;Any name of your choosing
                    :host "localhost:11434"               ;Where it's running
                    :stream t                             ;Stream responses
                    :models '("zephyr:latest" "codellama:latest" "mistral:latest") ;Installed Models
                    )
                  gptel-model "zephyr:latest")

    (defun gptel-extensions-rewrite-and-replace (bounds &optional directive)
      "Rewrite the region or sentence at point and replace it with the response.

  BOUNDS is a cons cell where the car is the beginning and the cdr is the end of the region to be rewritten."
      (interactive
       (list
        (cond
         ((use-region-p) (cons (region-beginning) (region-end)))
         ((derived-mode-p 'text-mode)
          (list (bounds-of-thing-at-point 'sentence)))
         (t (cons (line-beginning-position) (line-end-position))))
        (and current-prefix-arg
             (read-string "ChatGPT Directive: "
                          "Paraphrase and Rewrite my prompt more professionally."))))
      (gptel-request
          (buffer-substring-no-properties (car bounds) (cdr bounds)) ;the prompt
        :system (or directive "Paraphrase and Rewrite my prompt more professionally.")
        :buffer (current-buffer)
        :context (cons (set-marker (make-marker) (car bounds))
                       (set-marker (make-marker) (cdr bounds)))
        :callback
        (lambda (response info)
          (if (not response)
              (message "ChatGPT response failed with: %s" (plist-get info :status))
            (let* ((bounds (plist-get info :context))
                   (beg (car bounds))
                   (end (cdr bounds))
                   (buf (plist-get info :buffer)))
              (with-current-buffer buf
                (save-excursion
                  (goto-char beg)
                  (kill-region beg end)
                  (insert response)
                  (set-marker beg nil)
                  (set-marker end nil)
                  (message "Rewrote line. Original line saved to kill-ring.")))))))))

stack-trace

Debugger entered--Lisp error: (args-out-of-range [#s(cl-slot-descriptor :name name :initform nil :type t :props nil) #s(cl-slot-descriptor :name host :initform nil :type t :props nil) #s(cl-slot-descriptor :name header :initform nil :type t :props nil) #s(cl-slot-descriptor :name protocol :initform nil :type t :props nil) #s(cl-slot-descriptor :name stream :initform nil :type t :props nil) #s(cl-slot-descriptor :name endpoint :initform nil :type t :props nil) #s(cl-slot-descriptor :name key :initform nil :type t :props nil) #s(cl-slot-descriptor :name models :initform nil :type t :props nil) #s(cl-slot-descriptor :name url :initform nil :type t :props nil)] 9)
  cl-struct-define(gptel-ollama nil gptel-backend record nil ((cl-tag-slot) (name nil) (host nil) (header nil) (protocol nil) (stream nil) (endpoint nil) (key nil) (models nil) (url nil)) cl-struct-gptel-ollama-tags gptel-ollama t)
  byte-code("\300\301\302\303#\304\305\306\307\310\306\311\312\305\303&\11\207" [function-put gptel--make-ollama side-effect-free t cl-struct-define gptel-ollama nil gptel-backend record ((cl-tag-slot) (name nil) (host nil) (header nil) (protocol nil) (stream nil) (endpoint nil) (key nil) (models nil) (url nil)) cl-struct-gptel-ollama-tags] 11)
  (gptel-make-ollama "ollama" :host "localhost:11434" :stream t :models '("zephyr:latest" "codellama:latest" "mistral:latest"))
  (set-default 'gptel-backend (gptel-make-ollama "ollama" :host "localhost:11434" :stream t :models '("zephyr:latest" "codellama:latest" "mistral:latest")))
  (progn (set-default 'gptel-backend (gptel-make-ollama "ollama" :host "localhost:11434" :stream t :models '("zephyr:latest" "codellama:latest" "mistral:latest"))) (set-default 'gptel-model "zephyr:latest"))
  (progn (progn (set-default 'gptel-backend (gptel-make-ollama "ollama" :host "localhost:11434" :stream t :models '("zephyr:latest" "codellama:latest" "mistral:latest"))) (set-default 'gptel-model "zephyr:latest")) t)
  (closure (helm-mode-abbrev-table helm-mode-syntax-table bootstrap-version t) nil (progn (progn (set-default 'gptel-backend (gptel-make-ollama "ollama" :host "localhost:11434" :stream t :models '("zephyr:latest" "codellama:latest" "mistral:latest"))) (set-default 'gptel-model "zephyr:latest")) t))()
  eval-after-load-helper("/Users/ckoneru/.emacs.d/elpa/gptel-20240221.811/gp...")
  do-after-load-evaluation("/Users/ckoneru/.emacs.d/elpa/gptel-20240221.811/gp...")
  #<subr command-execute>(gptel record nil nil)
  ad-Advice-command-execute(#<subr command-execute> gptel record)
  apply(ad-Advice-command-execute #<subr command-execute> (gptel record))
  command-execute(gptel record)
  #<subr execute-extended-command>(nil "gptel" nil)
  ad-Advice-execute-extended-command(#<subr execute-extended-command> nil "gptel" nil)
  apply(ad-Advice-execute-extended-command #<subr execute-extended-command> (nil "gptel" nil))
  execute-extended-command(nil "gptel" nil)
  funcall-interactively(execute-extended-command nil "gptel" nil)
  #<subr command-execute>(execute-extended-command nil nil nil)
  ad-Advice-command-execute(#<subr command-execute> execute-extended-command)
  apply(ad-Advice-command-execute #<subr command-execute> execute-extended-command)
  command-execute(execute-extended-command)
karthink commented 4 months ago

I'm not able to reproduce this error. Have you tried rebuilding or reinstalling the package? The definition of gptel-make-ollama was changed slightly but the change seems to not be reflected in your stack trace.

CsBigDataHub commented 4 months ago

Deleting the package and re-installing worked. Thank you.