Repository navigation
fix: forward input_type in async embedding helpers - #67
Conversation
_aget_embeddings validated input_type via _check_input_type but never passed it to Embedding.acreate, so aget_embedding/aget_embeddings silently computed embeddings with no input-type prefix (degrading retrieval quality) while the sync path forwarded it correctly. Forward input_type to match the sync path, and add a regression test.
fzowl
left a comment
There was a problem hiding this comment.
Verified locally with a live API key: full suite 370 passed / 21 skipped (local-model tests skip without local extras); the only failure was a transient APIConnectionError on an async multimodal case that moved between parametrizations across runs — environmental network flakiness, unrelated to this change. All embedding tests (the code path touched here) pass.
The fix is correct: async _aget_embeddings now forwards input_type to acreate, mirroring the sync path; since input_type is a named parameter it was previously silently dropped. No double-pass risk. The added offline test asserts the forwarded kwarg.
Note: the fork PR's Integration/Tests CI checks are red only because fork PRs don't receive the VOYAGE_API_KEY secret; with a key they pass (verified above).
|
@NishchayMahor Thank you very much for your contribution, great catch! I'm releasing a new version with this fix very soon! |
|
Thanks for the merge! Small fix, but the quiet kind that bites people at exactly the wrong time, so glad it's in. Big fan of the embedding models, retrieval quality is something we lean on a lot in the observability work I do. Happy to help out here again anytime. |
What
The async embedding helpers validate
input_typebut then drop it. Invoyageai/embeddings_utils.py:_get_embeddingsforwards it:Embedding.create(input=..., model=..., input_type=input_type, **kwargs)._aget_embeddingsvalidates it (_check_input_type(input_type)) but callsEmbedding.acreate(input=..., model=..., **kwargs)—input_typeis a named parameter, not part of**kwargs, so it never reaches the API.Both public async functions (
aget_embedding,aget_embeddings) route through_aget_embeddings, so:computes the embedding with no input-type prefix, which degrades retrieval quality — a silent correctness bug and a sync/async divergence.
Fix
Forward
input_typein the async call, mirroring the sync path:Testing
Added
test_aget_embeddings_forwards_input_typetoTestEmbeddingsUtils(mirrors the existingtest_aget_embeddings_internalmocked pattern) assertingacreateis called withinput_type="query". Fully offline (mocksacreate, no API key). It fails onmainand passes with the fix.