boilerplaite

package module
v0.0.0-...-9a84353 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

boilerplaite

GoDoc Go Report Card

boilerplaite is a command-line tool and library to generate boilerplate code from a prompt using openai's chatgpt api.

demo

Installation

go install github.com/mvrilo/boilerplaite/cmd/boilerplaite@latest

Usage

boilerplaite is a package and cli tool to generate boilerplate code from a prompt using openai's chatgpt api.

Usage:
  boilerplaite [flags]

Examples:
boilerplaite -o ./examples/go-cli-example -p "go program, package main, using cobra"

Flags:
  -h, --help            help for boilerplaite
  -m, --model string    OpenAI model (default "gpt-3.5-turbo")
  -o, --output string   Output directory
  -p, --prompt string   Prompt
  -t, --timeout int     Timeout in seconds (default 60)
  -v, --verbose         Verbose logs

See examples below.

Configuration

Most options can be used as flags as shown below in "usage".

Except for OpenAI api key which must be set as environment variable: BOILERPLAITE_OPENAI_KEY

Examples

  • A Go program using cobra.
boilerplaite -o ./examples/go-cli-example -p "go program, package main, using cobra"
  • A Rust server using axum.
boilerplaite -o ./examples/rust-axum-hello -p "hello world program using rust with axum server and cli with clap"
  • SQL tables and queries
./boilerplaite -o ./examples/sql-users-table -p "sql file containing create table statement for users, insert and update queries, the table should include id, name and email"
  • A Python app using flask listening on port 3000.
./boilerplaite -o ./examples/python-flask-hello-world -p "python app using flask, hello world endpoint, listening on port 3000"
  • A Ruby app using sinatra, fetchin data from sqlite db, listening on port 5000, with extra files.
./boilerplaite -o ./examples/ruby-sinatra -p "a ruby app using sinatra, fetching some data from a sqlite database, listening on port 5000, with dockerfile, gemspec and bundle files"
  • A Ruby script for encoding data into sha256 from stdin to stdout
./boilerplaite -o ./examples/ruby-sha256 -p "ruby script for encoding data into sha256 from stdin to stdout"

Check the output here: ./examples.

Notes

  • Responses may contain innacurate or incorrect data.
  • GPT-3.5-turbo is used as default model.
  • Beware the high costs when changing the model to GPT-4.
  • No overwrites when writing to files.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutputExists = errors.New("Output directory already exists")

Functions

This section is empty.

Types

type Boilerplaite

type Boilerplaite struct {
	// contains filtered or unexported fields
}

func New

func New(openaiKey, openaiModel string) *Boilerplaite

func (*Boilerplaite) Complete

func (b *Boilerplaite) Complete(ctx context.Context, data string) (string, int, error)

func (*Boilerplaite) WriteFiles

func (b *Boilerplaite) WriteFiles(ctx context.Context, outdir string, data string) error

func (*Boilerplaite) WritePrompt

func (b *Boilerplaite) WritePrompt(ctx context.Context, outdir string, data string) error

Directories

Path Synopsis
cmd
boilerplaite command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址