Skip to content

feat: add Valkey vector store integration#2476

Open
daric93 wants to merge 8 commits into
arc53:mainfrom
daric93:feat/valkey-vector-store
Open

feat: add Valkey vector store integration#2476
daric93 wants to merge 8 commits into
arc53:mainfrom
daric93:feat/valkey-vector-store

Conversation

@daric93
Copy link
Copy Markdown

@daric93 daric93 commented May 15, 2026

Implement ValkeyStore in application/vectorstore/ using valkey-glide-sync and the valkey-search module for HNSW vector similarity search.

Fixes: #2475

What kind of change does this PR introduce?

Feature — adds Valkey as a new vector store backend option.

Why was this change needed?

DocsGPT users who run Valkey as their primary data store had no way to use its vector search capabilities within DocsGPT, requiring a separate vector database. This integration provides a high-performance, low-latency vector search option using Valkey's native HNSW indexing.

Changes

  • Add ValkeyStore class extending BaseVectorStore with full interface: search, add_texts, delete_index, get_chunks, add_chunk, delete_chunk
  • Register "valkey" in VectorCreator factory
  • Add VALKEY_* settings to Settings class (host, port, password, tls, index_name, prefix, request_timeout, distance_metric, vector_type, vector_algorithm)
  • Add valkey-glide-sync==2.3.1 to requirements.txt
  • Add Valkey config examples to .env-template
  • Add 56 unit tests (mocked, no external deps)
  • Add 7 integration tests (requires running Valkey with search module)

Other information

  • Uses the synchronous GLIDE client (valkey-glide-sync) — consistent with all other vector store implementations in the project. The Flask backend and Celery workers are synchronous — no async runtime exists in the application.
  • Requires Valkey server with the valkey-search module loaded
  • Set VECTOR_STORE=valkey to enable
  • Tested against Valkey 8.1 / 9.1 with valkeysearch module
  • Soft import guard prevents breaking other vector store backends when valkey-glide-sync is not installed
  • Pagination uses a shared generator with a safety cap of 1000 pages (~10M documents) to prevent infinite loops
  • Search k is capped at [1, 100] to prevent server memory exhaustion
  • delete_index re-raises exceptions so callers can handle failures during re-indexing
  • Supports context manager (with ValkeyStore(...) as store:) for deterministic connection cleanup

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@daric93 is attempting to deploy a commit to the Arc53 Team on Vercel.

A member of the Team first needs to authorize it.

@daric93 daric93 force-pushed the feat/valkey-vector-store branch from c9976d7 to 677fc12 Compare May 20, 2026 19:33
@daric93
Copy link
Copy Markdown
Author

daric93 commented May 20, 2026

Hi @dartpain

I'd appreciate a review on this when you get a chance — if Valkey vector store backend aligns with the project's roadmap. If someone else is better suited to review the storage/vector store layer, could you point me their way?

Thanks!

@atao2004
Copy link
Copy Markdown

Hey @daric93 👋

I've opened a PR against your feat/valkey-vector-store branch that adds client_name="docsgpt_vector_store_client" to both GlideClientConfiguration paths in valkey.py: daric93#2

This sends a CLIENT SETNAME command on connection, making DocsGPT connections identifiable in CLIENT LIST and monitoring dashboards. One-line addition per config path, zero behavioral changes.

daric93 added 7 commits May 29, 2026 10:07
…plication/vectorstore/ using valkey-glide-sync and the valkey-search module for HNSW vector similarity search. - Add ValkeyStore class extending BaseVectorStore with full interface: search, add_texts, delete_index, get_chunks, add_chunk, delete_chunk - Register 'valkey' in VectorCreator factory - Add VALKEY_* settings to Settings class (host, port, password, tls, index_name, prefix) - Add valkey-glide-sync==2.3.1 to requirements.txt - Add Valkey config examples to .env-template - Add 22 unit tests (mocked, no external deps) - Add 7 integration tests (requires running Valkey with search module)

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
…aracters in source_id for tag queries (prevents malformed FT.SEARCH queries with dots, hyphens, slashes, etc.) - Use explicit password check (is not None and != '') instead of truthiness to handle empty-string env vars correctly - Add request_timeout=5000ms to GlideClientConfiguration - Use ReturnField to avoid fetching embedding blobs in search/get_chunks - Paginate delete_index and get_chunks to handle >10k documents - Batch DELETE calls (100 keys per call) for efficiency - Improve error message in add_texts to report partial write count - Add unit tests for tag escaping, batch delete, pagination, and password handling edge cases

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
…ALKEY_DISTANCE_METRIC (cosine/l2/ip), VALKEY_VECTOR_TYPE (float32), and VALKEY_VECTOR_ALGORITHM (hnsw/flat) settings with safe defaults - Log chosen config at index creation time - Fall back to defaults with a warning if unrecognized values are provided - Add '|' to tag escape character set (was missing) - Support FLAT vector algorithm as alternative to HNSW - Add unit tests for all resolver methods and pipe escaping - Update .env-template and integration test fixture

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
… tests - Add close() method and __del__ to release GlideClient TCP connection - _paginated_source_scan now uses ReturnField('source_id') to avoid fetching full document content (only key names needed for deletion) - _ensure_index_exists widens error matching to also catch 'index already' phrasing, reducing brittleness on different Valkey versions - Add 6 new unit tests: close() lifecycle (3), FLAT algorithm path (1), already-exists handling (1), unknown error re-raise (1) - Skipped lazy-import refactor — imports remain at module top per project style

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
…re, Settings, and Postgres Migration pages to list Valkey alongside the other supported vector store backends.

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
…, tag escaping, typed exceptions

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
…guard in vector_creator.py (fragility concern) - Catch RequestError instead of bare Exception in _ensure_index_exists - Re-raise exceptions in delete_index so callers can handle failures - Extract shared _paginated_search generator with max-iterations guard - Add __enter__/__exit__ for deterministic connection cleanup - Cap search k to [1, 100] to prevent memory exhaustion - Make request_timeout configurable via VALKEY_REQUEST_TIMEOUT setting - Refactor integration test fixture to use real Settings instance - Update tests to match new behavior, add context manager + k bounds tests All 63 tests pass (56 unit + 7 integration).

Signed-off-by: Daria Korenieva <daric2612@gmail.com>
@daric93 daric93 force-pushed the feat/valkey-vector-store branch from 677fc12 to 6b6a76f Compare May 29, 2026 17:08
Signed-off-by: Daria Korenieva <daric2612@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add Valkey as a vector store backend

2 participants