# README
OpenAI
Overview
This is a library implemented in Go for OpenAI API. It supports:
Install
go get github.com/mengbin92/openai
ChatGPT example code
package main
import (
"context"
"fmt"
"os"
"github.com/mengbin92/openai"
)
func main() {
client := openai.NewClient("your token", "your org", "proxy")
resp, err := client.CreateChatCompletion(
context.Background(),
&openai.ChatCompletionRequset{
Model: openai.GPT3Dot5Turbo,
Messages: []openai.Message{
{Role: openai.ChatMessageRoleUser, Content: "hi!"},
},
},
)
if err != nil {
fmt.Printf("CreateChatCompletion error: %s\n", err.Error())
os.Exit(-1)
}
fmt.Println(resp.Choices[0].Message.Content)
}
# Packages
No description provided by the author
# Functions
NewClient creates and returns a new instance of the Client struct.
No description provided by the author
# Constants
chat role defined by OpenAI.
chat role defined by OpenAI.
chat role defined by OpenAI.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
update 2023/06/14.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
model list from https://platform.openai.com/docs/models/model-endpoint-compatibility.
# Structs
APIError provides error information returned by the OpenAI API.
No description provided by the author
No description provided by the author
ChatCompletionRequest struct defines the openAI ChatCompletionRequest type.
No description provided by the author
No description provided by the author
Clinet is the openAI API client.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
The RequestFactory interface defines the behavior for creating an http.Request object given certain parameters.