aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.38k stars 591 forks source link

Improve AWS service initialization syntax in example notebooks #277

Open ChandraLingam opened 1 month ago

ChandraLingam commented 1 month ago

Description:

This PR proposes an improvement to the way AWS services are initialized in the example notebooks. Currently, the syntax used is:

import boto3

boto3_bedrock = boto3.client('bedrock')

The improved syntax initializes a boto3 session, which allows for more flexibility, such as automatically inferring the region, switching profiles if needed:

import boto3

boto3_session = boto3.Session()  # Initialize a boto3 session (use the profile_name parameter to switch profiles if needed)
bedrock_client = boto3_session.client('bedrock') # Region is automatically inferred from the session

Changes Made:

Updated the initialization syntax in a couple of example notebooks to demonstrate the improvement.

Benefits:

Please review these changes and let me know if you'd like me to apply this improvement to the remaining example notebooks as well.

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

review-notebook-app[bot] commented 3 weeks ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB