From 0b788a8ae19185f20880cb7d4627d5836dc318ba Mon Sep 17 00:00:00 2001 From: sashabaranov <677093+sashabaranov@users.noreply.github.com> Date: Wed, 19 Aug 2020 13:06:47 +0300 Subject: [PATCH] Create README.md --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..869f6be --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# go-gpt3 +[![GoDoc](http://img.shields.io/badge/GoDoc-Reference-blue.svg)](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) +} +```