openai

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config Config
}

func NewClient

func NewClient(config Config) *Client

NewClient creates a new OpenAI client.

func (*Client) Explain added in v0.1.5

func (c *Client) Explain(command string) (string, error)

Explain explains a command.

func (*Client) Suggest

func (c *Client) Suggest(query string) (string, error)

Suggest suggests a command for a given query.

type Config

type Config struct {
	// ApiKey is the OpenAI API key.
	ApiKey string `config:"openai.apikey"`
	// OpenAI request configuration
	RequestBase
}

type RequestBase

type RequestBase struct {
	Model            string  `json:"model" config:"openai.model"`
	Temperature      float64 `json:"temperature" config:"openai.temperature"`
	MaxTokens        int     `json:"max_tokens" config:"openai.maxtokens"`
	TopP             float64 `json:"top_p" config:"openai.topp"`
	FrequencyPenalty float64 `json:"frequency_penalty" config:"openai.frequencypenalty"`
	PresencePenalty  float64 `json:"presence_penalty" config:"openai.presencepenalty"`
}

RequestBase will be used in the request body.

Jump to

Keyboard shortcuts

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