Documentation
¶
Index ¶
- func NewRetrieverWithCache(retriever core.Retriever, semanticCache core.SemanticCache, ...) core.Retriever
- type BoltOption
- type BoltSemanticCache
- func (c *BoltSemanticCache) CacheResponse(ctx context.Context, query *core.Query, answer *core.Result) error
- func (c *BoltSemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
- func (c *BoltSemanticCache) CleanExpired(ctx context.Context) (int, error)
- func (c *BoltSemanticCache) Close() error
- func (c *BoltSemanticCache) Size() (int, error)
- type CacheOption
- type Config
- type EvictPolicy
- type InMemorySemanticCache
- func (c *InMemorySemanticCache) CacheResponse(ctx context.Context, query *core.Query, answer *core.Result) error
- func (c *InMemorySemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
- func (c *InMemorySemanticCache) CleanExpired(ctx context.Context) (int, error)
- func (c *InMemorySemanticCache) Size() int
- type IndexedBoltOption
- type IndexedBoltSemanticCache
- func (c *IndexedBoltSemanticCache) CacheResponse(ctx context.Context, query *core.Query, answer *core.Result) error
- func (c *IndexedBoltSemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
- func (c *IndexedBoltSemanticCache) CleanExpired(ctx context.Context) (int, error)
- func (c *IndexedBoltSemanticCache) Close() error
- func (c *IndexedBoltSemanticCache) Size() (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRetrieverWithCache ¶ added in v1.1.4
Types ¶
type BoltOption ¶ added in v1.1.4
type BoltOption func(*BoltSemanticCache)
func WithBoltDBPath ¶ added in v1.1.4
func WithBoltDBPath(path string) BoltOption
func WithBoltThreshold ¶ added in v1.1.4
func WithBoltThreshold(threshold float32) BoltOption
type BoltSemanticCache ¶ added in v1.1.4
type BoltSemanticCache struct {
// contains filtered or unexported fields
}
func DefaultBoltSemanticCache ¶ added in v1.1.4
func DefaultBoltSemanticCache(embedder embedding.Provider) (*BoltSemanticCache, error)
func NewBoltSemanticCache ¶ added in v1.1.4
func NewBoltSemanticCache(embedder embedding.Provider, opts ...BoltOption) (*BoltSemanticCache, error)
func (*BoltSemanticCache) CacheResponse ¶ added in v1.1.4
func (*BoltSemanticCache) CheckCache ¶ added in v1.1.4
func (c *BoltSemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
func (*BoltSemanticCache) CleanExpired ¶ added in v1.1.4
func (c *BoltSemanticCache) CleanExpired(ctx context.Context) (int, error)
func (*BoltSemanticCache) Close ¶ added in v1.1.4
func (c *BoltSemanticCache) Close() error
func (*BoltSemanticCache) Size ¶ added in v1.1.4
func (c *BoltSemanticCache) Size() (int, error)
type CacheOption ¶ added in v1.1.4
type CacheOption func(*Config)
func WithDBPath ¶ added in v1.1.4
func WithDBPath(path string) CacheOption
func WithEvictPolicy ¶ added in v1.1.4
func WithEvictPolicy(p EvictPolicy) CacheOption
func WithMaxSize ¶ added in v1.1.4
func WithMaxSize(n int) CacheOption
func WithTTL ¶ added in v1.1.4
func WithTTL(d time.Duration) CacheOption
func WithThreshold ¶ added in v1.1.4
func WithThreshold(threshold float32) CacheOption
type EvictPolicy ¶ added in v1.1.4
type EvictPolicy string
const ( EvictLRU EvictPolicy = "lru" EvictFIFO EvictPolicy = "fifo" EvictLFU EvictPolicy = "lfu" )
type InMemorySemanticCache ¶
type InMemorySemanticCache struct {
// contains filtered or unexported fields
}
func NewInMemorySemanticCache ¶
func NewInMemorySemanticCache(embedder embedding.Provider, opts ...CacheOption) *InMemorySemanticCache
func NewInMemorySemanticCacheWithConfig ¶ added in v1.1.4
func NewInMemorySemanticCacheWithConfig(embedder embedding.Provider, cfg *Config) *InMemorySemanticCache
func (*InMemorySemanticCache) CacheResponse ¶ added in v1.1.4
func (*InMemorySemanticCache) CheckCache ¶ added in v1.1.4
func (c *InMemorySemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
func (*InMemorySemanticCache) CleanExpired ¶ added in v1.1.4
func (c *InMemorySemanticCache) CleanExpired(ctx context.Context) (int, error)
func (*InMemorySemanticCache) Size ¶ added in v1.1.4
func (c *InMemorySemanticCache) Size() int
type IndexedBoltOption ¶ added in v1.1.6
type IndexedBoltOption func(*IndexedBoltSemanticCache)
func WithIndexedDBPath ¶ added in v1.1.6
func WithIndexedDBPath(path string) IndexedBoltOption
func WithIndexedThreshold ¶ added in v1.1.6
func WithIndexedThreshold(threshold float32) IndexedBoltOption
type IndexedBoltSemanticCache ¶ added in v1.1.6
type IndexedBoltSemanticCache struct {
// contains filtered or unexported fields
}
IndexedBoltSemanticCache is an optimized version of BoltSemanticCache with vector indexing. It uses govector for fast similarity search instead of full scan.
func NewIndexedBoltSemanticCache ¶ added in v1.1.6
func NewIndexedBoltSemanticCache(embedder embedding.Provider, opts ...IndexedBoltOption) (*IndexedBoltSemanticCache, error)
NewIndexedBoltSemanticCache creates a new indexed bolt cache with vector indexing for O(log n) search.
func (*IndexedBoltSemanticCache) CacheResponse ¶ added in v1.1.6
func (*IndexedBoltSemanticCache) CheckCache ¶ added in v1.1.6
func (c *IndexedBoltSemanticCache) CheckCache(ctx context.Context, query *core.Query) (*core.CacheResult, error)
func (*IndexedBoltSemanticCache) CleanExpired ¶ added in v1.1.6
func (c *IndexedBoltSemanticCache) CleanExpired(ctx context.Context) (int, error)
func (*IndexedBoltSemanticCache) Close ¶ added in v1.1.6
func (c *IndexedBoltSemanticCache) Close() error
func (*IndexedBoltSemanticCache) Size ¶ added in v1.1.6
func (c *IndexedBoltSemanticCache) Size() (int, error)
Click to show internal directories.
Click to hide internal directories.