openai

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: LGPL-3.0 Imports: 7 Imported by: 1

README

openai

API Integration with OpenAI

Documentation

Index

Constants

View Source
const (
	OPENAI_TOKEN  = "OPENAI_TOKEN"
	OPENAI_PREFIX = "openai-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenAIClient

type OpenAIClient struct {
	Client *openai.Client
	Model  string
}

func NewOpenAIClient

func NewOpenAIClient(model string) (*OpenAIClient, error)

NewClient creates a new OpenAI API client using an environment variable.

func (*OpenAIClient) Prompt

func (c *OpenAIClient) Prompt(ctx context.Context, messages []openai.ChatCompletionMessage) (string, error)

Prompt prompts the OpenAI API with a list of messages using 0.000001 temperature and a retry mechanism.

Jump to

Keyboard shortcuts

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