amazon-bedrock-workshop
amazon-bedrock-workshop copied to clipboard
Improve AWS service initialization syntax in example notebooks
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:
- No need to manually configure the region when initializing the client; it is automatically inferred from the session.
- Allows users to easily switch profiles by specifying the
profile_name
parameter, which is useful when running the examples locally. - Provides a more flexible and scalable way to manage AWS service clients.
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.