openai

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenAI

type OpenAI struct {
	StripNewLines bool
	BatchSize     int
	// contains filtered or unexported fields
}

OpenAI is the embedder using the OpenAI api.

func NewOpenAI

func NewOpenAI(opts ...Option) (OpenAI, error)

NewOpenAI creates a new OpenAI with options. Options for client, strip new lines and batch.

func (OpenAI) EmbedDocuments

func (e OpenAI) EmbedDocuments(ctx context.Context, texts []string) ([][]float64, error)

EmbedDocuments creates one vector embedding for each of the texts.

func (OpenAI) EmbedQuery

func (e OpenAI) EmbedQuery(ctx context.Context, text string) ([]float64, error)

EmbedQuery embeds a single text.

type Option

type Option func(p *OpenAI)

Option is a function type that can be used to modify the client.

func WithBatchSize

func WithBatchSize(batchSize int) Option

WithBatchSize is an option for specifying the batch size.

func WithClient

func WithClient(client openai.LLM) Option

WithClient is an option for providing the LLM client.

func WithStripNewLines

func WithStripNewLines(stripNewLines bool) Option

WithStripNewLines is an option for specifying the should it strip new lines.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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