Documentation
¶
Overview ¶
Package pgvector provides a PostgreSQL + pgvector store for memoryrails.
It uses GORM for database operations and pgvector for vector similarity search with HNSW indexing. Requires PostgreSQL with the pgvector extension installed.
Index ¶
- type MemoryRecord
- type Option
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Get(ctx context.Context, id string) (*memoryrails.Memory, error)
- func (s *Store) List(ctx context.Context, opts memoryrails.ListOptions) ([]*memoryrails.Memory, error)
- func (s *Store) Put(ctx context.Context, mem *memoryrails.Memory) error
- func (s *Store) Search(ctx context.Context, embedding []float64, opts memoryrails.SearchOptions) ([]memoryrails.SearchResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryRecord ¶
type MemoryRecord struct {
ID string `gorm:"primaryKey;size:64"`
Content string `gorm:"type:text;not null"`
Type string `gorm:"size:50;not null;index"`
Embedding pgvector.Vector `gorm:"type:vector"`
Metadata string `gorm:"type:jsonb"` // JSON string
Importance float64 `gorm:"default:0.5"`
AccessCount int `gorm:"default:0"`
LastAccessedAt *time.Time
CreatedAt time.Time `gorm:"index"`
UpdatedAt time.Time
}
MemoryRecord is the GORM model for the memories table.
func (MemoryRecord) TableName ¶
func (MemoryRecord) TableName() string
TableName returns the table name.
type Option ¶
type Option func(*Store)
Option configures the store.
func WithDimensions ¶
WithDimensions sets the vector dimensions for the embedding column. Default: 1536.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements memoryrails.Store using PostgreSQL with pgvector.
func New ¶
New creates a new pgvector store. It auto-migrates the table and creates the pgvector extension and HNSW index if they don't exist.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, opts memoryrails.ListOptions) ([]*memoryrails.Memory, error)
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, embedding []float64, opts memoryrails.SearchOptions) ([]memoryrails.SearchResult, error)