Create README.md
This commit is contained in:
42
README.md
Normal file
42
README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# go-gpt3
|
||||
[](https://godoc.org/github.com/sashabaranov/go-gpt3)
|
||||
|
||||
[OpenAI GPT-3](https://beta.openai.com/) API for Go
|
||||
|
||||
|
||||
Example usage:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
gogpt "github.com/sashabaranov/go-gpt3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := gogpt.NewClient("your token")
|
||||
ctx := context.Background()
|
||||
|
||||
req := gogpt.CompletionRequest{
|
||||
MaxTokens: 5,
|
||||
Prompt: "Lorem ipsum",
|
||||
}
|
||||
resp, err := c.CreateCompletion(ctx, "ada", req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(resp.Сhoices[0].Text)
|
||||
|
||||
searchReq := gogpt.SearchRequest{
|
||||
Documents: []string{"White House", "hospital", "school"},
|
||||
Query: "the president",
|
||||
}
|
||||
searchResp, err := c.Search(ctx, "ada", searchReq)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmt.Println(searchResp.SearchResults)
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user