Bake a simple Agent in Sagemaker AI notebook
说明与用途
在 SageMaker 中使用 Strands Agents 和 Amazon Bedrock 构建一个简单的代理,包含算术和天气查询工具。
问题
Create an AI agent that can use tools such as arithmetic and weather lookup within an AWS SageMaker notebook using Amazon Bedrock models.
结果
The notebook demonstrates how to set up a Strands Agents agent in SageMaker, configure Bedrock, and use simple tools for arithmetic and weather data.
工作流
- Create a SageMaker notebook instance with default settings.
- Open JupyterLab and create a new notebook named SimpleAgent.ipynb.
- Install strands-agents, boto3, and requests via pip.
- Import os, boto3, Agent, tool, and BedrockModel from strands.
- Configure AWS_REGION, BEDROCK_MODEL_ID, and verify credentials with sts.get_caller_identity().
- Define the calculate and get_weather tools using the @tool decorator.
- Instantiate an Agent with the BedrockModel and the two tools.
- Run the agent on sample queries to see tool selection and responses.
证据
Login to AWS account using an I AM user with admin access
Install strands-agents, boto3, and requests via pip
BedrockModel tells Strands to send model requests to Amazon Bedrock
- 记录日期: 2026-10-14T04:41:19.170Z