emacs-openai / openai

Elisp library for the OpenAI API
GNU General Public License v3.0
100 stars 17 forks source link

Cannot install openai #25

Closed beyondpie closed 1 year ago

beyondpie commented 1 year ago

Hi there,

when I plan to use chatgpt, it says no openai. Later I found that it depends on this repo. But seems like we cannot use use-package to install this package?

Furthermore, is that possible to use API-KEY like this? Typically we don't want to expose our KEY, but the way in this package to hide key seems a little bit difficult for me (sorry that I am not that familiar with Emacs)...

Thanks! Songpeng

jcs090218 commented 1 year ago

when I plan to use chatgpt, it says no openai. Later I found that it depends on this repo. But seems like we cannot use use-package to install this package?

The package is NOT on MELPA, so that's why. You would have to use JCS-ELPA instead.

Furthermore, is that possible to use API-KEY like this? Typically we don't want to expose our KEY, but the way in this package to hide key seems a little bit difficult for me (sorry that I am not that familiar with Emacs)...

The standard way to store keys/secrets in Emacs is through auth-source. See our README.md you will find:

(setq openai-key #'openai-key-auth-source)

or just getenv:

(setq openai-key #(getenv "OPENAI_API_KEY"))  ; You can name whatever you want!

P.S. It's a bit hard to use auth-source the first time, but it's the standard in Emacs.

beyondpie commented 1 year ago

Thanks for the comments.

  1. I tried auth-source long ago, but did not get it work very well. Then I just ignore it. But I will keep one eye on it. But thank you for the method you suggested!
  2. I actually use-package and combine with straight-like way to install openai, but did not succeed.
;; under Emacs >= 29.1
(cl-defun slot/vc-install (&key (fetcher "github") repo name rev backend)
(use-package openai
  :init (slot/vc-install :fetcher "github" :repo "emacs-openai/openai"))

I use this method to install chatgpt, but did not work on openai. I will try it again then.

Thanks! Songpeng

jcs090218 commented 1 year ago

If you are using striaght.el:

(use-package openai
  :straight (openai :type git :host github :repo "emacs-openai/openai"))

Why did you close it? Did you manage to solve it? 🤔

beyondpie commented 1 year ago

Hi, I can now install openai. I don't know, it just works. But M-x chatgpt, and insert "hi", will have 404 error.... I have insert my token and bought GPT service. So I just give it up, and use it in the browser...

But thank you so much for your responses! You are really patient. I also notice that you are one of the authors of emacs tree-sitter. That's a really great package!

jcs090218 commented 1 year ago

But M-x chatgpt, and insert "hi", will have 404 error.... I have insert my token and bought GPT service.

Try our debugging section, see https://github.com/emacs-openai/openai#-debugging. It should give you detailed information! 🤔

But thank you so much for your responses! You are really patient. I also notice that you are one of the authors of emacs tree-sitter. That's a really great package!

Thank you! ❤️ But I am not the author of emacs tree-sitter, I did contribute a little but mainly because of the package ts-fold.