Documentation
¶
Index ¶
- func Migrate(ctx context.Context, db *sql.DB) error
- type PgvectorStore
- func (s *PgvectorStore) Close() error
- func (s *PgvectorStore) ReplaceProject(ctx context.Context, tenantID, projectKey string, docs []knowledge.Document) error
- func (s *PgvectorStore) Search(ctx context.Context, queryEmbedding []float32, f knowledge.Filter, topK int) ([]knowledge.Hit, error)
- func (s *PgvectorStore) Stats(ctx context.Context, tenantID, projectKey string) (int, error)
- func (s *PgvectorStore) Upsert(ctx context.Context, docs []knowledge.Document) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PgvectorStore ¶
type PgvectorStore struct {
// contains filtered or unexported fields
}
PgvectorStore persists and queries knowledge documents using Postgres + pgvector.
func New ¶
func New(ctx context.Context, dsn string) (*PgvectorStore, error)
New creates a new PgvectorStore connected to the given DSN.
func (*PgvectorStore) Close ¶
func (s *PgvectorStore) Close() error
Close releases the connection pool held by the store.
func (*PgvectorStore) ReplaceProject ¶
func (s *PgvectorStore) ReplaceProject(ctx context.Context, tenantID, projectKey string, docs []knowledge.Document) error
ReplaceProject atomically removes all documents for tenantID+projectKey and inserts docs in a single transaction. On any error the transaction is rolled back.
func (*PgvectorStore) Search ¶
func (s *PgvectorStore) Search(ctx context.Context, queryEmbedding []float32, f knowledge.Filter, topK int) ([]knowledge.Hit, error)
Search returns the topK nearest documents to queryEmbedding filtered by f. Score is cosine similarity (1 - cosine distance), ranging from 0 to 1. If topK is zero or queryEmbedding is empty, an empty slice is returned.
Click to show internal directories.
Click to hide internal directories.