Skip to content

Latest commit

 

History

History
63 lines (50 loc) · 1.68 KB

README.md

File metadata and controls

63 lines (50 loc) · 1.68 KB

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.

Screenshots

Command line

poor_gpt_cli.mp4

Inside Emacs

gpt.mp4

Prerequisites

  • nodejs
  • google chrome
  • ChatGPT account logged in

Installation

npm install -g puppeteer
npm install -g html-to-text

Usage

  1. Start chrome with remote debugging port
chrome --remote-debugging-port=9999
  1. Open https://chat.openai.com/ and login in your account and make tis tab visible, even it's not active and very small.

  2. Run the script to start chatting

node poor-gpt.js <Query>
  1. 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" %*

Editor integration

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

todo list in the future

  • Add auto gpt feature