Documentation
¶
Overview ¶
Package stores provides key/value stores for LLM applications, mirroring langchain_core.stores.
Index ¶
- Variables
- type InMemoryByteStore
- func (s *InMemoryByteStore) MDelete(ctx context.Context, keys []string) error
- func (s *InMemoryByteStore) MGet(ctx context.Context, keys []string) ([][]byte, []bool, error)
- func (s *InMemoryByteStore) MSet(ctx context.Context, pairs map[string][]byte) error
- func (s *InMemoryByteStore) YieldKeys(ctx context.Context, prefix string) ([]string, error)
- type InMemoryStore
- func (s *InMemoryStore[K, V]) MDelete(ctx context.Context, keys []K) error
- func (s *InMemoryStore[K, V]) MGet(ctx context.Context, keys []K) ([]V, []bool, error)
- func (s *InMemoryStore[K, V]) MSet(ctx context.Context, pairs map[K]V) error
- func (s *InMemoryStore[K, V]) YieldKeys(ctx context.Context, prefix string) ([]K, error)
- type JSONCodec
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is returned when a key is missing from a store.
Functions ¶
This section is empty.
Types ¶
type InMemoryByteStore ¶
type InMemoryByteStore struct {
// contains filtered or unexported fields
}
InMemoryByteStore stores arbitrary values as JSON bytes, mirroring langchain_core.stores.InMemoryByteStore.
func NewInMemoryByteStore ¶
func NewInMemoryByteStore() *InMemoryByteStore
NewInMemoryByteStore returns an empty InMemoryByteStore.
func (*InMemoryByteStore) MDelete ¶
func (s *InMemoryByteStore) MDelete(ctx context.Context, keys []string) error
MDelete removes the given keys.
type InMemoryStore ¶
type InMemoryStore[K comparable, V any] struct { // contains filtered or unexported fields }
InMemoryStore is an in-memory Store implementation, mirroring langchain_core.stores.InMemoryStore.
func NewInMemoryStore ¶
func NewInMemoryStore[K comparable, V any]() *InMemoryStore[K, V]
NewInMemoryStore returns an empty InMemoryStore.
func (*InMemoryStore[K, V]) MDelete ¶
func (s *InMemoryStore[K, V]) MDelete(ctx context.Context, keys []K) error
MDelete implements Store.
func (*InMemoryStore[K, V]) MGet ¶
func (s *InMemoryStore[K, V]) MGet(ctx context.Context, keys []K) ([]V, []bool, error)
MGet implements Store.
type JSONCodec ¶
type JSONCodec struct {
// contains filtered or unexported fields
}
JSONCodec allows storing arbitrary (JSON-serializable) values in a byte store.
func NewJSONCodec ¶
func NewJSONCodec(store *InMemoryByteStore) *JSONCodec
NewJSONCodec wraps a byte store with JSON (de)serialization.
type Store ¶
type Store[K comparable, V any] interface { // MGet returns the values for the given keys, preserving order. Missing keys // yield their zero value and a false flag. MGet(ctx context.Context, keys []K) ([]V, []bool, error) // MSet sets the values for the given key/value pairs. MSet(ctx context.Context, pairs map[K]V) error // MDelete removes the given keys. MDelete(ctx context.Context, keys []K) error // YieldKeys iterates over keys matching the given prefix. YieldKeys(ctx context.Context, prefix string) ([]K, error) }
Store is a generic key/value store interface, mirroring langchain_core.stores.BaseStore.