Documentation
¶
Index ¶
- func ListAllCollections(dbPath string) []string
- type CollectionState
- type Engine
- type ExternalSource
- type PersistentKB
- func NewPersistentChromeCollection(llmClient *openai.Client, ...) (*PersistentKB, error)
- func NewPersistentCollectionKB(stateFile, assetDir string, store Engine, maxChunkSize, chunkOverlap int, ...) (*PersistentKB, error)
- func NewPersistentLocalAICollection(llmClient *openai.Client, ...) (*PersistentKB, error)
- func NewPersistentPostgresCollection(llmClient *openai.Client, ...) (*PersistentKB, error)
- func (db *PersistentKB) AddExternalSource(source *ExternalSource) error
- func (db *PersistentKB) Count() int
- func (db *PersistentKB) EntryExists(entry string) bool
- func (db *PersistentKB) GetEntryContent(entry string) ([]types.Result, error)
- func (db *PersistentKB) GetEntryFileContent(entry string) (content string, chunkCount int, err error)
- func (db *PersistentKB) GetEntryFilePath(entry string) (string, error)
- func (db *PersistentKB) GetExternalSources() []*ExternalSource
- func (db *PersistentKB) ListDocuments() []string
- func (db *PersistentKB) RemoveEntry(entry string) error
- func (db *PersistentKB) RemoveExternalSource(url string) error
- func (db *PersistentKB) Repopulate() error
- func (db *PersistentKB) Reset() error
- func (db *PersistentKB) Search(s string, similarEntries int) ([]types.Result, error)
- func (db *PersistentKB) Store(entry string, metadata map[string]string) (string, error)
- func (db *PersistentKB) StoreOrReplace(entry string, metadata map[string]string) (string, error)
- type SourceManager
- func (sm *SourceManager) AddSource(collectionName, url string, updateInterval time.Duration) error
- func (sm *SourceManager) RegisterCollection(name string, collection *PersistentKB)
- func (sm *SourceManager) RemoveSource(collectionName, url string) error
- func (sm *SourceManager) Start()
- func (sm *SourceManager) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListAllCollections ¶
ListAllCollections lists all collections in the database
Types ¶
type CollectionState ¶ added in v0.3.0
type CollectionState struct {
ExternalSources []*ExternalSource `json:"external_sources"`
}
CollectionState represents the persistent state of a collection
type Engine ¶
type Engine interface {
Store(s string, metadata map[string]string) (engine.Result, error)
StoreDocuments(s []string, metadata map[string]string) ([]engine.Result, error)
GetEmbeddingDimensions() (int, error)
Reset() error
Search(s string, similarEntries int) ([]types.Result, error)
Count() int
Delete(where map[string]string, whereDocuments map[string]string, ids ...string) error
GetByID(id string) (types.Result, error)
GetBySource(source string) ([]types.Result, error)
}
type ExternalSource ¶ added in v0.3.0
ExternalSource represents a source that needs to be periodically updated
type PersistentKB ¶
func NewPersistentChromeCollection ¶
func NewPersistentChromeCollection(llmClient *openai.Client, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize, chunkOverlap int) (*PersistentKB, error)
NewPersistentChromeCollection creates a new persistent knowledge base collection using the ChromemDB engine. Returns an error instead of exiting so embedded callers (long-running servers) can degrade gracefully when the engine or embedding service is transiently unavailable.
func NewPersistentLocalAICollection ¶
func NewPersistentLocalAICollection(llmClient *openai.Client, apiURL, apiKey, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize, chunkOverlap int) (*PersistentKB, error)
NewPersistentLocalAICollection creates a new persistent knowledge base collection using the LocalAI stores engine. Returns an error instead of exiting so embedded callers can degrade gracefully on transient failures.
func NewPersistentPostgresCollection ¶ added in v0.5.0
func NewPersistentPostgresCollection(llmClient *openai.Client, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize, chunkOverlap int, databaseURL string) (*PersistentKB, error)
NewPersistentPostgresCollection creates a new persistent knowledge base collection using the PostgreSQL engine. Returns an error instead of exiting so embedded callers can degrade gracefully when the embedding service or PostgreSQL is transiently unavailable.
func (*PersistentKB) AddExternalSource ¶ added in v0.3.0
func (db *PersistentKB) AddExternalSource(source *ExternalSource) error
AddExternalSource adds an external source to the collection
func (*PersistentKB) Count ¶ added in v0.3.0
func (db *PersistentKB) Count() int
func (*PersistentKB) EntryExists ¶
func (db *PersistentKB) EntryExists(entry string) bool
EntryExists checks if an entry with the given name exists. It searches by the full key first, then falls back to matching by base filename.
func (*PersistentKB) GetEntryContent ¶ added in v0.5.3
func (db *PersistentKB) GetEntryContent(entry string) ([]types.Result, error)
GetEntryContent returns all chunks (content, id, metadata) for the given entry. It uses Engine.GetBySource to find chunks by source metadata.
func (*PersistentKB) GetEntryFileContent ¶ added in v0.5.3
func (db *PersistentKB) GetEntryFileContent(entry string) (content string, chunkCount int, err error)
GetEntryFileContent returns the full content of the stored file (same text that was chunked, without overlap) and the number of chunks it occupies. This avoids returning overlapping chunk content.
func (*PersistentKB) GetEntryFilePath ¶ added in v0.5.8
func (db *PersistentKB) GetEntryFilePath(entry string) (string, error)
GetEntryFilePath returns the filesystem path of the stored file for the given entry.
func (*PersistentKB) GetExternalSources ¶ added in v0.3.0
func (db *PersistentKB) GetExternalSources() []*ExternalSource
GetExternalSources returns the list of external sources for this collection
func (*PersistentKB) ListDocuments ¶
func (db *PersistentKB) ListDocuments() []string
ListDocuments returns the list of documents in the knowledge base. Each entry includes the key (uuid/filename).
func (*PersistentKB) RemoveEntry ¶
func (db *PersistentKB) RemoveEntry(entry string) error
func (*PersistentKB) RemoveExternalSource ¶ added in v0.3.0
func (db *PersistentKB) RemoveExternalSource(url string) error
RemoveExternalSource removes an external source from the collection
func (*PersistentKB) Repopulate ¶ added in v0.3.0
func (db *PersistentKB) Repopulate() error
func (*PersistentKB) Reset ¶
func (db *PersistentKB) Reset() error
func (*PersistentKB) StoreOrReplace ¶ added in v0.3.0
type SourceManager ¶ added in v0.3.0
type SourceManager struct {
// contains filtered or unexported fields
}
SourceManager manages external sources for collections
func NewSourceManager ¶ added in v0.3.0
func NewSourceManager(config *sources.Config) *SourceManager
NewSourceManager creates a new source manager
func (*SourceManager) AddSource ¶ added in v0.3.0
func (sm *SourceManager) AddSource(collectionName, url string, updateInterval time.Duration) error
AddSource adds a new external source to a collection
func (*SourceManager) RegisterCollection ¶ added in v0.3.0
func (sm *SourceManager) RegisterCollection(name string, collection *PersistentKB)
RegisterCollection registers a collection with the source manager
func (*SourceManager) RemoveSource ¶ added in v0.3.0
func (sm *SourceManager) RemoveSource(collectionName, url string) error
RemoveSource removes an external source from a collection
func (*SourceManager) Start ¶ added in v0.3.0
func (sm *SourceManager) Start()
Start starts the background service
func (*SourceManager) Stop ¶ added in v0.3.0
func (sm *SourceManager) Stop()
Stop stops the background service