Documentation
¶
Overview ¶
Package semantic provides a Redis Stack (RediSearch) vector store used by the semantic cache plugin to look up and persist responses by embedding similarity, scoped per rule via a hashed tag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
RuleID string
Embedding *embedding.Embedding
Response string
TTL time.Duration
}
Entry is a response to persist for future similarity lookups.
type Option ¶
type Option func(*RedisStore)
Option customizes a RedisStore.
func WithIndexName ¶
WithIndexName overrides the RediSearch index name.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore implements Store against Redis Stack RediSearch.
func NewRedisStore ¶
NewRedisStore builds a vector store over the given Redis client.
func (*RedisStore) EnsureIndex ¶
func (s *RedisStore) EnsureIndex(ctx context.Context, dimension int) error
EnsureIndex creates the vector index once, tolerating a pre-existing index.
func (*RedisStore) Lookup ¶
func (s *RedisStore) Lookup(ctx context.Context, ruleID string, emb *embedding.Embedding, topK int) ([]Candidate, error)
Lookup returns the topK nearest cached responses for the rule, ordered by descending similarity. A query error degrades to no candidates so the caller can fall through to the upstream.