Skip to content
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(data_classes): add support for Bedrock Agents event #3262

Merged
merged 12 commits into from
Nov 2, 2023

Conversation

rubenfonseca
Copy link
Contributor

@rubenfonseca rubenfonseca commented Oct 27, 2023

Issue number: #3261

Summary

Changes

Please provide a summary of what's being changed

This PR adds event data class support for the Bedrock Agent events and response payloads.

Official docs: https://docs.aws.amazon.com/bedrock/latest/userguide/agents-create.html

User experience

Please share what the user experience looks like before and after this change

Before:

def handler(event: dict):
    print(event["inputText"]) # are you sure you've spelled it correctly? what is the return type?

After this PR, we could start writing Lambdas for Bedrock Agents like this:

from aws_lambda_powertools.utilities.data_classes import BedrockAgentEvent, event_source

@event_source(data_class=BedrockAgentEvent)
def handler(event: BedrockAgentEvent):
    print(event.input_text) # fully typed and filled by the IDE

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 27, 2023
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 30, 2023
@rubenfonseca rubenfonseca linked an issue Oct 30, 2023 that may be closed by this pull request
2 tasks
@rubenfonseca rubenfonseca marked this pull request as ready for review October 30, 2023 13:04
@rubenfonseca rubenfonseca requested a review from a team as a code owner October 30, 2023 13:04
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Oct 30, 2023
@ran-isenberg
Copy link
Contributor

any chance for parser schema too?

@leandrodamascena
Copy link
Contributor

any chance for parser schema too?

Yeah @ran-isenberg! We will add support for Parser and Event Handler.

@rubenfonseca
Copy link
Contributor Author

Update: As of October 31, 2023, the payload structure of the Lambda input event and response format is changing. So I'm updating this PR to reflect the changes

@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (b3c9ee0) 95.09% compared to head (fd524b4) 95.06%.
Report is 6 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3262      +/-   ##
===========================================
- Coverage    95.09%   95.06%   -0.04%     
===========================================
  Files          202      203       +1     
  Lines         9408     9470      +62     
  Branches      1719      772     -947     
===========================================
+ Hits          8947     9003      +56     
- Misses         341      345       +4     
- Partials       120      122       +2     
Files Coverage Δ
...mbda_powertools/utilities/data_classes/__init__.py 100.00% <100.00%> (ø)
...ools/utilities/data_classes/bedrock_agent_event.py 98.50% <98.50%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

I left some comments and we are good to merge after addressing them.

@leandrodamascena leandrodamascena self-requested a review November 2, 2023 12:16
@rubenfonseca
Copy link
Contributor Author

@leandrodamascena ready for another review

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

APPROVED!!!

@leandrodamascena leandrodamascena changed the title feat(data_classes): add support for Bedrock Agents events feat(data_classes): add support for Bedrock Agents event Nov 2, 2023
Copy link

sonarqubecloud bot commented Nov 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@leandrodamascena leandrodamascena merged commit 0964e75 into develop Nov 2, 2023
15 checks passed
@leandrodamascena leandrodamascena deleted the rf/bedrock-events branch November 2, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add support for the Bedrock Agent event and response formats
5 participants