Use ChatGPT in your terminal. Kind of feels like a bash utility?
curl https://raw.githubusercontent.com/lunabrain-ai/lunapipe/main/scripts/install.sh | sh
or
go install github.com/lunabrain-ai/lunapipe@latest
or if you are looking for other releases, go to releases.
export OPENAI_API_KEY="<your openai api key>"
lunapipe "Write me a go function that prints 'Hello World'"
Here's an example Go function that prints "Hello World" to the console:
```go
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
```
To have your API key persist, you can use:
lunapipe configure
Enter your API key: <your openai api key>
Wrote API key to ~/.lunapipe/config.yaml
Don't have an API key? Sign up here and generate an API key here.
You can pipe text into lunapipe. For example, if you have a file called main.go
that contains the following code:
ls | lunapipe "Based on the files, what language is this repo?"
This repo is written in Go (also known as Golang).
You can use templates to generate code. For example, if you want to generate a go function that prints "Hello World", you can use the following template:
lunapipe -t function -p language=go "Read values from a map"
# create an alias to code even faster
alias aigo="lunapipe -t function -p language=go"
aigo "Read values from a map"
To see all available templates, check out the available prompt templates.
To define your own templates, you can pass a directory to where your templates are:
mkdir my_prompt_templates
echo "This is a test" > my_prompt_templates/test.tmpl
lunapipe --prompts my_prompt_templates -t test "Is this thing working?"
# If you want to add parameters to your template
echo 'This is a test with params: {{ index .Params "testparam" }} ' > my_prompt_templates/test_with_params.tmpl
lunapipe --prompts my_prompt_templates -t test -p testparam="Hello, world!" "Is this thing working?"
You can use different models to generate your code. For example, if you want to generate a go function that prints "Hello World", you can use the following model:
lunapipe -m gpt-4 "Read values from a map"
The default model is gpt-3.5-turbo
, but you can use any of the following models:
- gpt4
- gpt-3.5-turbo
LOG_LEVEL=debug go run main.go "Test prompt"
go run main.go
go build main.go