openai

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResponse = errors.New("no reponse")

ErrNoResponse thrown when there is no response from the open ai API.

Functions

This section is empty.

Types

type Client

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

Client holds the OpenAI client and some configuration.

func New

func New(logger *slog.Logger, apiKey string, opts ...OptFunc) Client

New returns a new OpenAI client.

func (Client) Prompt

func (c Client) Prompt(ctx context.Context, prompt string) (string, error)

Prompt executes a prompt to the OpenAI endpoints

type OptFunc

type OptFunc func(store *Client)

OptFunc used for setting optional configs.

func WithBaseUrl

func WithBaseUrl(url string) OptFunc

WithBaseUrl sets the Client baseUrl optional param.

func WithCustomContext

func WithCustomContext(ctx string) OptFunc

WithBaseUrl sets the Client prompt context optional param.

func WithModel

func WithModel(model string) OptFunc

WithBaseUrl sets the Client model optional param.

Jump to

Keyboard shortcuts

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