Skip to content

fix: forward input_type in async embedding helpers - #67

Merged
fzowl merged 4 commits into
voyage-ai:mainfrom
NishchayMahor:fix/async-embeddings-input-type
Jul 9, 2026
Merged

fzowl merged 4 commits into
voyage-ai:mainfrom
NishchayMahor:fix/async-embeddings-input-type

Conversation

@NishchayMahor

Copy link
Copy Markdown
Contributor

What

The async embedding helpers validate input_type but then drop it. In voyageai/embeddings_utils.py:

  • Sync _get_embeddings forwards it: Embedding.create(input=..., model=..., input_type=input_type, **kwargs).
  • Async _aget_embeddings validates it (_check_input_type(input_type)) but calls Embedding.acreate(input=..., model=..., **kwargs) — input_type is 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:

await aget_embedding(text, model="voyage-3", input_type="query")

computes the embedding with no input-type prefix, which degrades retrieval quality — a silent correctness bug and a sync/async divergence.

Fix

Forward input_type in the async call, mirroring the sync path:

await voyageai.Embedding.acreate(
    input=list_of_text, model=model, input_type=input_type, **kwargs
)

Testing

Added test_aget_embeddings_forwards_input_type to TestEmbeddingsUtils (mirrors the existing test_aget_embeddings_internal mocked pattern) asserting acreate is called with input_type="query". Fully offline (mocks acreate, no API key). It fails on main and passes with the fix.

NishchayMahor and others added 3 commits July 5, 2026 01:16
_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 fzowl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@fzowl

fzowl commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@NishchayMahor Thank you very much for your contribution, great catch! I'm releasing a new version with this fix very soon!

@fzowl
fzowl merged commit a2ef572 into voyage-ai:main Jul 9, 2026
20 of 26 checks passed
@fzowl fzowl mentioned this pull request Jul 10, 2026
@NishchayMahor

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants