project-nomad/admin/app/services
Chris Sherwood 2dec5bf676 fix(AI): pre-cap embed input + log fallback reason (#881)
The OpenAI-compatible /v1/embeddings fallback path can't pass
`truncate:true` / `num_ctx:8192` to the model, so any chunk that
exceeds the model's loaded context_length (often 2048 for
nomic-embed-text:v1.5) returns a 400 BadRequestError and is silently
dropped from Qdrant. Two CPU-only ingestion runs on NOMAD1 hit this
on dense technical content (medlineplus, arduino.stackexchange) even
after PR #763's num_ctx fix on the native path.

Pre-cap each input string at 4000 chars before either backend call.
That's ~1000-2000 tokens depending on density, comfortably under the
model's 2048 default. The chunker in RagService is sized for
MAX_SAFE_TOKENS=1600 (3200 chars at its conservative 2 chars/token
estimate), so well-formed inputs are never touched; this is purely a
runtime safety net for the edge cases that slip through.

Also stop swallowing the original error in the catch. The bare
`} catch {}` here has masked recurring "input length exceeds context
length" failures for months (#369, #670, #881). Capture and warn-log
the message so future investigations see why we fell back.

Same root cause as #369 and #670 which were closed without an actual
fix to the fallback path.
2026-05-20 10:16:00 -07:00
..
benchmark_service.ts fix(AI): vendor-aware AMD HSA override + benchmark discrete-GPU detection 2026-05-20 10:16:00 -07:00
chat_service.ts fix(AI): qwen2.5 loading on every chat message (#649) 2026-04-21 14:26:28 -07:00
collection_manifest_service.ts fix: update default branch name 2026-03-01 16:08:46 -08:00
collection_update_service.ts feat(content-updates): show size, surface downloads in Active Downloads 2026-05-20 10:16:00 -07:00
container_registry_service.ts feat: support for updating services 2026-03-11 14:08:09 -07:00
countries_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-20 10:16:00 -07:00
docker_service.ts fix(DockerService): improve volume logic and documentation in forceReinstall 2026-05-20 10:16:00 -07:00
docs_service.ts docs: add Community Add-Ons page with field manuals + W3Schools packs (#753) 2026-04-21 14:26:28 -07:00
download_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-20 10:16:00 -07:00
kiwix_library_service.ts fix: prevent ZIM corrupt file crash and deduplicate Ollama download logs (#741) 2026-04-21 14:26:28 -07:00
map_service.ts feat(Maps): regional map downloads via go-pmtiles extract (#780) 2026-05-20 10:16:00 -07:00
ollama_service.ts fix(AI): pre-cap embed input + log fallback reason (#881) 2026-05-20 10:16:00 -07:00
queue_service.ts fix(queue): singleton QueueService to stop ioredis connection leak 2026-05-20 10:16:00 -07:00
rag_service.ts feat(KB): per-file ingest state machine (Phase 1 of RFC #883) (#888) 2026-05-20 10:16:00 -07:00
system_service.ts fix(System): validate StartedAt with fallback to tail:500 (PR review) 2026-05-20 10:16:00 -07:00
system_update_service.ts fix(security): SSRF validation for map downloads and error sanitization (CWE-918, CWE-209) (#552) 2026-04-21 14:26:28 -07:00
zim_extraction_service.ts fix(RAG): report ZIM ingestion progress in overall-file frame 2026-05-20 10:16:00 -07:00
zim_service.ts fix(ZIM): preserve co-existing Wikipedia corpora on cleanup (#884) 2026-05-20 10:16:00 -07:00