memory

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DSN is the in-memory data source name.
	DSN = ":memory:"
)

Variables

View Source
var (
	ErrMissingDSN = errors.New("ErrMissingDSN")
	ErrInvalidDSN = errors.New("ErrInvalidDSN")
	ErrDBClosed   = errors.New("ErrDBClosed")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	// DSN string.
	DSN string
	// Closed flag for DB operations.
	Closed bool

	*sync.RWMutex
	// contains filtered or unexported fields
}

DB is an in-memory DB store.

func NewDB

func NewDB(dsn string) (*DB, error)

NewDB creates a new DB and returns it.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) InitStore

func (db *DB) InitStore(store map[string]map[string]any) error

InitStore lets you init the in-memory DB with the given store.

func (*DB) Open

func (db *DB) Open() (err error)

Open opens the database connection.

type ProvidersService

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

ProvidersService is an in-memory store for embeddings providers.

func NewProvidersService

func NewProvidersService(db *DB) (*ProvidersService, error)

NewProvidersService creates an instance of ProvidersService and returns it.

func (*ProvidersService) AddProvider

func (p *ProvidersService) AddProvider(ctx context.Context, name string, md map[string]any) (*v1.Provider, error)

AddProvider adds a new embeddings provider. nolint:revive

func (*ProvidersService) ComputeProviderProjections

func (p *ProvidersService) ComputeProviderProjections(ctx context.Context, uid string, prj v1.Projection) error

ComputeProviderProjections recomputes all projections from scratch for the provider with the given UID. nolint:revive

func (*ProvidersService) DropProviderEmbeddings

func (p *ProvidersService) DropProviderEmbeddings(ctx context.Context, uid string) error

DropProviderEmbeddings drops all embeddings for the provider with the given uid. NOTE: this obviously also drops the projections, as keeping them would make no sense since there would be no embeddings to associate them with. nolint:revive

func (*ProvidersService) GetProviderByUID

func (p *ProvidersService) GetProviderByUID(ctx context.Context, uid string) (*v1.Provider, error)

GetProviderByid fetches a specific provider by uid. nolint:revive

func (*ProvidersService) GetProviderEmbeddings

func (p *ProvidersService) GetProviderEmbeddings(ctx context.Context, uid string, filter v1.ProviderFilter) ([]v1.Embedding, v1.Page, error)

GetProviderEmbeddings fetches a specific provider embeddings. nolint:revive

func (*ProvidersService) GetProviderProjections

func (p *ProvidersService) GetProviderProjections(ctx context.Context, uid string, filter v1.ProviderFilter) (map[v1.Dim][]v1.Embedding, v1.Page, error)

GetProviderProjections fetches a specific provider embeddings projection. nolint:revive

func (*ProvidersService) GetProviders

func (p *ProvidersService) GetProviders(ctx context.Context, filter v1.ProviderFilter) ([]*v1.Provider, v1.Page, error)

GetProviders fetches all available providers. nolint:revive

func (*ProvidersService) UpdateProviderEmbeddings

func (p *ProvidersService) UpdateProviderEmbeddings(ctx context.Context, uid string, embeds []v1.Embedding, prj v1.Projection) ([]v1.Embedding, error)

UpdateProviderEmbeddings updates embeddings of a specific provider. nolint:revive

Jump to

Keyboard shortcuts

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