index

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultKeyID      = "id"
	DefaultKeyContent = "content"
)

Variables

View Source
var (
	ErrInternal = errors.New("internal index error")
)

Functions

func DeepCopyMetadata added in v0.0.10

func DeepCopyMetadata(metadata types.Meta) types.Meta

func GetDefaultOptions added in v0.0.12

func GetDefaultOptions() *option.Options

Types

type AddDataCallback added in v0.0.12

type AddDataCallback func(data *Data) error

type Data added in v0.0.11

type Data struct {
	ID       string
	Values   []float64
	Metadata types.Meta
}

type Embedder

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

type Index added in v0.0.12

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

func New added in v0.0.12

func New(vectorDB VectorDB, embedder Embedder) *Index

func (*Index) Add added in v0.0.12

func (i *Index) Add(ctx context.Context, data *Data) error

func (*Index) Drop added in v0.1.0

func (i *Index) Drop(ctx context.Context) error

func (*Index) Embedder added in v0.1.0

func (i *Index) Embedder() Embedder

func (*Index) IsEmpty added in v0.0.12

func (i *Index) IsEmpty(ctx context.Context) (bool, error)

func (*Index) LoadFromDocuments added in v0.0.12

func (i *Index) LoadFromDocuments(ctx context.Context, documents []document.Document) error

func (*Index) Query added in v0.0.12

func (i *Index) Query(ctx context.Context, query string, opts ...option.Option) (SearchResults, error)

func (*Index) Search added in v0.0.12

func (i *Index) Search(ctx context.Context, values []float64, opts ...option.Option) (SearchResults, error)

func (*Index) WithAddDataCallback added in v0.0.12

func (i *Index) WithAddDataCallback(callback AddDataCallback) *Index

WithAddDataCallback allows to modify the data before it is added to the index. This can be useful to add additional metadata to the vector.

func (*Index) WithBatchInsertSize added in v0.0.12

func (i *Index) WithBatchInsertSize(batchInsertSize int) *Index

func (*Index) WithIncludeContents added in v0.0.12

func (i *Index) WithIncludeContents(includeContents bool) *Index

type SearchResult added in v0.0.11

type SearchResult struct {
	Data
	Score float64
}

func (*SearchResult) Content added in v0.0.11

func (s *SearchResult) Content() string

type SearchResults added in v0.0.11

type SearchResults []SearchResult

func (SearchResults) ToDocuments added in v0.0.11

func (s SearchResults) ToDocuments() []document.Document

type VectorDB added in v0.0.12

type VectorDB interface {
	Insert(context.Context, []Data) error
	IsEmpty(context.Context) (bool, error)
	Search(context.Context, []float64, *option.Options) (SearchResults, error)
	Drop(ctx context.Context) error
	Delete(ctx context.Context, ids []string) error
}

Directories

Path Synopsis
vectordb

Jump to

Keyboard shortcuts

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