Skip to content

Commit

Permalink
Get model from cli, make gpt4 the default
Browse files Browse the repository at this point in the history
  • Loading branch information
spideyz0r committed Aug 15, 2023
1 parent 58cf3b1 commit e196d85
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ import (
openai "github.com/spideyz0r/openai-go"
)

const (
model = "gpt-3.5-turbo"
)

func main() {
help := getopt.BoolLong("help", 'h', "display this help")
apiKey := getopt.StringLong("api", 'a', "", "API key (default: OPENAI_API_KEY environment variable)")
temperature := getopt.StringLong("temperature", 't', "0.8", "temperature (default: 0.8)")
system_role := getopt.StringLong("system-role", 'r', "You're an expert in everything.", "system role (default: You're an expert in everything. You like speaking.)")
model := getopt.StringLong("model", 'm', "gpt-4", "gpt chat model (default: gpt-4)")
system_role := getopt.StringLong("system-role", 'S', "You're an expert in everything.", "system role (default: You're an expert in everything. You like speaking.)")
output_width := getopt.StringLong("output-width", 'w', "80", "output width (default: 80)")
delim := getopt.StringLong("delimiter", 'd', "\n", "set the delimiter for the user input (default: new line)")
stdin_input := getopt.BoolLong("stdin", 's', "read the message from stdin and exit (default: false)")
Expand Down Expand Up @@ -65,7 +62,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
output, err := sendMessage(client, messages, float32(t), uint(w))
output, err := sendMessage(client, messages, float32(t), uint(w), *model)
if err != nil {
log.Fatal(err)
}
Expand All @@ -87,7 +84,7 @@ func main() {
stop := make(chan bool)
go spinner(10*time.Millisecond, stop)

output, err := sendMessage(client, messages, float32(t), uint(w))
output, err := sendMessage(client, messages, float32(t), uint(w), *model)
if err != nil {
log.Fatal(err)
}
Expand All @@ -96,7 +93,7 @@ func main() {
}
}

func sendMessage(client *openai.OpenAIClient, messages []openai.Message, t float32, w uint) (string, error) {
func sendMessage(client *openai.OpenAIClient, messages []openai.Message, t float32, w uint, model string) (string, error) {
completion, err := client.GetCompletion(model, messages, t)
if err != nil {
return "", err
Expand Down

0 comments on commit e196d85

Please # to comment.