database

package
v0.0.0-...-6a25a8b Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKnowledgeBase

func NewKnowledgeBase(
	ctx context.Context,
	name string,
	config sop.DatabaseOptions,
	llm ai.Generator,
	embedder ai.Embeddings,
	documentMode bool,
	enableTextSearch ...bool,
) (*memory.KnowledgeBase[map[string]any], error)

NewKnowledgeBase opens a KnowledgeBase using the filesystem-backed default path.

It is the simple, reusable entry point for the common case: one constructor call and then standard CRUD/search methods. Advanced callers can still use OpenKnowledgeBase for explicit control over transactions, managers, and low-level stores.

Types

type Database

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

Database extends the core sop.Database with AI capabilities.

func NewCassandraDatabase

func NewCassandraDatabase(config sop.DatabaseOptions) *Database

NewCassandraDatabase creates a new AI-enabled database manager backed by Cassandra.

func NewDatabase

func NewDatabase(config sop.DatabaseOptions) *Database

NewDatabase creates a new AI-enabled database manager.

func (*Database) BeginTransaction

func (db *Database) BeginTransaction(ctx context.Context, mode sop.TransactionMode, maxTime ...time.Duration) (sop.Transaction, error)

BeginTransaction starts a new transaction.

func (*Database) Cache

func (db *Database) Cache() sop.L2Cache

Cache returns the L2 cache used by the database.

func (*Database) CacheType

func (db *Database) CacheType() sop.L2CacheType

CacheType returns the configured cache type.

func (*Database) Config

func (db *Database) Config() sop.DatabaseOptions

Config returns the database configuration.

func (*Database) ErasureConfig

func (db *Database) ErasureConfig() map[string]sop.ErasureCodingConfig

ErasureConfig returns the configured erasure coding configuration.

func (*Database) GetDomains

func (db *Database) GetDomains(ctx context.Context) ([]string, error)

GetDomains returns only the vector databases (domains).

func (*Database) GetStores

func (db *Database) GetStores(ctx context.Context) ([]string, error)

GetStores returns the standard stores, excluding system and vector databases.

func (*Database) KnowledgeBaseExists

func (db *Database) KnowledgeBaseExists(ctx context.Context, name string) (bool, error)

KnowledgeBaseExists checks if the underlying physical tables for a knowledge base have been created.

func (*Database) Locker

func (db *Database) Locker() sop.Locker

Locker returns a Lock facet fronting the L2 cache used in the database. Useful for implementing Optimistic locking.

func (*Database) MigrateVectorToKnowledgeBase

func (db *Database) MigrateVectorToKnowledgeBase(
	ctx context.Context,
	vectorStoreName string,
	knowledgeBaseName string,
	t sop.Transaction,
	llm ai.Generator,
	embedder ai.Embeddings,
) (*memory.KnowledgeBase[map[string]any], error)

MigrateVectorToKnowledgeBase reads an existing pure-math VectorStore index, extracts its math-based groupings (Centroids), and enriches them (Post-Hoc Labeling) by asking the LLM to generate descriptive categories. This "Mints" a digital asset into a human-readable KnowledgeBase for the marketplace.

func (*Database) NewBtree

func (db *Database) NewBtree(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)

NewBtree creates a new B-Tree store with string keys and any values.

func (*Database) OpenBtree

func (db *Database) OpenBtree(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)

OpenBtree opens a general purpose B-Tree store with string keys and any values.

func (*Database) OpenBtreeCursor

func (db *Database) OpenBtreeCursor(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)

OpenBtreeCursor opens a cursor wrapper for a given Btree. It opens it if it is not yet.

func (*Database) OpenKnowledgeBase

func (db *Database) OpenKnowledgeBase(
	ctx context.Context,
	name string,
	t sop.Transaction,
	llm ai.Generator,
	embedder ai.Embeddings,
	documentMode bool,
	enableTextSearch ...bool,
) (*memory.KnowledgeBase[map[string]any], error)

OpenKnowledgeBase intelligently provisions or opens the physical tables and returns the clean KnowledgeBase facade. KnowledgeBase leverages LLM or human generated semantic Categories for clustering, avoiding the periodic rebuilds (Optimize) required by standard VectorStores.

func (*Database) OpenModelStore

func (db *Database) OpenModelStore(ctx context.Context, name string, t sop.Transaction) (ai.ModelStore, error)

OpenModelStore opens a ModelStore for the specified name using the provided transaction.

func (*Database) OpenSearch

func (db *Database) OpenSearch(ctx context.Context, name string, t sop.Transaction) (*search.Index, error)

OpenSearch opens a text search index for the specified name using the provided transaction.

func (*Database) OpenVectorStore

func (db *Database) OpenVectorStore(ctx context.Context, name string, t sop.Transaction, cfg vector.Config) (ai.VectorStore[map[string]any], error)

OpenVectorStore opens a vector store with map[string]any payload.

func (*Database) Options

func (db *Database) Options() sop.DatabaseOptions

Options returns the database options.

func (*Database) RemoveKnowledgeBase

func (db *Database) RemoveKnowledgeBase(ctx context.Context, name string) error

RemoveKnowledgeBase removes the Knowledge Base and its underlying B-Trees.

func (*Database) RemoveModelStore

func (db *Database) RemoveModelStore(ctx context.Context, name string) error

RemoveModelStore removes the model store and its underlying B-Tree.

func (*Database) RemoveSearch

func (db *Database) RemoveSearch(ctx context.Context, name string) error

RemoveSearch removes the search index and its underlying B-Trees.

func (*Database) RemoveVectorStore

func (db *Database) RemoveVectorStore(ctx context.Context, name string) error

RemoveVectorStore removes the vector store and its underlying B-Trees.

func (*Database) StoragePath

func (db *Database) StoragePath() string

StoragePath returns the base storage path.

func (*Database) StoreExists

func (db *Database) StoreExists(ctx context.Context, name string) (bool, error)

StoreExists checks if a B-Tree store with the given name exists. It starts a read-only transaction to perform the check.

func (*Database) StoresFolders

func (db *Database) StoresFolders() []string

StoresFolders returns the list of storage folders (for replication).

func (*Database) Vectorize

func (db *Database) Vectorize(
	ctx context.Context,
	kbName string,
	llm ai.Generator,
	embedder ai.Embeddings,
	batchSize int,
) error

Vectorize processes the store's KnowledgeBase in batches, managing its own transactions and cursor state.

func (*Database) VectorizeCategories

func (db *Database) VectorizeCategories(
	ctx context.Context,
	kbName string,
	llm ai.Generator,
	embedder ai.Embeddings,
	batchSize int,
	categoryIDs []sop.UUID,
) error

Vectorize processes the store's KnowledgeBase in batches, managing its own transactions and cursor state.

func (*Database) VectorizeItems

func (db *Database) VectorizeItems(
	ctx context.Context,
	kbName string,
	llm ai.Generator,
	embedder ai.Embeddings,
	batchSize int,
	categoryID sop.UUID,
	itemIDs []sop.UUID,
) error

VectorizeItems processes specific items or an entire category within a single isolated transaction. It is intended for real-time web-handlers and granular hooks, avoiding the full Space scan.

Jump to

Keyboard shortcuts

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