Skip to content

pathikrit/chatgpt-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT CLI

This is a tiny (<500 LoC) toy program written in node.js to run ChatGPT in your terminal that supports:

Setup

  1. Install node.js e.g. using brew:
brew install node
  1. Start the app:
export OPENAI_API_KEY=XXXXXXXX # Get from https://platform.openai.com/account/api-keys
npx [email protected]:pathikrit/chatgpt-cli.git

Alternatively, you can clone and run:

git clone [email protected]:pathikrit/chatgpt-cli.git
cd chatgpt-cli
yarn && node app.js

demo

Usage

System commands:
  * clear / clr     : Clear chat history
  * copy / cp       : Copy last message to clipboard
  * history / h     : Show current history
  * export          : Save current chat history as ChatML doc
  * speak / say     : Speak out last response
  * help / ?        : Show this message
  * exit / quit / q : Exit the program

Usage Tips:
  - For multiline chats press PageDown
  - Use Up/Down array keys to scrub through previous messages  
  - Include [web] anywhere in your prompt to force web browsing
  - Include [img] anywhere in your prompt to generate an image
  - Enter a local path or url, to ingest text from it and add to context
  - Use TAB to do path completions when entering file (or folder path)

Web Browsing

Some queries depend on up-to-date info e.g.:

> Whats the weather like in nyc today?
⚠ I do not have real-time information. Please check a weather website or app for the current weather in NYC.

To enable browsing, you need to setup Google API keys:

export GOOGLE_CUSTOM_SEARCH_ENGINE_ID=XXXXX # Get from https://www.google.com/cse/create/new
export GOOGLE_CUSTOM_SEARCH_API_KEY=XXXXX # Get from https://developers.google.com/custom-search/v1/introduction

Now you will get:

> Whats the weather like in nyc today?
⚠ I do not have real-time information. Please check a weather website or app for the current weather in NYC.
⠸ Searching the web ...
✔ As of April 19, 2023, the weather in New York City today is cloudy with a temperature of 67°F (19.4°C).

You can also force web browsing by including [web] anywhere in your prompt.

Chatting with documents

Give a file path or folder (hit tab to autocomplete paths):

> ~/Downloads/Principles by Ray Dalio.pdf
✔ Ingested ~/Downloads/Principles by Ray Dalio.pdf. Here's a summary of first 10 pages:
Ray Dalio's book, Principles, is divided into three parts. 
Part 1 explains the purpose and importance of having principles in general. 
Part 2 explains Ray's most fundamental life principles. 
Part 3 explains Ray's management principles and how they are being applied at Bridgewater. 
Ray encourages readers to think for themselves and make clear-headed decisions in order to get what they want.
────────────────────────────────────────────────────────────────────────────────────
> What's the top management principle?
✔ Based on the snippets provided, it seems that Ray Dalio's management principles emphasize the importance of clear communication, delineation of responsibilities, logic and reason in decision-making, constant feedback and discussion, matching the right people to the job, synthesizing and connecting the dots, and a problem-solving approach. 
────────────────────────────────────────────────────────────────────────────────────

Chat with webpages

> https://www.nytimes.com/2023/04/14/opinion/china-america-relationship.html
✔ Ingested https://www.nytimes.com/2023/04/14/opinion/china-america-relationship.html. Here's a summary of first 10 pages:
This article discusses the relationship between the United States and China, and how a trip to Beijing and Taiwan showed the author how the two countries are both fated to cooperate and doomed to compete.
───────────────────────────────

About

Simple CLI for ChatGPT using node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published