GitNexus/gitnexus/src/core/embeddings
henry201605 622f98ade5
feat(embeddings): forward dimensions param in HTTP embedding requests (#1498)
* feat(embeddings): forward GITNEXUS_EMBEDDING_DIMS as dimensions in HTTP request body

When GITNEXUS_EMBEDDING_DIMS is set, include it as the `dimensions` field
in the /v1/embeddings request body. This enables Matryoshka-capable models
(OpenAI text-embedding-3-*, Cohere embed-v3, Voyage) to return truncated
vectors at the requested size.

When the env var is unset, the request body remains `{ input, model }` —
no breaking change for backends that reject unknown fields.

Adds 4 unit tests covering both paths (with/without dimensions) on both
the batch embed and single-query embed code paths.

* fix(embeddings): address review findings — strict parseInt, multi-batch test, comment wording

1. Strict parseInt validation: reject non-numeric strings like '1024abc'
   by checking /^\d+$/ before parseInt (Finding 1).
2. Add multi-batch test asserting dimensions is forwarded in every fetch
   call when inputs exceed batch size (Finding 2).
3. Soften JSDoc comment: backends may ignore or reject the dimensions
   field rather than universally ignoring it (Finding 3).
4. Add test for invalid GITNEXUS_EMBEDDING_DIMS values.

---------

Co-authored-by: henry <zhangwei2017@unipus.cn>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-05-11 13:56:10 +01:00
..
ast-utils.ts fix(windows): 32767-char tree-sitter crash + VECTOR extension SIGSEGV (#1433) 2026-05-10 16:00:36 +01:00
character-chunk.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
chunker.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +01:00
config.ts fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00
embedder.ts fix: actionable HF_ENDPOINT guidance, retries, timeout and circuit breaker when embedding model download fails (#1419) 2026-05-08 08:53:13 +01:00
embedding-pipeline.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
exact-search.ts fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00
hf-env.ts feat: shared resilient-fetch (retries + circuit breaker) (#1448) 2026-05-09 15:18:09 +01:00
http-client.ts feat(embeddings): forward dimensions param in HTTP embedding requests (#1498) 2026-05-11 13:56:10 +01:00
index.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
line-index.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
server-mapping.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
structural-extractor.ts feat(embeddings): AST-aware chunking with offset-based splitting (#889) 2026-04-16 22:55:04 +01:00
text-generator.ts feat(embeddings): structural chunking with data-driven CHUNKING_RULES dispatch (#987) 2026-04-20 08:25:31 +01:00
types.ts fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00