fix: Update AmazonBedrockDocumentEmbedder to not modify Documents in place#2702
Merged
sjrl merged 1 commit intoJan 13, 2026
Conversation
8 tasks
sjrl
reviewed
Jan 12, 2026
Contributor
|
@GunaPalanivel thanks for the changes! Could you also update the code here AmazonBedrockRanker to use replace as well
|
1762a72 to
d1915ee
Compare
Contributor
Author
Added |
sjrl
reviewed
Jan 12, 2026
…eepset-ai#2174) - Add dataclasses.replace import - Update _embed_cohere to create new document instances - Update _embed_titan to create new document instances - Add immutability tests for both Cohere and Titan paths - Update CHANGELOG.md with bug fix entry Follows the pattern from FastEmbed, Optimum, and Nvidia integrations.
d1915ee to
f5bb112
Compare
davidsbatista
pushed a commit
that referenced
this pull request
Jan 13, 2026
…2174) (#2702) - Add dataclasses.replace import - Update _embed_cohere to create new document instances - Update _embed_titan to create new document instances - Add immutability tests for both Cohere and Titan paths - Update CHANGELOG.md with bug fix entry Follows the pattern from FastEmbed, Optimum, and Nvidia integrations.
This was referenced Jan 15, 2026
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.
Description
partially addresses #2174
Updates
AmazonBedrockDocumentEmbedderto create newDocumentinstances instead of modifying them in place, following the pattern established in Haystack core (#9693) and recent fixes in FastEmbed (#2678), Optimum (#2675), and Nvidia (#2680) integrations.Changes
Code Changes
from dataclasses import replaceimport_embed_cohere()method to create new document instances usingreplace(doc, embedding=emb)_embed_titan()method to create new document instances usingreplace(doc, embedding=emb)Test Changes
test_run_cohere_does_not_modify_original_documents()to verify Cohere path creates new instancestest_run_titan_does_not_modify_original_documents()to verify Titan path creates new instancesDocumentation
CHANGELOG.mdwith bug fix entryTesting
All tests pass successfully:
hatch run fmt-checkhatch run test:typeshatch run test:unit(213 passed including 2 new immutability tests)Notes
AmazonBedrockDocumentImageEmbedderalready uses the correct pattern (implemented in feat: AddAmazonBedrockDocumentImageEmbeddercomponent #2185)AmazonBedrockSparseDocumentEmbedderexists in this integration