Documentation
¶
Index ¶
- func ListAllCollections(dbPath string) []string
- type CollectionState
- type Engine
- type ExternalSource
- type PersistentKB
- func NewPersistentChromeCollection(llmClient *openai.Client, ...) *PersistentKB
- func NewPersistentCollectionKB(stateFile, assetDir string, store Engine, maxChunkSize, chunkOverlap int, ...) (*PersistentKB, error)
- func NewPersistentLocalAICollection(llmClient *openai.Client, ...) *PersistentKB
- func NewPersistentPostgresCollection(llmClient *openai.Client, ...) *PersistentKB
- 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) 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) error
- func (db *PersistentKB) StoreOrReplace(entry string, metadata map[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"`
Index map[string][]engine.Result `json:"index"`
}
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)
}
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
NewPersistentChromeCollection creates a new persistent knowledge base collection using the ChromemDB engine
func NewPersistentLocalAICollection ¶
func NewPersistentLocalAICollection(llmClient *openai.Client, apiURL, apiKey, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize, chunkOverlap int) *PersistentKB
NewPersistentLocalAICollection creates a new persistent knowledge base collection using the LocalAI stores engine
func NewPersistentPostgresCollection ¶ added in v0.5.0
func NewPersistentPostgresCollection(llmClient *openai.Client, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize, chunkOverlap int, databaseURL string) *PersistentKB
NewPersistentPostgresCollection creates a new persistent knowledge base collection using the PostgreSQL engine
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
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 the in-memory index and Engine.GetByID to resolve full chunk data.
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) 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
Store stores an entry in the persistent knowledge base.
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) Store ¶
func (db *PersistentKB) Store(entry string, metadata map[string]string) error
Store stores an entry in the persistent knowledge base.
func (*PersistentKB) StoreOrReplace ¶ added in v0.3.0
func (db *PersistentKB) StoreOrReplace(entry string, metadata map[string]string) error
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