Prerequisites
- Activate Bedrock in your AWS account.
- Request access to your desired models (e.g. Claude Sonnet 3.7, Amazon Nova Pro)
- Optional - you may need to configure AWS CLI locally to authenticate with your AWS account.
Important Notes
- Bedrock usage may incur costs based on your Bedrock plan.
- Be mindful of sensitive data and consider security measures when integrating with external services.
Basic Messages
Create a Table: In Pixeltable, create a table with columns to represent your input data and the columns where you want to store the results from Bedrock.| input | response |
|---|---|
| What was the outcome of the 1904 US Presidential election? | The 1904 United States Presidential election was held on November 8, 1904. The outcome was a victory for the incumbent President, Theodore Roosevelt, who ran as the Republican candidate. Here are the key details of the election: ### Candidates: - **Theodore Roosevelt (Republican Party)**: Incumbent President who had assumed office in 1901 following the assassination of President William McKinley. - **Alton B. Parker (Democratic Party)**: A New York judge and the Democratic nominee. - **Euge ...... actions and conservation efforts, were popular. 2. **Economic Prosperity**: The country was experiencing economic growth, which benefited the incumbent. 3. **Personal Popularity**: Roosevelt’s dynamic personality and vigorous campaign style resonated with the public. Roosevelt’s win in 1904 allowed him to implement his "Square Deal" domestic program and continue his foreign policy initiatives, including the construction of the Panama Canal and increased American influence in global affairs. |
Advanced: Tool-based Agent with Bedrock
Now let’s create a more advanced example using Bedrock with tools for news search and weather information.| prompt | answer |
|---|---|
| What's the latest news about SpaceX? | Here's the latest news about SpaceX: 1. **Starbase City Proposal**: - **Title**: The home of Elon Musk's SpaceX could become an official Texas city called Starbase - **Source**: The Associated Press - **Published**: 2025-04-30 - **Snippet**: An election is scheduled for Saturday to determine whether a small area of coastal South Texas, which is home to SpaceX, will become an official city named Starbase. 2. **250th Starlink Satellite Mission**: - **Title**: SpaceX launches 2 ...... Press - **Published**: 2025-04-29 - **Snippet**: Amazon launched its first set of internet satellites using an Atlas V rocket, aiming to compete with SpaceX's Starlink. 5. **Recent Starlink Satellite Launch**: - **Title**: SpaceX launches batch of Starlink satellites into low-Earth orbit - **Source**: UPI - **Published**: 2025-04-28 - **Snippet**: SpaceX launched a Falcon 9 rocket carrying nearly two dozen Starlink satellites into low-Earth orbit from Florida's east coast. |
| What's the weather in San Francisco? | Based on the tool output provided, here's the current weather in San Francisco: - **Temperature:** 72°F - **Condition:** Partly Cloudy If you need more detailed information or a forecast for the upcoming days, feel free to ask! |
How It Works
This notebook demonstrates two key Bedrock integration patterns:-
Basic Message Completion: Using the
bedrock.messages()function to generate responses from Bedrock models. -
Tool-based Agent: Using
bedrock.converse()andbedrock.invoke_tools()to create an agent that can:- Analyze user queries
- Select appropriate tools (news search or weather)
- Execute the tools to retrieve information
- Generate a final response based on the tool output