Added ChatGPT query API for Emacs.

This is incomplete and does not currently work on my personal
machine, due to how NixOS handles pip.
This commit is contained in:
James Patrick 2023-04-23 22:28:17 -04:00
parent c6f470bb4b
commit 8e886e9135
4 changed files with 52 additions and 0 deletions

9
emacs/+chatGPT.el Normal file
View File

@ -0,0 +1,9 @@
(use-package! chatgpt
:defer t
:config
(unless (boundp 'python-interpreter)
(defvaralias 'python-interpreter 'python-shell-interpreter))
(setq chatgpt-repo-path (expand-file-name "straight/repos/ChatGPT.el/" doom-local-dir))
(set-popup-rule! (regexp-quote "*ChatGPT*")
:side 'bottom :size .5 :ttl nil :quit t :modeline nil)
:bind ("C-c q" . chatgpt-query))

View File

@ -35,3 +35,5 @@
(load! "+keybinds") (load! "+keybinds")
(load! "+orgmode") (load! "+orgmode")
(load! "+chatGPT")

View File

@ -843,6 +843,44 @@ cat a.org
;(add-hook 'mixed-pitch-mode-hook #'solaire-mode-reset) ;(add-hook 'mixed-pitch-mode-hook #'solaire-mode-reset)
#+end_src #+end_src
** ChatGPT
ChatGPT is good for creating short summaries about technical subjects. Its may be incorrect & does not produce citations, and is effectively just cargo culting, but may help me fill out some Roam docs quickly among other things.
We will be using the [[https://github.com/joshcho/ChatGPT.el][joshcho/ChatGPT.el]] package
To install this
#+BEGIN_SRC emacs-lisp :tangle "packages.el"
(package! chatgpt
:recipe (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")))
#+END_SRC
Logic for this will be found in =$DOOMDIR/+chatGPT.el=
#+begin_src emacs-lisp
(load! "+chatGPT")
#+end_src
Then use =use-package!= to configure. =C-c q= is the bind for this.
#+begin_src emacs-lisp :tangle "+chatGPT.el" :noweb no-export :comments no
(use-package! chatgpt
:defer t
:config
(unless (boundp 'python-interpreter)
(defvaralias 'python-interpreter 'python-shell-interpreter))
(setq chatgpt-repo-path (expand-file-name "straight/repos/ChatGPT.el/" doom-local-dir))
(set-popup-rule! (regexp-quote "*ChatGPT*")
:side 'bottom :size .5 :ttl nil :quit t :modeline nil)
:bind ("C-c q" . chatgpt-query))
#+end_src
This runs the =chatgpt.py= file. There are a couple of dependencies, to install run the following:
#+begin_src bash :tangle no
pip install sexpdata==0.0.3
pip install epc
pip install git+https://github.com/mmabrouk/chatgpt-wrapper
chatgpt install
#+end_src
* Content Stolen From * Content Stolen From
A large amount of the details listed here have been lifted from: A large amount of the details listed here have been lifted from:
- [[https://tecosaur.github.io/emacs-config/][tecosaur's literate configuration]]. - [[https://tecosaur.github.io/emacs-config/][tecosaur's literate configuration]].

View File

@ -1,3 +1,6 @@
;;; packages.el -*- lexical-binding: t; -*- ;;; packages.el -*- lexical-binding: t; -*-
(package! ob-mermaid) (package! ob-mermaid)
(package! chatgpt
:recipe (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")))