Skip to content

feat: add Valkey as a vector database provider - #5929

Open
daric93 wants to merge 6 commits into
Mintplex-Labs:masterfrom
daric93:feat/valkey-vector-db-provider
Open

feat: add Valkey as a vector database provider#5929
daric93 wants to merge 6 commits into
Mintplex-Labs:masterfrom
daric93:feat/valkey-vector-db-provider

Conversation

@daric93

@daric93 daric93 commented Jun 29, 2026

Copy link
Copy Markdown

Pull Request Type

  • ✨ feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

resolves #

Description

Adds Valkey (with the valkey-search module) as a first-class vector database provider, selectable via VECTOR_DB=valkey. The change is purely additive: default behavior is unchanged and the provider is only exercised when explicitly configured.

  • New Valkey provider extending the VectorDatabase base contract, registered in getVectorDbClass() exactly like the PGVector/Qdrant providers.
  • Uses the official @valkey/valkey-glide client (server-only, pinned exact 2.4.1) and valkey-search (FT.CREATE/FT.SEARCH, HNSW, COSINE) with one index per namespace (allm_idx_{ns}) over allm:{ns}: hash keys. Vectors stored as FLOAT32 little-endian; KNN query vector bound via PARAMS (no string interpolation).
  • Settings plumbing (updateENV KEY_MAPPING, systemSettings with the password surfaced as a boolean only), .env.example entries, a commented opt-in valkey service in docker-compose.yml, and an admin UI config option + provider-privacy entry.

Capability parity — full parity (or greater) with the existing reference providers, nothing stubbed or deferred:

  • add/delete document, delete-namespace, reset, namespace stats / existence checks
  • similarity search with similarityThreshold + topN, filterIdentifiers (pinned-source) exclusion
  • vector-cache reuse path and skipCache embed path, with partial-failure surfacing
  • bounded SCAN + batched DEL for orphan cleanup, optional TLS/auth, configurable request timeout
  • LanceDB-only rerankedSimilarityResponse is correctly out of scope (not part of the base contract)

Configuration / opt-in — disabled by default; activate by setting VECTOR_DB=valkey plus connection config:

VECTOR_DB="valkey"
# Either a single endpoint:
VALKEY_VECTOR_DB_ENDPOINT="redis://localhost:6379"
# or discrete host/port (+ optional credentials/TLS):
VALKEY_VECTOR_DB_HOST="localhost"
VALKEY_VECTOR_DB_PORT="6379"
# VALKEY_VECTOR_DB_USERNAME=
# VALKEY_VECTOR_DB_PASSWORD=
# VALKEY_VECTOR_DB_USE_TLS="true"

Requires a Valkey server with the valkey-search module (valkey/valkey-bundle:8.1). A commented opt-in service is included in docker/docker-compose.yml.

Visuals (if applicable)

Additional Information

What was tested

  • Unit: 28 tests (mocked GLIDE client, fully hermetic) — covers every base-contract method, cache/embed/partial-failure paths, threshold + filterIdentifiers filtering, orphan cleanup, and selector registration.
  • Integration: 9 live tests against valkey/valkey-bundle:8.1 (real Valkey ops; only the embedder, on-disk vector cache, and Prisma DocumentVectors stubbed). Poll-based index waits, no blind sleeps — heartbeat, index create + ingest, KNN retrieval, filterIdentifiers exclusion, document delete, namespace ops, totalVectors across namespaces, delete-namespace (no orphan keys), reset.
  • Lint: eslint clean on all changed server source files.
  • Docker: docker build -f docker/Dockerfile . succeeds locally (arm64); confirmed @valkey/valkey-glide and the Valkey provider are bundled and the provider loads inside the image.

Documentation

  • Added Valkey to the supported vector databases list in README.md.
  • Added a setup guide at server/utils/vectorDbProviders/valkey/SETUP.md (mirrors the other providers' setup docs).
  • A companion docs-site PR adds Valkey to pages/features/vector-databases.mdx on Mintplex-Labs/anythingllm-docs.

How to run the integration suite manually:

podman run -d --name valkey-test -p 6379:6379 valkey/valkey-bundle:8.1
cd server && VALKEY_INTEGRATION_TEST=1 VALKEY_VECTOR_DB_HOST=localhost \
  VALKEY_VECTOR_DB_PORT=6379 \
  npx jest __tests__/utils/vectorDbProviders/valkey/integration.test.js
podman rm -f valkey-test

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

daric93 added 5 commits June 22, 2026 16:20
Add Valkey (with the valkey-search module) as a first-class vector
database provider, selectable via VECTOR_DB=valkey. The change is purely
additive: default behavior is unchanged and the provider is only used
when explicitly configured.

- New Valkey provider extending VectorDatabase, registered in
  getVectorDbClass(); mirrors the PGVector/Qdrant providers.
- Uses the official @valkey/valkey-glide client (server only, pinned)
  and valkey-search (FT.CREATE/FT.SEARCH, HNSW, COSINE) with one index
  per namespace (allm_idx_{ns}) over allm:{ns}: hash keys.
- Full parity: add/delete document, delete-namespace, reset, similarity
  search with threshold + topN, filterIdentifiers exclusion, vector
  cache path, namespace stats, optional TLS/auth, configurable timeout.
- Settings plumbing (updateENV, systemSettings with password masked),
  env examples, commented opt-in docker-compose service, admin UI option.
- Unit tests (mocked client) and gated live integration tests against
  valkey/valkey-bundle.
- Rebuild cached client on connection setting changes (postUpdate disconnect)
- Normalize keyPrefix to match indexName (prevent prefix/index divergence)
- Guard getOrCreateIndex against dimension mismatch; reset valkey on embedder change
- Wire validateConnection via preUpdate so bad config is rejected at save time
- namespaceExists: only treat unknown-index as missing; propagate real outages
- await client.close() in disconnect/validateConnection (no unhandled rejection)
- Authenticate username-only ACL connections
- Infer TLS from rediss:// endpoint scheme
- Sort KNN results by similarity descending (valkey-search rejects SORTBY on KNN)
- Collapse redundant FT.INFO round-trips; drop per-query existence pre-check
Signed-off-by: Daria Korenieva <daric2612@gmail.com>
@daric93

daric93 commented Jul 10, 2026

Copy link
Copy Markdown
Author

@timothycarambat could you please review this pr when you have time

@timothycarambat timothycarambat added Integration Request Request for support of a new LLM, Embedder, or Vector database PR:needs review Needs review by core team labels Jul 11, 2026
@daric93

daric93 commented Jul 30, 2026

Copy link
Copy Markdown
Author

@timothycarambat could you please review this pr when you have time. It adds Valkey as a vector database provider.

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

Labels

Integration Request Request for support of a new LLM, Embedder, or Vector database PR:needs review Needs review by core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants