joshcho / ChatGPT.el

ChatGPT in Emacs
GNU General Public License v3.0
397 stars 34 forks source link

Can't Install on Spacemacs #13

Closed erichlf closed 1 year ago

erichlf commented 1 year ago

When I attempt to install via quelpa I get the following:

(Spacemacs) --> installing package: ChatGPT@dotfile... [6/6]
Fetcher: github
Source: joshcho/ChatGPT.el

Updating REDACTED/.emacs.d/.cache/quelpa/build/ChatGPT/
Skipping rebuild of REDACTED/.emacs.d/.cache/quelpa/packages/ChatGPT-20221213.43350.el
  INFO     Scraping files for chatgpt-autoloads.el... 
Generating autoloads for chatgpt.el...done
  INFO     Scraping files for chatgpt-autoloads.el...done
Wrote REDACTED/.emacs.d/elpa/28.1/develop/chatgpt-20221213.43350/chatgpt-autoloads.el [2 times]
Wrote REDACTED/.emacs.d/.cache/undo-tree-history/REDACTED!.emacs.d!elpa!28.1!develop!chatgpt-20221213.43350!chatgpt-autoloads.el.~undo-tree~
Loading async...done
(Spacemacs) Error: 
An error occurred while installing ChatGPT (error: (scan-error Unbalanced parentheses 271 6478))

My install code looks like:

      (ChatGPT :location (recipe
                           :fetcher github
                           :repo "joshcho/ChatGPT.el"
                           :bind ("C-c q" . chatgpt-query) )
        )
erichlf commented 1 year ago

Chaning the above to

 (ChatGPT :location (recipe
                           :fetcher github
                           :repo "joshcho/ChatGPT.el"
                           :init
                           (setq chatgpt-repo-path (expand-file-name "chatgpt/" quelpa-build-dir))
                           :bind ("C-c q" . chatgpt-query) )
)

results in the following:

(Spacemacs) --> installing package: ChatGPT@dotfile... [6/6]
Fetcher: github
Source: joshcho/ChatGPT.el

Updating REDACTED/.emacs.d/.cache/quelpa/build/ChatGPT/
Skipping rebuild of REDACTED/.emacs.d/.cache/quelpa/packages/ChatGPT-20221213.43350.el
  INFO     Scraping files for chatgpt-autoloads.el... 
Generating autoloads for chatgpt.el...done
  INFO     Scraping files for chatgpt-autoloads.el...done
Wrote REDACTED/.emacs.d/elpa/28.1/develop/chatgpt-20221213.43350/chatgpt-autoloads.el [2 times]
Wrote REDACTED/.emacs.d/.cache/undo-tree-history/REDACTED!.emacs.d!elpa!28.1!develop!chatgpt-20221213.43350!chatgpt-autoloads.el.~undo-tree~
Loading async...done
(Spacemacs) --> deleting chatgpt... [1/1]
Package ‘chatgpt-20221213.43350’ deleted.
joshcho commented 1 year ago

I am not a spacemacs user, so I will be a bit unfamiliar. But I got the following to work on spacemacs with Emacs 28.2.

In dotspacemacs/user-config

  (setq chatgpt-repo-path (expand-file-name "chatgpt/" quelpa-build-dir))
  (global-set-key (kbd "C-c q") #'chatgpt-query)

In dotspacemacs/layers

   dotspacemacs-additional-packages
   '(
     (chatgpt :location (recipe
                         :fetcher github
                         :repo "joshcho/ChatGPT.el"
                         ))
     )

Let me know if that works for you.

erichlf commented 1 year ago

So oddly, changing ChatGPT->chatgpt fixed things. However, however now I get:

chatgpt--query: Symbol’s value as variable is void: python-interpreter

It looks like this is suppose to be a variable that describes the location of the python interpreter?

joshcho commented 1 year ago

Can you try (require 'python) before loading the package (or the spacemacs equivalent)? python-interpreter is available then. I will make appropriate changes to the repo in the next coming days.

joshcho commented 1 year ago

Otherwise, you can try (setq python-interpreter "python")

or (setq python-interpreter "python3")

in your user-config for a temporary solution. Your choice of python should depend on what's installed on your system.

erichlf commented 1 year ago

I set the python-interpreter to python3 however:

epc:start-server: Server may raise an error. Use "M-x epc:pop-to-last-server-process-buffer RET" to see full traceback:
Traceback (most recent call last):
  File "REDACTED/.emacs.d/.cache/quelpa/build/chatgpt/chatgpt.py", line 3, in <module>
    from epc.server import EPCServer
ModuleNotFoundError: No module named 'epc'

And before all of this I had already done

pip3 install git+https://github.com/mmabrouk/chatgpt-wrapper
erichlf commented 1 year ago

Fixed the above with pip3 install epc.

joshcho commented 1 year ago

Sorry about that. I will add all the relevant dependencies.

erichlf commented 1 year ago

However, now it just seems to sit there querying forever.

joshcho commented 1 year ago

Can you try the main troubleshooting method?

joshcho commented 1 year ago

pkill ms-playwright/firefox && chatgpt install

Followed by chatgpt-reset... hopefully works.

erichlf commented 1 year ago

I had to run chatgpt install and login again, then I had to do M-x chatgpt-reset and things seem to be working now. Thanks.

joshcho commented 1 year ago

Great. It's a bit unstable, for now. Hopefully it gets better. Please reopen this issue if there are any more issues.

erichlf commented 1 year ago

Maybe I don't understand how this works, but I selected an elisp function and the did C-c q and asked ChatGPT to help find the bug in the code and I got the following:

chatgpt--query-by-type: No format string associated with ’query-type’ Find the bug in the given function. Please customize ’chatgpt-query-format-string-map’
joshcho commented 1 year ago

Can you take a look at https://youtu.be/4oUrm4CnIjo? You want to select bug, or just type bug then enter, instead of Find the bug in the given function. If you want your own prepend prompt, then select custom, then type Find the bug in the given function.

You can also customize these selections as per README. I recommend a package like https://github.com/minad/vertico to choose between selections.

joshcho commented 1 year ago

Your workflow should be supported in https://github.com/joshcho/ChatGPT.el/commit/862c5b3d8cb38e2992ef9b4c05ef4d48aa523de2