Run ChatGPT in cli by using puppeteer communicate with chrome browser. It's a poor version of AutoGPT(The final goal). It's not perfect, but it works. You don't need to use api key to use this script. It's free.
poor_gpt_cli.mp4
gpt.mp4
- nodejs
- google chrome
- ChatGPT account logged in
npm install -g puppeteer
npm install -g html-to-text
- Start chrome with remote debugging port
chrome --remote-debugging-port=9999
-
Open https://chat.openai.com/ and login in your account and make tis tab visible, even it's not active and very small.
-
Run the script to start chatting
node poor-gpt.js <Query>
- Create a alias or shell script
gpt
#!/usr/bin/env bash
node <path-to-repo>/poor-gpt.js $*
for windows create a gpt.bat file
@echo off
node "<path-to-repo>/poor-gpt.js" %*
You can run the gpt command in any kind of editor. here just use Emacs for demo
(defun query-gpt-chat()
"Run script command with current line content and insert output in buffer"
(interactive)
(let ((current-line (thing-at-point 'line t))
(output (shell-command-to-string (concat "ngpt " (thing-at-point 'line t)))))
(insert (mapconcat 'identity (nthcdr 4 (split-string output "\n")) "\n"))))
(global-set-key (kbd "C-;") 'query-gpt-chat)
which ngpt just a alias to command node poor-gpt.js
- Add auto gpt feature