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

Tuning bedrock_agents high-level classes to be simpler to use #20

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

rostcheck
Copy link

@rostcheck rostcheck commented Jan 25, 2025

Amazon Bedrock Agent Samples Pull Request

Instructions

  • Do not erase any parts of this template that are not applicable to your pull request.
  • If a section is not applicable, explicitly state the reason.
    • Tick the checkboxes for the items you have completed.
  • These are mandatory requirements, not mere suggestions.

Describe your changes

  • Concise description of the PR
Changes to ..., because ...

Issue ticket number and link

  • Issue # (if applicable)

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you uploading a dataset?
  • Have you added contributions to RELEASE NOTES?

New Example Submissions:

  • Have you tested your code, and made sure the functionality runs successfully? Provide screenshots.
  • Have you linted your Python code with black?
  • Does this implementation use the shared tools src/utils/*. List them here:
1. web_search
2. ...
  • Does this implementation use the helper functions src/utils/*. List them here:
1. bedrock_agent_helper.py
2. ...

src/utils Submissions:

Changes to the utils folder won't be accepted. Instead, open a new issue.


src/shared tool Submissions:

Changes to existing tools won't be accepted. Instead, open a new issue.

  • Business justification for including a new tool
This tool is necessary because ...
  • How is this tool implemented?
      • AWS CDK
      • AWS CloudFormation (recommended)

rostcheck and others added 13 commits January 8, 2025 23:45
… than all construction up front on creation). Added Tool2 (needs to be unified w/ Tool) and an alt version of portfolio demo.
…an to expand its scope), moved some kb attach code out of Agents.init(). Added some alt example versions for now.
…an to expand its scope), moved some kb attach code out of Agents.init(). Added some alt example versions for now.
…hared tools for use by multiple agents (ex. web_search), simplifying creation syntax
…e agents_helper. Removed direct references to agents_helper from examples.
…ase_helper.py to retrieve s3 bucket name if needed.
…ability to use local Python functions as Tools (but it materializes them to a lambda for now)
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@EashanKaushik
Copy link
Contributor

Issue #, if available:

Description of changes:
Allow creating Tools from local code in files, from Python functions w/ type hints, or from lambdas registered in a Toolbox (account-wide DynamoDB table). Allow attaching Tools after creation. Added high-level wrappers so bedrock_agents_helper is not exposed directly; updated Python examples for that (notebooks still use it directly). Added examples/bedrock_agent directory with notebook walking through usage patterns. Added tool_manager for command-line registration/deregistration of Tools. Added high-level convenience helper functions on Agent (ex. Agent.delete_by_name()), renamed direct_create() to create().

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

@EashanKaushik
Copy link
Contributor

Can you complete the above checklist ^ ?

@rostcheck
Copy link
Author

Extra text for answers:
Are you uploading a dataset? No

Does this implementation use the shared tools src/utils/*. List them here:
[Note, this should be src/shared/*]

  • The examples/bedrock_agent/getting_started.ipynb uses the web_search tool

Does this implementation use the helper functions src/utils/*. List them here:

  • Sort of: I'm making core changes to the bedrock_agent (and one addition to bedrock_agent_helper, not adding an example. I did add a tutorial examples/bedrock_agent/getting_started.ipynb ; it uses bedrock_agent. Also in multi_agent_collaboration, I modified every example that used bedrock_agent to remove direct references to bedrock_agent_helper and instead use Agent.exists() and Agent.delete_by_name(), encapsulating all use of bedrock_agent_helper to be via the bedrock_agent to reinforce the use of bedrock_agent as a high-level API. When code used bedrock_agent_helper but not bedrock_agent (the ipynb files), I left that continuing to use bedrock_agent_helper directly.

Have you included your Agent Example name and introduction in README.md
I have not included the tutorial there yet, as we don't directly reference bedrock_agent in the README. If we think we are ready to do that, I can add it.

src/utils Submissions:
I do have additions to bedrock_agent (see the RELEASE_NOTES.md and one function added to bedrock_agent_helper. We don't have issues open for these but can add issues and tie them to this PR if needed.

src/shared tool Submissions: Business justification for including a new tool

I added a command-line utility, src/shared/tool_manager to allow testing the Toolbox (tool sharing via a registry for simpler creation). I also added a note in shared/web_search/README.md explaining how to register web_search and sample code in examples/bedrock_agent/getting_started.ipynb that uses it to attach the web_search tool to an agent (see "Working with Tools", "Attaching tools from the toolbox". The tool_manager does not use CDK or CloudFormation, it calls the Toolbox class to register the Tool's metadata into a DynamoDB table that it creates. If we wanted to instead do that in the CDK for the shared tools, we could do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants