Skip to content

feat(langbot): add LangBot + Valkey vector search cookbook - #77

Closed
atao2004 wants to merge 2 commits into
mainfrom
cookbook-langbot
Closed

atao2004 wants to merge 2 commits into
mainfrom
cookbook-langbot

Conversation

@atao2004

@atao2004 atao2004 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Migrates the archived LangBot + Valkey cookbook (from archive/main-pre-reorg) to the current CONTRIBUTING.md format, scoped to the Valkey Search vector-database backend only.

  • 01 - Getting Started — start Valkey with the search module, verify the connection with valkey-glide, enable LangBot's opt-in valkey_search backend
  • 02 - Vector Search (was 03) — HNSW index, embeddings as HASH keys, KNN queries via the typed ft API
  • 03 - Hybrid Search & Filtering (was 04) — full-text, hybrid filter-then-KNN, file_id TAG filtering, vector_weight caveat, query-injection safety

Scope change from the original 4-cookbook series

The original series also covered distributed rate limiting (valkey_fixwin). That cookbook is dropped in this PR: the upstream implementation, LangBot PR #2267, was not merged — the maintainer said it would be deprecated in favor of a plugin-based approach ("we're going to deprecate Pipeline in the upcoming versions, so this feature will not be accepted, and we recommend implementing this as a plugin"). The vector-search backend (LangBot PR #2276) is merged and released (LangBot v4.10.6), so this PR ships that half of the series now. Rate limiting may return as a separate cookbook if/when a plugin-based reference implementation exists.

Version pins

  • valkey/valkey-bundle:9.1.0 — the TEXT field used by this backend needs valkey-search ≥ v1.2.0, which ships in the 9.x bundle line
  • valkey-glide==2.5.0 — latest published release; verified compatible by actually running the sample and test suite against a live container

A bug found and fixed during review

Independent review caught a real issue in the code carried over from the archive: file_id_filter() percent-encodes TAG-unsafe characters ({, }, *, %) when building a query, but the write path stored file_id raw and unencoded. A stored value containing one of those characters would silently stop matching its own filter forever — directly contradicting the cookbook's own claim that this "fails closed." Fixed by encoding at write time too, corrected the affected doc text (injection-safety section and troubleshooting table in cookbook 03), and added a regression test (test_delete_by_file_id_with_tag_unsafe_characters) that fails against the old code and passes against the fix.

Validation

  • valkey-glide==2.5.0 installed and run against a live valkey/valkey-bundle:9.1.0 container
  • sample/vector_search.py demo runs end-to-end; its README's "Expected output" block is captured from an actual run, not guessed
  • sample/test_vector_search.py: 8/8 tests pass (7 original + 1 new regression test)
  • markdownlint-cli2 clean on all line-length (MD013) findings

Pre-Submit Checklist

  • Builds and runs from a clean clone
  • Runs against current stable Valkey Bundle (9.1.0)
  • No private links, internal references, or local paths
  • No marketing language or uncited claims
  • Vendor-neutral by default (LangBot itself is the framework being integrated; no third-party vendor lock-in introduced)
  • README explains the Valkey concept demonstrated, prerequisites, and how to run
  • Dependencies pinned to specific versions
  • CI validates the sample (temporary cookbook-python.yml copy, per the pattern used by cookbook-semantic-caching/cookbook-haystack/cookbook-agno — PR docs+ci: add semantic-caching cookbook with Python CI (MERGE FIRST FOR PYTHON CI) #45's shared workflow hasn't merged yet)

🤖 Generated with Claude Code

Migrates the archived LangBot + Valkey cookbook to the current
CONTRIBUTING.md format, scoped to the Valkey Search vector-database
backend only. The rate-limiting cookbook is dropped: upstream PR
langbot-app/LangBot#2267 was rejected by the
maintainer, who asked for it as a plugin instead of a cookbook feature.

Renumbered 01-getting-started / 02-vector-search (was 03) /
03-hybrid-and-filtering (was 04). Pinned valkey/valkey-bundle:9.1.0 and
valkey-glide==2.5.0, verified against a live container (8/8 pytest
tests pass, demo script output captured from an actual run).

Fixes a real bug found during review: file_id_filter() encodes TAG-
unsafe characters for queries, but the write path stored file_id raw,
so ids containing those characters would silently stop matching
forever. Storage now encodes consistently with the query path, and a
regression test covers it.

Signed-off-by: Anna Tao <annatao2004@gmail.com>
A wrapped continuation line started with "+ escape_tag", which
markdownlint-cli2 (the exact version pinned in CI, v0.17.2) parses as
a nested unordered-list marker inconsistent with the file's dash
convention. Rewrapped the prose so no continuation line starts with a
bullet character.

Signed-off-by: Anna Tao <annatao2004@gmail.com>
@jbrinkman jbrinkman added the Cookbook Cookbooks are tutorials with runnable code that highlights how to use Valkey in specific scenarios label Aug 12, 2026
@jbrinkman

Copy link
Copy Markdown
Collaborator

Closing this draft PR as part of a cookbook program cleanup.

@jbrinkman jbrinkman closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cookbook Cookbooks are tutorials with runnable code that highlights how to use Valkey in specific scenarios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants