cache

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = fmt.Errorf("cache miss")

Functions

This section is empty.

Types

type Cache

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

func New

func New(embedder Embedder, index Index) *Cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, query string) (*Result, error)

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, embedding []float64, answer string) error

func (*Cache) WithScoreThreshold

func (c *Cache) WithScoreThreshold(scoreThreshold float64) *Cache

func (*Cache) WithTopK

func (c *Cache) WithTopK(topK int) *Cache

type Embedder

type Embedder interface {
	Embed(ctx context.Context, texts []string) ([]embedder.Embedding, error)
}

type Index

type Index interface {
	Search(context.Context, []float64, ...indexoption.Option) (index.SearchResults, error)
	Add(context.Context, *index.Data) error
}

type Result

type Result struct {
	Answer    []string
	Embedding []float64
}

Jump to

Keyboard shortcuts

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