ericthewizard / ai-cli

Simple terminal interface to GPT-3, with support for pipes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ai-cli

This is a command line interface for sending text to the OpenAI Completion API.

Installation

To install, clone the repository and run:

pip install -r requirements.txt

Then set the file to executable:

chmod +x ai

And place the folder in your PATH, and set your API key in the OPENAI_API_KEY environment variable.

Usage

To use the CLI, run:

ai [text] [options]

Where [text] is the text you want to send to the API and [options] are any of the optional arguments listed below.

Options

--model, default='text-davinci-003', type=str, help='The model to use for completion'
--max_tokens, default=256, type=int, help='The maximum number of tokens to generate'
--stop, default='', type=str, help='A string that, if encountered, will cause the API to stop generating tokens'
--temperature, default=0.0, type=float, help='sampling temperature (default: 0.0)'
--top_p, default=1.0, type=float, help='top-p filtering value (default: 1.0)'
--frequency_penalty, default=0.0, type=float, help='penalty for generating frequent tokens (default: 0.0)'
--presence_penalty, default=0.0, type=float, help='penalty for generating tokens not present in the prompt (default: 0.0)'
--best_of, default=3, type=float, help='An optional integer specifying the number of completions to generate server-side and return the "best" (the one with the highest log probability per token)'

Examples

Create a simple "Hello World" program

Input:

ai write a python function that prints hello world

Output:

def print_hello_world():
  print("Hello World")

print_hello_world()

Create a Flask app

Input:

ai write a Flask app that has 2 endpoints: / and /about

Output:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def home():
    return 'This is the home page'

@app.route('/about')
def about():
    return 'This is the about page'

if __name__ == '__main__':
    app.run()

Write a sonnet

Input:

ai write a sonnet about a dog named chip

Output:

Chip, my loyal pup, so full of love and joy,
Your wagging tail and happy bark bring me delight.
Your furry coat of brown and white, a sight to enjoy,
Your playful nature, so full of life and light.

Your eyes so bright, your nose so wet and cold,
Your bark so loud, your tail so full of wag.
Your love so strong, your loyalty so bold,
Your friendship, a treasure I will never lag.

Your loyalty and love, so strong and true,
Your friendship, a bond that will never break.
Your joy and happiness, so pure and true,
Your presence, a blessing I will never forsake.

Chip, my loyal pup, so full of love and joy,
Your friendship, a blessing I will always enjoy.

Describe the files in a directory

Input:

ls | ai write a description of each file

Output:

release_pyspedas.sh: A shell script to automate the release of the Pyspedas package.
release_pytplot.sh: A shell script to automate the release of the Pytplot package.

Write a Flask app, then write a poem about the app

Input:

ai write a Flask app with 3 endpoints: /, /about, /posts. Python code | ai describe the code in a rhyming poem

Output:

A Flask app is what we've got
It's routes are all quite hot
Home, About, and Posts, they all appear
To make a website that's quite clear

About

Simple terminal interface to GPT-3, with support for pipes

License:MIT License


Languages

Language:Python 100.0%