Skip to content

feat(database): Implement PgVectorStore abstraction (Resolves #287) - #1389

Open
parastejpal987-cmyk wants to merge 1 commit into
khoj-ai:masterfrom
parastejpal987-cmyk:feat/pgvector-vectorstore
Open

feat(database): Implement PgVectorStore abstraction (Resolves #287)#1389
parastejpal987-cmyk wants to merge 1 commit into
khoj-ai:masterfrom
parastejpal987-cmyk:feat/pgvector-vectorstore

Conversation

@parastejpal987-cmyk

Copy link
Copy Markdown

Description

This PR introduces the PgVectorStore class to provide a standardized, clean abstraction layer for managing and querying vector embeddings in PostgreSQL.

It directly resolves Issue #287 by encapsulating vector operations while remaining completely non-disruptive to the existing core engine.

Changes Made

  • Created src/khoj/database/adapters/vector_store.py with the PgVectorStore implementation.
  • Utilized the existing pgvector.django.CosineDistance metric and Khoj's native UserMemory model to ensure seamless integration without requiring new, invasive database migrations.
  • Implemented add, search, and delete methods with proper type hinting and owner-based filtering to safely segregate user and agent data namespaces.

Motivation

This abstraction makes it significantly easier to interact with pgvector across the codebase, reducing raw query repetition and paving the way for easier maintenance and future search optimizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant