openai

package
v2.0.27 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExists = errors.New("key does not exist")

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(apiKey string, db *badger.DB, logger *logging.Logger) *Client

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(input string, model oai.EmbeddingModel) (*oai.Embedding, error)

type ClientV2 added in v2.0.23

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

func NewClientV2 added in v2.0.23

func NewClientV2(apiKey string, kv KVStore, logger zLogger.ZLogger) *ClientV2

func (*ClientV2) CreateEmbedding added in v2.0.23

func (c *ClientV2) CreateEmbedding(input string, model oai.EmbeddingModel) (*oai.Embedding, error)

type EmbeddingRequest

type EmbeddingRequest struct {
	Input          string `json:"input"`
	Model          string `json:"model"`
	EncodingFormat string `json:"encoding_format,omitempty"`
	User           string `json:"user,omitempty"`
}

type EmbeddingResult

type EmbeddingResult struct {
	Vector []float64 `json:"embedding"`
	Index  int       `json:"index"`
	Object string    `json:"object"`
}

type KVBadger added in v2.0.23

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

func NewKVBadger added in v2.0.23

func NewKVBadger(db *badger.DB) *KVBadger

func (*KVBadger) Get added in v2.0.23

func (k *KVBadger) Get(key string) (*oai.Embedding, error)

func (*KVBadger) Set added in v2.0.23

func (k *KVBadger) Set(key string, value *oai.Embedding) error

type KVGCache added in v2.0.23

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

func NewKVGCache added in v2.0.23

func NewKVGCache(cache gcache.Cache) *KVGCache

func (*KVGCache) Get added in v2.0.23

func (k *KVGCache) Get(key string) (*oai.Embedding, error)

func (*KVGCache) Set added in v2.0.23

func (k *KVGCache) Set(key string, value *oai.Embedding) error

type KVStore added in v2.0.23

type KVStore interface {
	Get(key string) (*oai.Embedding, error)
	Set(key string, value *oai.Embedding) error
}

Jump to

Keyboard shortcuts

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