openai

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModel = openai.GPT3Dot5Turbo

Functions

func GetModel added in v0.0.2

func GetModel(model string) string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Clint for OpenAI client interface

func New

func New(opts ...Option) (*Client, error)

New for initialize OpenAI client interface.

func (*Client) Completion

func (c *Client) Completion(
	ctx context.Context,
	content string,
) (string, error)

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(
	ctx context.Context,
	content string,
) (resp openai.ChatCompletionResponse, err error)

CreateChatCompletion — API call to Create a completion for the chat message.

func (*Client) CreateCompletion

func (c *Client) CreateCompletion(
	ctx context.Context,
	content string,
) (resp openai.CompletionResponse, err error)

CreateCompletion — API call to create a completion. This is the main endpoint of the API. Returns new text as well as, if requested, the probabilities over each alternative token at each position.

If using a fine-tuned model, simply provide the model's ID in the CompletionRequest object, and the server will use the model's parameters to generate the completion.

type Option added in v0.0.5

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface that specifies instrumentation configuration options.

func WithModel added in v0.0.5

func WithModel(val string) Option

WithModel is a function that returns an Option, which sets the model field of the config struct.

func WithOrgID added in v0.0.5

func WithOrgID(val string) Option

WithOrgID is a function that returns an Option, which sets the orgID field of the config struct.

func WithProxyURL added in v0.0.5

func WithProxyURL(val string) Option

WithProxyURL is a function that returns an Option, which sets the proxyURL field of the config struct.

func WithToken added in v0.0.5

func WithToken(val string) Option

WithToken is a function that returns an Option, which sets the token field of the config struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL