more stuff

This commit is contained in:
Jeff Carr 2022-12-03 19:56:58 -06:00
parent 0f6351ab29
commit 3ec14cc65f
7 changed files with 82 additions and 6 deletions

View File

@ -1,7 +1,8 @@
build:
# reset
GO111MODULE="off" go build -v -x complicated.go
# GO111MODULE="off" go build -v -x
# GO111MODULE="off" go build -v -x complicated.go
GO111MODULE="off" go build -v -x
./example-gpt-3
deps:
go get github.com/openai/gpt-3

View File

@ -5,9 +5,14 @@ package main
*/
import (
"fmt"
"github.com/openai/gpt-3"
"time"
"context"
"fmt"
"log"
"os"
"github.com/PullRequestInc/go-gpt3"
"github.com/joho/godotenv"
)
func main() {
@ -81,4 +86,3 @@ func main() {
log.Println("i, c =", i, c)
}
}

View File

@ -0,0 +1,12 @@
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "Summarize this for a second-grade student:\n\nJupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.",
"temperature": 0.7,
"max_tokens": 64,
"top_p": 1.0,
"frequency_penalty": 0.0,
"presence_penalty": 0.0
}'

View File

@ -0,0 +1,12 @@
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "Summarize this for a second-grade student:\n\nJupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.",
"temperature": 0.7,
"max_tokens": 64,
"top_p": 1.0,
"frequency_penalty": 0.0,
"presence_penalty": 0.0
}'

View File

@ -16,3 +16,17 @@ curl https://api.openai.com/v1/completions \
"presence_penalty": 0.0,
"stop": ["\n"]
}'
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "What color is the sky?",
"temperature": 0,
"max_tokens": 100,
"top_p": 1.0,
"frequency_penalty": 0.2,
"presence_penalty": 0.0,
"stop": ["\n"]
}'

View File

@ -0,0 +1,13 @@
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "Convert this text to a programmatic command:\n\nExample: Ask Constance if we need some bread\nOutput: send-msg `find constance` Do we need some bread?\n\nReach out to the ski store and figure out if I can get my skis fixed before I leave on Thursday",
"temperature": 0,
"max_tokens": 100,
"top_p": 1.0,
"frequency_penalty": 0.2,
"presence_penalty": 0.0,
"stop": ["\n"]
}'

View File

@ -9,6 +9,7 @@ import (
"github.com/PullRequestInc/go-gpt3"
"github.com/joho/godotenv"
)
import "github.com/davecgh/go-spew/spew"
func main() {
godotenv.Load()
@ -22,6 +23,10 @@ func main() {
ctx := context.Background()
client := gpt3.NewClient(apiKey)
eng, _ := client.Engines(ctx)
log.Println("engines =", eng)
spew.Dump(eng)
resp, err := client.Completion(ctx, gpt3.CompletionRequest{
Prompt: []string{"The first thing you should know about javascript is"},
MaxTokens: gpt3.IntPtr(30),
@ -32,4 +37,19 @@ func main() {
log.Fatalln(err)
}
fmt.Println(resp.Choices[0].Text)
spew.Dump(resp)
/*
resp, err = client.Completion(ctx, gpt3.CompletionRequest{
Prompt: []string{"The first thing you should know about javascript is"},
MaxTokens: gpt3.IntPtr(30),
Stop: []string{"."},
Echo: true,
Engine: "babbage",
})
if err != nil {
log.Fatalln(err)
}
fmt.Println(resp.Choices[0].Text)
*/
}