localvectordb

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cosine

func Cosine[T Float](a []T, b []T) T

Cosine 计算cosine [-1,1],越大越相似

func GetMetaID added in v0.5.3

func GetMetaID(m map[string]any) (string, bool)

func PutMetaID added in v0.5.3

func PutMetaID(m *map[string]any, id string)

Types

type DB

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

func New

func New(path string) (DB, error)

func (DB) Close

func (s DB) Close() error

func (DB) Delete

func (s DB) Delete(namespace string) error

func (DB) Get

func (s DB) Get(embedder embeddings.Embedder, namespace string, maxGo int) (Store, error)

func (DB) List

func (s DB) List() ([]string, error)

type Doc

type Doc struct {
	Id                   string    `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Content              string    `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
	Vector               []float32 `protobuf:"fixed32,3,rep,packed,name=vector,proto3" json:"vector,omitempty"`
	Meta                 []byte    `protobuf:"bytes,4,opt,name=meta,proto3" json:"meta,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

Doc

func (*Doc) Descriptor

func (*Doc) Descriptor() ([]byte, []int)

func (*Doc) GetContent

func (m *Doc) GetContent() string

func (*Doc) GetId

func (m *Doc) GetId() string

func (*Doc) GetMeta

func (m *Doc) GetMeta() []byte

func (*Doc) GetVector

func (m *Doc) GetVector() []float32

func (*Doc) ProtoMessage

func (*Doc) ProtoMessage()

func (*Doc) Reset

func (m *Doc) Reset()

func (*Doc) String

func (m *Doc) String() string

func (*Doc) XXX_DiscardUnknown

func (m *Doc) XXX_DiscardUnknown()

func (*Doc) XXX_Marshal

func (m *Doc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Doc) XXX_Merge

func (m *Doc) XXX_Merge(src proto.Message)

func (*Doc) XXX_Size

func (m *Doc) XXX_Size() int

func (*Doc) XXX_Unmarshal

func (m *Doc) XXX_Unmarshal(b []byte) error

type DocWithScore

type DocWithScore struct {
	*Doc
	Score float32
}

type Float

type Float interface {
	~float32 | ~float64
}

type Store

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

func (Store) AddDocuments

func (s Store) AddDocuments(ctx context.Context, documents []schema.Document, option ...vectorstores.Option) error

func (Store) Docs

func (s Store) Docs() ([]schema.Document, error)

func (Store) SimilaritySearch

func (s Store) SimilaritySearch(ctx context.Context, query string, numDocuments int, options ...vectorstores.Option) ([]schema.Document, error)

Jump to

Keyboard shortcuts

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