SIGN IN SIGN UP

fix: avoid repeated numpy checks for embeddings (#3757)

- [x] I understand that this repository is auto-generated and my pull
request may not be merged

## Changes being requested

Avoid calling has_numpy() once per returned embedding when the default
embeddings decoder handles a bulk base64 response. The parser now checks
whether any encoded vectors need decoding, resolves NumPy availability
once per response, and reuses that result for every encoded vector.

Add focused regressions that verify multiple encoded vectors trigger one
availability check and responses containing only already-decoded vectors
do not inspect NumPy.

## Additional context & links

Closes #3753

Parser-only benchmark for 1,500 vectors x 1,536 dimensions with NumPy
unavailable: 86.0 ms -> 20.5 ms median across 30 alternating runs, a
76.1% reduction and 4.18x speedup. With NumPy installed, performance was
effectively unchanged/slightly improved: 24.0 ms -> 23.5 ms.

Validation:
- 79 focused embeddings tests passed under Pydantic v2
- 79 focused embeddings tests passed under Pydantic v1
- 11,232 full-suite tests passed; 144 skipped
- Ruff format/check passed
- Pyright passed
- mypy passed
- Three adversarial review rounds completed; the final two consecutive
rounds were clean
J
Justin Beckwith committed
b19c2161b1eac80fbf1f6f67a64a50af99c53356
Parent: 1cfa80a
Committed by GitHub <noreply@github.com> on 8/28/2026, 10:31:01 PM