fix(utils): preserve embedding types across batches - #797
Open
OllieinCanada wants to merge 1 commit into
Open
Conversation
Signed-off-by: Oliver Slapinski <olliefromcanada@gmail.com>
OllieinCanada
marked this pull request as ready for review
August 15, 2026 23:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #796
Summary
Nonevalues while preserving types returned by later batchesint8responseRoot cause
merge_embed_responses()built its field list fromembeddings_type[0]. When that response did not contain a type that a later batch returned, the type was never added to the merged dictionary and its values were silently lost.Validation
main(int8isNone)pytest -q tests/test_embed_utils.py(7 passed)mypy .(341 source files, no issues)git diff --checkThe complete test collection requires
CO_API_KEYin two existing modules, so no live API tests were run. Ruff reports the repository's existing import-format findings in both touched files; this patch does not reformat unrelated code.Note
Low Risk
Small, targeted change to batch merge logic with a regression test; affects embed response assembly only, not API calls or auth.
Overview
Fixes batched embeddings-by-type merging so embedding types from later API batches are not dropped when the first batch did not return those types.
merge_embed_responses()now decides which fields to merge by checking whether any batch has a non-Nonevalue for each type, instead of only inspecting the first response. Merging still skipsNoneper batch when concatenating vectors.A regression test covers a case where the first batch has only
float_and a later batch addsint8, ensuring both types appear in the merged result.Reviewed by Cursor Bugbot for commit 9806f64. Bugbot is set up for automated code reviews on this repo. Configure here.