-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Update AmazonBedrockChatGenerator to use Converse API (BREAKING CHANGE) #1219
Conversation
@julian-risch @silvanocerza do you remember who was giving us permissions for Amazon Bedrock models, was it @askainet ? We need to ping him to click through all these Amazon Bedrock models in this PR so they become available on our Haystack account... |
|
||
# so far we've discovered these models support streaming and tool use | ||
STREAMING_TOOL_MODELS = ["anthropic.claude-3-5-sonnet-20240620-v1:0", "cohere.command-r-plus-v1:0"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These models in MODELS_TO_TEST, MODELS_TO_TEST_WITH_TOOLS and STREAMING_TOOL_MODELS @askainet 🙏 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paul set us up 🚀
@anakin87 would you please give it a rough pass first to make sure I'm not forgetting any major parts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a cursory look and I like the change and the approach, also because we are deleting a lot of code :-)
Ping me when you need a more in-depth review.
f309b60
to
bdf6c34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this refactoring. (Just left some minor comments)
One relevant aspect I noticed involves truncation - we removed it and I am OK with it but we should:
- remove the
truncate
parameter - clearly communicate this in the PR title (which is used for changelog generation)
- release this breaking change in a major version once this PR has been merged
|
||
messages_list = [{"role": msg.role.value, "content": [{"text": msg.content}]} for msg in messages] | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can move try
closer to the actual client usage
(after callback = streaming_callback or self.streaming_callback
)
|
||
return {"replies": replies} | ||
|
||
def extract_replies_from_response(self, response_body: Dict[str, Any]) -> List[ChatMessage]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can easily add an unit test for this method
) | ||
return replies | ||
|
||
def process_streaming_response( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also like to see a unit test for this method, but IDK how tricky it is, so I'll leave it up to you
Addressed your concerns @anakin87
direct usage to improve clarity but since we already import botocore I though it was ok - look like stable API. LMK your thoughts here and please have another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Please incorporate the suggested changes to align with #1236: in short, text
has been introduced to smooth transition to new ChatMessage
in future but currently it just mirrors content
.
Once this PR is merged, please release 2.0.0
...edrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py
Outdated
Show resolved
Hide resolved
...edrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py
Outdated
Show resolved
Hide resolved
…ts/generators/amazon_bedrock/chat/chat_generator.py Co-authored-by: Stefano Fiorucci <[email protected]>
…ts/generators/amazon_bedrock/chat/chat_generator.py Co-authored-by: Stefano Fiorucci <[email protected]>
Enhances the integration with Amazon Bedrock by using the new Converse API in
AmazonBedrockChatGenerator
. The modifications address the removal of outdated adapter structures and simplifies code greatly all while maintaining compatibility as much as possible.What:
adapters.py
file was deleted to eliminate deprecated structures related to chat model adapters.chat_generator.py
:test_chat_generator.py
to include new model tests and validate functionality with the new configurations and expected responses.How can it be used:
How did you test it:
Conducted integration tests that focused on:
AmazonBedrockChatGenerator
with various model configurations.Notes for the reviewer:
adapters.py
file to understand how changes in architecture affect existing functionalities.Breaking Changes
truncate
initialization parameter has been removed fromAmazonBedrockChatGenerator
Migration Steps:
truncate
parameter from component initialization.