Documentation
¶
Overview ¶
Package redis 提供基于 RediSearch 的消息检索 依赖 Redis Stack(>= 7.0)的 RediSearch 模块
Package redis 提供基于 Redis 的消息存储 纯 Hash 存储,不涉及检索逻辑
Index ¶
- type DocStore
- func (d *DocStore) Close() error
- func (d *DocStore) DeleteCollection(ctx context.Context, collection string) error
- func (d *DocStore) GetDocuments(ctx context.Context, collection string) ([]*schema.Document, error)
- func (d *DocStore) RecallDocuments(ctx context.Context, collection string, query string, topK int) ([]*schema.Document, error)
- func (d *DocStore) SaveDocuments(ctx context.Context, collection string, docs []*schema.Document) error
- type EmbeddingFunc
- type IndexItem
- type Retriever
- func (r *Retriever) AddToIndex(ctx context.Context, id string, content string, embedding []float32) error
- func (r *Retriever) Close() error
- func (r *Retriever) IndexReady() bool
- func (r *Retriever) RebuildIndex(ctx context.Context, msgs []IndexItem) error
- func (r *Retriever) Recall(ctx context.Context, sessionID string, query string, topK int) ([]*schema.Message, error)
- func (r *Retriever) RemoveFromIndex(ctx context.Context, sessionID string) error
- type RetrieverConfig
- type Store
- func (s *Store) ClearSession(ctx context.Context, sessionID string) error
- func (s *Store) Close() error
- func (s *Store) GetClient() *redis.Client
- func (s *Store) GetKeyPrefix() string
- func (s *Store) GetSession(ctx context.Context, sessionID string) ([]*schema.Message, error)
- func (s *Store) Save(ctx context.Context, sessionID string, msgs []*schema.Message) error
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocStore ¶
type DocStore struct {
// contains filtered or unexported fields
}
DocStore 基于 Redis 的通用文档存储
func (*DocStore) DeleteCollection ¶
func (*DocStore) GetDocuments ¶
func (*DocStore) RecallDocuments ¶
type IndexItem ¶
type IndexItem struct {
ID string
SessionID string
Role string
Content string
Timestamp int64
Embedding []float32
}
IndexItem 用于重建索引的数据项
type Retriever ¶
type Retriever struct {
// contains filtered or unexported fields
}
Retriever 基于 RediSearch 的检索器
func NewRetriever ¶
func NewRetriever(config *RetrieverConfig, embedding EmbeddingFunc) (*Retriever, error)
func NewRetrieverFromStore ¶
func NewRetrieverFromStore(store *Store, config *RetrieverConfig, embedding EmbeddingFunc) (*Retriever, error)
NewRetrieverFromStore 从已有 Store 创建 Retriever(共享连接)
func (*Retriever) AddToIndex ¶
func (*Retriever) IndexReady ¶
func (*Retriever) RebuildIndex ¶
type RetrieverConfig ¶
type RetrieverConfig struct {
Addr string
Password string
DB int
KeyPrefix string // 默认 "pulse:"
IndexName string // 默认 "pulse:idx"
VectorDim int // 默认 768
}
RetrieverConfig RediSearch 检索配置
func DefaultRetrieverConfig ¶
func DefaultRetrieverConfig() *RetrieverConfig
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 纯 Redis Hash 消息存储
func NewStore ¶
func NewStore(config *StoreConfig) (*Store, error)
func (*Store) ClearSession ¶
func (*Store) GetSession ¶
type StoreConfig ¶
type StoreConfig struct {
Addr string // 默认 "localhost:6379"
Password string
DB int
KeyPrefix string // 默认 "pulse:"
}
StoreConfig Redis 存储配置
func DefaultStoreConfig ¶
func DefaultStoreConfig() *StoreConfig
Click to show internal directories.
Click to hide internal directories.