project-nomad/admin/app
Chris Sherwood b0be0dec43 fix(ai): don't probe the native embed endpoint on a non-Ollama backend
_embedWithFallback() always tried Ollama's native /api/embed first and only
reached /v1/embeddings from the catch block. Against a backend that only
speaks the OpenAI embeddings API, every batch therefore paid a
guaranteed-failing round trip plus a warn line before doing the real work.

Invisible on a handful of documents. Expensive on a bulk file-embeddings
job: the reporter is indexing several million chunks through an
OpenAI-compatible proxy, which doubles request volume and log noise against
their embedding host for the entire lifetime of the ingest.

Gates the native attempt on _isNativeBackend(), matching how _doDownloadModel
already skips /api/pull. Used the probe rather than reading isOllamaNative
directly: the field is null until something populates it, and an embed job
can easily be the first thing to touch the service after a restart, which is
exactly when a long ingest is starting and the saving matters most. The probe
memoizes for the process lifetime, so this costs one request overall rather
than one per batch.

Behaviour is otherwise unchanged. A native backend still tries /api/embed
first and still falls back if it fails for a non-context reason, and
context-length errors still bubble to embed() for the truncated retry. The
response-shape validation stays: the probe establishes that /api/tags
answered like Ollama, not that /api/embed will.

Reported by @horsleyb.

Closes #1279

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-29 15:54:41 -07:00
..
controllers feat(AI): let retrieval decline instead of making the prompt paper over it 2026-09-29 15:54:41 -07:00
data refactor(drug-reference): make collections JSON the single source for curated data (#1130) 2026-08-04 03:38:35 +00:00
exceptions fix(Docs): documentation renderer fixes 2025-12-23 16:00:33 -08:00
jobs fix(queue): clear terminal jobs before re-dispatch so downloads aren't silently dropped 2026-09-29 15:54:41 -07:00
middleware fix(API): skip compression for Server-Sent Events (#798) 2026-05-20 10:16:00 -07:00
models feat(benchmark): official multi-arch sysbench, resolved digest, platform metadata (#1158) 2026-08-04 03:39:53 +00:00
services fix(ai): don't probe the native embed endpoint on a non-Ollama backend 2026-09-29 15:54:41 -07:00
utils fix(queue): stop stalled-job recovery forking the embedding chain 2026-09-29 15:54:41 -07:00
validators feat(AI): let retrieval decline instead of making the prompt paper over it 2026-09-29 15:54:41 -07:00