Documentation
¶
Overview ¶
Package pgvector implements the vector.Backend interface using PostgreSQL with pgvector.
Index ¶
- Constants
- type Backend
- func (b *Backend) Delete(ctx context.Context, id string) error
- func (b *Backend) DeleteBatch(ctx context.Context, ids []string) error
- func (b *Backend) EmbeddingDimension() int
- func (b *Backend) Ping(ctx context.Context) error
- func (b *Backend) Search(ctx context.Context, query []float64, filter vector.Filter, topK int) ([]vector.SearchResult, error)
- func (b *Backend) Store(ctx context.Context, id string, embedding []float64, metadata map[string]any) error
- func (b *Backend) StoreBatch(ctx context.Context, items []vector.StoreItem) error
- type DBTX
Constants ¶
const DefaultEmbeddingDimension = 1536
DefaultEmbeddingDimension is the default dimension for the pgvector chunk_embeddings column. Must match the vector(N) in the migration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements vector.Backend using pgvector cosine similarity.
func NewWithDimension ¶
NewWithDimension creates a new pgvector backend with a custom embedding dimension.
func (*Backend) DeleteBatch ¶
DeleteBatch removes multiple embeddings.
func (*Backend) EmbeddingDimension ¶
EmbeddingDimension returns the number of dimensions this backend expects.
func (*Backend) Search ¶
func (b *Backend) Search(ctx context.Context, query []float64, filter vector.Filter, topK int) ([]vector.SearchResult, error)
Search returns chunk IDs ranked by cosine similarity.
type DBTX ¶ added in v0.1.3
type DBTX interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}
DBTX is the database interface used by Backend. Both *pgxpool.Pool and *pgx.Conn satisfy this interface.