Skip to content

feat: Redis knowledge backend via hook registry - #434

Closed
esafwan wants to merge 3 commits into
feat/knowledge-backend-hook-registryfrom
feat/redis-knowledge-backend
Closed

feat: Redis knowledge backend via hook registry #434
esafwan wants to merge 3 commits into
feat/knowledge-backend-hook-registryfrom
feat/redis-knowledge-backend

Conversation

@esafwan

@esafwan esafwan commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

feat: Redis knowledge backend (hook-registered, contract-compliant)

Adds Redis (RediSearch) as a knowledge backend, registered through the huf_knowledge_backends hook introduced in #406 — huf dogfoods its own registry. Supersedes #235, which was written against the pre-#280 architecture (hand-rolled 381-line backend, hardcoded registry dict, first-class DocType fields).

Design

  • Direct KnowledgeBackend implementation on redisvl (the contract's "direct implementation" path, like sqlite_vec) — not a LlamaIndex adapter. llama-index-vector-stores-redis 0.4.0 pins llama-index-core<0.13 (env needs 0.14.x for chroma/pgvector stores) and redisvl<0.4, which is broken on Python 3.14 (pydantic v1 shim crash), so the wrapper is unusable on Frappe 16.
  • Hook registration in huf/hooks.py: huf_knowledge_backends = {"redis": "huf.ai.knowledge.backends.redis_backend.RedisBackend"}. Not a built-in; proves external-app registration works.
  • Connection settings via advanced_config schema (redis_host, redis_port, redis_username, redis_password, redis_index_prefix) per the backend contract — no first-class DocType fields.
  • Scoping: site_name + knowledge_source tags on metadata, search filters, and deletes — safe on a shared Redis server.
  • Embeddings always HUF-side (contract requirement); vectors stored as float32 bytes; cosine similarity, flat index, VectorQuery + Tag filter expressions.

Testing (bench 16_kbreg, Frappe 16.27, Python 3.14, Redis 8.8.1)

Test Status
Registry discovery: redis resolved via hook alongside built-ins
get_advanced_config_schema whitelisted API round-trip
Full cycle: text input → Gemini embeddings (3072-dim) → index → semantic search → stats/health → scoped delete
21 mocked unit tests incl. real delete-path assertion ✅ (2 pre-existing standalone-context errors in registry throw-tests, unrelated)
ruff check / ruff format

Dependencies

…ds hook

Supersedes #235. Direct KnowledgeBackend implementation on redisvl
(SearchIndex + VectorQuery + Tag filters) instead of a LlamaIndex
adapter: llama-index-vector-stores-redis 0.4.0 pins llama-index-core
<0.13 and redisvl <0.4, and redisvl 0.3.x is broken on Python 3.14
(pydantic v1 shim), making the wrapper unusable on Frappe 16.

- Registered through huf's own huf_knowledge_backends hook (dogfoods
  the registry); not a built-in
- Connection settings via advanced_config schema (redis_host, redis_port,
  redis_username, redis_password, redis_index_prefix) per the contract
- Site + source tag scoping on metadata, search filters and deletes
- Embeddings always HUF-side; float32-byte vectors; cosine/flat index
- 21 mocked unit tests + live E2E against Redis 8.8 (RediSearch)
@esafwan esafwan changed the title feat: Redis knowledge backend via hook registry (supersedes #235, depends on #406) feat: Redis knowledge backend via hook registry Jul 26, 2026
Add Redis as a knowledge backend option alongside pgvector:
- knowledgeTypes, VECTOR_KNOWLEDGE_TYPES and knowledgeTypeLabels
- KnowledgeType union and zod form schema enum
- Redis Connection Settings card in GeneralTab that renders the
  schema-driven AdvancedConfigFields (redis has no first-class
  DocType fields; connection settings come from the backend's
  get_advanced_config_schema)
@esafwan

esafwan commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by consolidated vector backend PR #467, now included in integration PR #468.

@esafwan esafwan closed this Jul 26, 2026
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