rag: cap chunk size at 6KB to fit nomic-embed-text 2048-tok context

The chunker emits any single paragraph as a stand-alone chunk regardless
of size. One HVM page had a 14,858-char paragraph (a big config table) —
nomic-embed-text 400'd the entire embed batch because the model's context
is 2048 tokens. Added a hard-split fallback that splits any oversized
chunk on line boundaries to MAX_CHARS=6000 (~1500 tokens, headroom).

Also defaulted PRODUCT_NAME to "hvm" in rag/index.py to match server.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 13:06:35 -04:00
parent 7a491ba9e4
commit dd691b0111
2 changed files with 36 additions and 12 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ CHROMA_DIR = ROOT / "chroma"
# Collection name — convention: <product>_docs. Override via env if needed.
import os
PRODUCT_NAME = os.environ.get("PRODUCT_NAME", "myproduct")
PRODUCT_NAME = os.environ.get("PRODUCT_NAME", "hvm")
COLLECTION = f"{PRODUCT_NAME}_docs"