Documentation
¶
Index ¶
- func NewKnowledgeBase(ctx context.Context, name string, config sop.DatabaseOptions, llm ai.Generator, ...) (*memory.KnowledgeBase[map[string]any], error)
- type Database
- func (db *Database) BeginTransaction(ctx context.Context, mode sop.TransactionMode, maxTime ...time.Duration) (sop.Transaction, error)
- func (db *Database) Cache() sop.L2Cache
- func (db *Database) CacheType() sop.L2CacheType
- func (db *Database) Config() sop.DatabaseOptions
- func (db *Database) ErasureConfig() map[string]sop.ErasureCodingConfig
- func (db *Database) GetDomains(ctx context.Context) ([]string, error)
- func (db *Database) GetStores(ctx context.Context) ([]string, error)
- func (db *Database) KnowledgeBaseExists(ctx context.Context, name string) (bool, error)
- func (db *Database) Locker() sop.Locker
- func (db *Database) MigrateVectorToKnowledgeBase(ctx context.Context, vectorStoreName string, knowledgeBaseName string, ...) (*memory.KnowledgeBase[map[string]any], error)
- func (db *Database) NewBtree(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)
- func (db *Database) OpenBtree(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)
- func (db *Database) OpenBtreeCursor(ctx context.Context, name string, t sop.Transaction) (btree.BtreeInterface[string, any], error)
- func (db *Database) OpenKnowledgeBase(ctx context.Context, name string, t sop.Transaction, llm ai.Generator, ...) (*memory.KnowledgeBase[map[string]any], error)
- func (db *Database) OpenModelStore(ctx context.Context, name string, t sop.Transaction) (ai.ModelStore, error)
- func (db *Database) OpenSearch(ctx context.Context, name string, t sop.Transaction) (*search.Index, error)
- func (db *Database) OpenVectorStore(ctx context.Context, name string, t sop.Transaction, cfg vector.Config) (ai.VectorStore[map[string]any], error)
- func (db *Database) Options() sop.DatabaseOptions
- func (db *Database) RemoveKnowledgeBase(ctx context.Context, name string) error
- func (db *Database) RemoveModelStore(ctx context.Context, name string) error
- func (db *Database) RemoveSearch(ctx context.Context, name string) error
- func (db *Database) RemoveVectorStore(ctx context.Context, name string) error
- func (db *Database) StoragePath() string
- func (db *Database) StoreExists(ctx context.Context, name string) (bool, error)
- func (db *Database) StoresFolders() []string
- func (db *Database) Vectorize(ctx context.Context, kbName string, llm ai.Generator, embedder ai.Embeddings, ...) error
- func (db *Database) VectorizeCategories(ctx context.Context, kbName string, llm ai.Generator, embedder ai.Embeddings, ...) error
- func (db *Database) VectorizeItems(ctx context.Context, kbName string, llm ai.Generator, embedder ai.Embeddings, ...) error
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) 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 ¶
GetDomains returns only the vector databases (domains).
func (*Database) GetStores ¶
GetStores returns the standard stores, excluding system and vector databases.
func (*Database) KnowledgeBaseExists ¶
KnowledgeBaseExists checks if the underlying physical tables for a knowledge base have been created.
func (*Database) 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 ¶
RemoveKnowledgeBase removes the Knowledge Base and its underlying B-Trees.
func (*Database) RemoveModelStore ¶
RemoveModelStore removes the model store and its underlying B-Tree.
func (*Database) RemoveSearch ¶
RemoveSearch removes the search index and its underlying B-Trees.
func (*Database) RemoveVectorStore ¶
RemoveVectorStore removes the vector store and its underlying B-Trees.
func (*Database) StoragePath ¶
StoragePath returns the base storage path.
func (*Database) StoreExists ¶
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 ¶
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.