rag

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAllCollections

func ListAllCollections(dbPath string) []string

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

type ExternalSource struct {
	URL            string
	UpdateInterval time.Duration
	LastUpdate     time.Time
}

ExternalSource represents a source that needs to be periodically updated

type PersistentKB

type PersistentKB struct {
	Engine
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPersistentChromeCollection

func NewPersistentChromeCollection(llmClient *openai.Client, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize int) *PersistentKB

NewPersistentChromeCollection creates a new persistent knowledge base collection using the ChromemDB engine

func NewPersistentCollectionKB

func NewPersistentCollectionKB(stateFile, assetDir string, store Engine, maxChunkSize int, llmClient *openai.Client, embeddingModel string) (*PersistentKB, error)

func NewPersistentLocalAICollection

func NewPersistentLocalAICollection(llmClient *openai.Client, apiURL, apiKey, collectionName, dbPath, filePath, embeddingModel string, maxChunkSize int) *PersistentKB

NewPersistentLocalAICollection creates a new persistent knowledge base collection using the LocalAI stores 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) 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) Search added in v0.3.0

func (db *PersistentKB) Search(s string, similarEntries int) ([]types.Result, 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

Directories

Path Synopsis
localai
TODO: this is a duplicate of LocalAI/core/store/client.go
TODO: this is a duplicate of LocalAI/core/store/client.go

Jump to

Keyboard shortcuts

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