-
Notifications
You must be signed in to change notification settings - Fork 134
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: AmazonBedrockChatGenerator - add tools support #1304
Conversation
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 have some questions and small suggestions.
In general, this PR looks good.
...edrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py
Show resolved
Hide resolved
...edrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py
Show resolved
Hide resolved
...edrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/chat_generator.py
Show resolved
Hide resolved
) | ||
|
||
@pytest.mark.parametrize("model_name", [MODELS_TO_TEST_WITH_TOOLS[0]]) # just one model is enough | ||
@pytest.mark.integration |
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 transform this into a simpler unit test about serde (without running the pipeline).
Pipeline running with tools is already tested in test_pipeline_with_amazon_bedrock_chat_generator
.
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.
please simplify this test
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.
Ah missing the pydoc class tooling example. I'll add it @anakin87
@anakin87 lmk what we should do about ids or perhaps we can do that in separate PR? I'm ok with both |
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.
At this point, let's do nothing about ID and wait for @lambda-science's opinion in the issue.
Please take this comment into account: #1304 (comment)
Then this PR is ready to be merged.
Right - I forgot about that one 🙏 |
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.
last change request (hopefully 😊)
@pytest.mark.parametrize("model_name", [MODELS_TO_TEST_WITH_TOOLS[0]]) # just one model is enough | ||
@pytest.mark.integration |
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.
@pytest.mark.parametrize("model_name", [MODELS_TO_TEST_WITH_TOOLS[0]]) # just one model is enough | |
@pytest.mark.integration |
- let's transform this into a unit test (with mocking?)
- if possible, let's test the dictionary format more extensively
- let's also dump to YAML and reload from YAML (some serialization errors happen in this phase)
An example of what I mean:
haystack-core-integrations/integrations/google_ai/tests/generators/chat/test_chat_gemini.py
Line 258 in 68ec202
def test_serde_in_pipeline(self, monkeypatch): |
Ok, I agree, how about now? 🤞 |
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!
* AmazonBedrockChatGenerator - add tools support * Remove test not needed * Add actual pipeline integration test with tools * Extract instance functions to free standing * No need to test serde on all models * Add serde test * Fix serde test * Lint * Always pack thinking + tool call into single ChatMessage * Revert accidental changes * Method renaming for Python Zen * Add class pydocs * Don't run pipeline in serde test * Update test_serde_in_pipeline test * Lint
Why:
Adds Haystack tool support to
AmazonBedrockChatGenerator
What:
AmazonBedrockChatGenerator
to accept, serialize, and handle tool specifications as part of the chat messages.How can it be used:
The changes enable users to pass tools to
AmazonBedrockChatGenerator
, enhancing the model's capabilities by allowing it to use external tools within chat interactions. Here is a simplified example:How did you test it:
Implemented thorough unit and integration tests to validate the addition of tool-related functionalities. Tests included:
Notes for the reviewer:
Please pay special attention to the serialization and deserialization processes for tool objects and the handling of tool calls within the chat messages. Consider reviewing the edge cases in the test suite that handle different orderings of tool messages in replies.