Giter Site home page Giter Site logo

ai-cli's Introduction

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

ai-cli's People

Contributors

ericthewizard avatar

Watchers

 avatar Kostas Georgiou 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.