vectordb_commons

package
v0.3.71 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WriteModeInsert      = "insert" // always append if not exists
	WriteModeUpdate      = "update" // insert or update
	WriteModeReset       = "reset"  // always overwrite
	WriteModeOnlyGreater = "only_greater"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBResult

type DBResult struct {
	ID        string            `json:"id,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Embedding []float32         `json:"embedding,omitempty"`
	Content   string            `json:"content"`

	// The cosine similarity between the query and the document.
	// The higher the value, the more similar the document is to the query.
	// The value is in the range [-1, 1].
	Similarity float32 `json:"similarity,omitempty"`
}

DBResult represents a single result from a query.

func (*DBResult) Map

func (instance *DBResult) Map() map[string]interface{}

func (*DBResult) String

func (instance *DBResult) String() string

type IVectorDB

type IVectorDB interface {
	Open() (err error)
	Close()
	String() string // return serialized options
	Load(filename string, writeMode string) (err error)
	AddToCollection(collName string, writeMode string, docs ...interface{}) (err error)
	DeleteCollection(name string) (err error)
	GetCollection(name string, params ...interface{}) (response IVectorDBCollection, err error)
	GetOrCreateCollection(name string, params ...interface{}) (response IVectorDBCollection, err error)

	SchemaGetCollections() []string
	SchemaGetCollectionHash(collName string) string
	SchemaGetCollectionSources(name string) []string
	SchemaAddCollectionSources(name string, source ...string) []string
	SchemaRemoveCollectionSources(name string, source ...string) []string
}

type IVectorDBCollection

type IVectorDBCollection interface {
	Count() (response int)

	GetById(ctx context.Context, id string) (response *DBResult, err error)
	InsertDocument(ctx context.Context, doc interface{}) error
	InsertDocuments(ctx context.Context, docs ...interface{}) error
	UpdateDocument(ctx context.Context, doc interface{}) (err error)
	UpdateDocuments(ctx context.Context, docs ...interface{}) (err error)
	Delete(ctx context.Context, params ...interface{}) (err error)
	DeleteById(ctx context.Context, id string) (err error)

	Query(ctx context.Context, params ...interface{}) (response []*DBResult, err error)
}

Jump to

Keyboard shortcuts

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