Giter VIP home page Giter VIP logo

gpt-on-cli's Introduction

 ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄       ▄▄▄▄▄▄▄▄▄▄▄  ▄            ▄▄▄▄▄▄▄▄▄▄▄ 
▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌     ▐░░░░░░░░░░░▌▐░▌          ▐░░░░░░░░░░░▌
▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀█░█▀▀▀▀      ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌           ▀▀▀▀█░█▀▀▀▀ 
▐░▌          ▐░▌       ▐░▌     ▐░▌          ▐░▌          ▐░▌               ▐░▌     
▐░▌ ▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌     ▐░▌          ▐░▌          ▐░▌               ▐░▌     
▐░▌▐░░░░░░░░▌▐░░░░░░░░░░░▌     ▐░▌          ▐░▌          ▐░▌               ▐░▌     
▐░▌ ▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀      ▐░▌          ▐░▌          ▐░▌               ▐░▌     
▐░▌       ▐░▌▐░▌               ▐░▌          ▐░▌          ▐░▌               ▐░▌     
▐░█▄▄▄▄▄▄▄█░▌▐░▌               ▐░▌          ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄▄▄  ▄▄▄▄█░█▄▄▄▄ 
▐░░░░░░░░░░░▌▐░▌               ▐░▌          ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
 ▀▀▀▀▀▀▀▀▀▀▀  ▀                 ▀            ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀ 
                                                                                   

Source for ASCII-fonts: https://www.coolgenerator.com/ascii-text-generator (Font: Electronic)

What is this?

Provide access to GPT 3 model via CLI encapsulated as a docker container.

What's the motivation?

To stay in the terminal when having a question (e.g. on how a certain command works)

Setup

Pre-requisites

Ensure to have docker installed and running. An OpenAI API key.

1 Configure preferences and provide OpenAI API key

The GPT model will be prepared to give answers fitting to your environment and liking. These preferences will be provided together with the API key in a .env file which will be stored inside the docker container. Therefore it is not recommended to upload your image to a public repository.

Create a new .env' file in this root folder of this project. The .envis listed in the.gitignore` file and will not be uploaded to the repository. Feel free to experiment with your own values the perference properties.

Here is an example:

GPT_MODEL = "gpt-4"
# GPT_MODEL = "gpt-3.5-turbo"

TARGET_OS = "Manjaro Linux"
# TARGET_OS = "Arch Linx"
# TARGET_OS = "MacOS"
# TARGET_OS = "Ubuntu"

# HUMOUR_STYLE = "none"
HUMOUR_STYLE = "friendly"
# HUMOUR_STYLE = "friendly ironic"
# HUMOUR_STYLE = "mean sarcastic"

TERMINAL_EMULATOR = "very simple"
# TERMINAL_EMULATOR = "Kitty"
# TERMINAL_EMULATOR = "Alacritty"
# TERMINAL_EMULATOR = "iTerm2"

OPENAI_KEY = "<your OpenAI API key>"

You should have a similar project structure like this:

.
├── dist
├── node_modules
├── src
├── test
├── .vscode
├── .git
├── .env  <------------- Your config file
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── Dockerfile
├── package.json
├── pnpm-lock.yaml
├── README.md
├── gpt-on-cli.code-workspace
└── tsconfig.json

2 Create a local docker image

Run the following command inside the project root to create the local docker image:

docker buildx build -t jni-gpt-on-cli .

Alternatively you can run pnpm run build-image if you have pnpm installed.

3 Add an alias to your .zshrc or .bashrc

Add the following lines to your .zshrc or .bashrc file:

# JNI's GPT on CLI
alias ai='docker container run --rm jni-gpt-on-cli'

Usage

Pass your quoted question as an argument to the ai command:

Usage example Result of HUMOUR_STYLE = "friendly ironic"

The general usage info reads like this:

Usage: ai [OPTIONS] [STRING]

Options:
  -h, --help       Show this message and exit.
  -v, --version   Show version info and exit.

Additional Information

Project Maintenance

To update all packages to the latest version pnpm up --latest to update all packages to the latest version.

To add a new package to the project pnpm add -D <package> to add a package to the project. The -D flag is for development dependencies.

Release History

v0.3.0

  • Add support for different GPT models.

v0.2.2

  • Tweak colors.

v0.2.1

  • Better handle unclean answers from GPT model.

v0.2.0

  • Improve AI prompt.
  • Improve output formatting.
  • Add color and improve waiting animation.
  • General code cleanup and refactoring.

v0.1.0

  • Initial project version

gpt-on-cli's People

Contributors

mopore avatar

Stargazers

Ahmed Hasnaoui avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.