Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 707 Bytes

README.md

File metadata and controls

40 lines (32 loc) · 707 Bytes

go-gpt

OpenAI GPT-3 API wrapper for Go #官方文档 #例子 #官方playground

Installation:

go get github.com/vurtneyang/go-gpt

Example usage:

package main

import (
	"context"
	"fmt"
	gogpt "github.com/vurtneyang/go-gpt"
)

func main() {
	c := gogpt.NewClient("your token")
	ctx := context.Background()

	req := gogpt.CompletionRequest{
		Model:     gogpt.GPT3Ada,
		MaxTokens: 5,
		Prompt:    "Lorem ipsum",
	}
	resp, err := c.CreateCompletion(ctx, req)
	if err != nil {
		return
	}
	fmt.Println(resp.Choices[0].Text)
}