A custom CLI AI assistant made in Node.js with the OpenAI API.
-
Create an OpenAI account or sign in.
-
Navigate to the API key page and "Create new secret key".
-
Create an .env file in the root directory:
cp .env.example .env
-
Add your OpenAI API key to the .env file. Review/change other settings as needed.
-
Install dependencies and run the CLI:
npm install
To use the CLI:
node index.js
-
To install and use the CLI globally:
npm install -g . # or sudo npm install -g .
Then run the tool in your terminal from anywhere with the
ask
command.
Chat history is saved to the ./history
directory. Each conversation is saved in a separate file. The file name is the date and time the conversation ended.
The last text chat is automatically loaded when the CLI is started. To start a new chat, use the --new
or -n
flag:
ask -n
To clear the chat history, delete all files in the history directory.
ask -d