Amazon Bedrock Studio, renamed to Amazon Bedrock IDE, is now available in Amazon SageMaker Unified Studio. Amazon Bedrock Studio will be available until February 28, 2025. You may access existing workspaces in this previous version through February 28, 2025, but you may not create new workspaces. To access the enhanced GA version of Amazon Bedrock Studio with additional features and capabilities, you can create a new Amazon SageMaker Unified Studio domain. To learn about Amazon Bedrock Studio IDE, see the documentation.
Build a chat app with Amazon Bedrock Studio
An Amazon Bedrock Studio chat app allows users to communicate with an Amazon Bedrock model through a conversational interface, typically by sending text messages and receiving responses. The model analyzes the user's input, formulate an appropriate response, and carries on a dialogue with the user. You can use a chat apps for various purposes, such as providing customer service, answering questions, offering recommendations, or engaging in open-ended conversations on a wide range of topics.
In this section, you learn how create a simple Amazon Bedrock Studio chat app in Build mode that creates playlists for a radio station. You can also create a Prompt Flows app. Later, you add the following features.
A guardrail to prevent songs with inappropriate song titles.
A data source that lets the app create playlists using your unique song information.
A function that gets today's top 10 songs.
If you want to quickly experiment with sending prompts to a model, consider user the Explore view. For more information, see Explore Amazon Bedrock Studio.
For more information about managing your projects and apps, see Organize your work with projects in Amazon Bedrock Studio.
Topics
Create an initial chat app
In this step you create a chat app that generates playlists for a radio station.
In the app, you use a system prompt to specify that the model should behave as an app that creates playlists for a radio station that plays rock and pop music. A system prompt is a type of prompt that provides instructions or context to the model about the task it should perform, or the persona it should adopt during the conversation.
The user can then use the app to create playlists based on different themes, such as songs that are related by shared artists.
The instructions show how you can change the genre of music that the app creates playlists for by changing the system prompt.
In the app, you can experiment with the randomness and diversity of the response that the model returns by changing the inference parameters.
To create the app, you first need to create a project. A project can contain multiple apps and is also where you can add the Amazon Bedrock components that you want your apps to use. Later you will add guardail, data source, and function calling components to your app. You can share a project with other users and groups of users. For more information, see Share an Amazon Bedrock Studio project.
Warning
The name and description of a chat app are visible to all members of the Amazon Bedrock workspace. We recommend that you don't store sensitive data in these two fields. Project-based access control ensures only authorized members of a project can edit the name, description, and other fields in the project.
To create a chat app Bedrock Studio app
Open your Amazon Bedrock Studio workspace.
Make sure that you are in Build mode, by choosing Build at the top right of the page.
-
If this is the first time that you've opened the workspace, Amazon Bedrock Studio does the following:
Creates a default project.
Creates an empty chat app within the default project.
Creates an empty Prompt Flows app within the default project.
Displays a Welcome to the build mode dialog box with the following choices.
Take a quick tour – Gives you a quick overview of building apps with build mode.
Explore app types – Explore the different types of apps that you can create with Amazon Bedrock Studio.
Build chat app – create your first chat app.
For this procedure, choose Build chat app.
If you have previously open the workspace, do the following:
Create a new project by doing the following:
If you are not on the All projects page, choose View all projects in the Projects dropdown list that is at the top of the page.
On the All projects page, choose Create new project.
-
In the Create new project section, enter
Radio station project
as the name for your project in Project name. For Project description, enter a description for your project.
Choose Create. It might take a few minutes to create the project.
In the card for your project, choose Go to project to open your project.
-
Open the navigation pane by choosing the menu ( ) at the top left of the page.
-
In App builder choose Chat to open the chat app that Bedrock Studio previously created for you.
If you have previously used a different app, that app is shown. If you don't want to use that app, create a new app — On the project page, in the Apps section, choose Create app and then Chat app.
If the Welcome to build model dialog is shown, choose Build chat app.
-
In the Configs pane, choose the model that you want your app to use in Model.
-
In App name, enter
Radio show
as the name for your app. -
For System prompt & examples, enter
You are an app that creates 2 hour long playlists for a radio station that plays rock and pop music.
In the UI section, update the user interface for the app by doing the following:
-
In Hint text for empty chat enter
Hi! I'm your radio show playlist creator.
In Hint text for user input enter
Enter a prompt that describes the playlist that you want.
-
In Quick start prompts choose Edit.
-
Choose Reset to clear the list of quick start prompts
-
For Quick-start prompt 1, enter
Create a playlist of 10 songs.
. (Optional). Enter quick start prompts of your choice in the remaining quick start prompt text boxes.
-
Choose Save to save your app.
In the Quick start prompts section of the Preview pane, run the quick start prompt that you just created by choosing the prompt.
The app shows the prompt and the response from the model in the Preview pane.
In the prompt text box (the text should read Enter a prompt that describes the playlist that you want), enter
Create a list of 10 songs where each song on the list is related to the next song, by musician, bands, or other connections. Be sure to explain the connection from one song to the next. Don’t repeat any artists.
.Choose the run button (or press Ctrl + Enter on your keyboard) to send the prompt to the model.
-
Experiment with influencing the model response by changing the inference parameters in the Parameters section. For example, increase the randomness of the songs in the playlist by increasing the Temperature inference parameter.
The inference parameters you can change are Temperature, Top P, and Top K. Not all models support each of these inference parameters. For more information, see Influence model responses with inference parameters.
Choose Reset to clear the conversation.
-
For System prompt & examples, enter
You are an app that creates 3 hour long playlists for a radio station that plays ambient music.
. Doing this changes the system prompt to create a playlist of songs for a different genre of music and show length. -
In the prompt text box, enter
Create a list of 10 songs where each song on the list is related to the next song, by musician, bands, or other connections. Be sure to explain the connection from one song to the next. Don’t repeat any artists.
. Choose the run button to send the prompt to the model. Note the response from the model now includes songs from the ambient genre of music.
Choose Save to save your app.
-
(Optional) Share your project with other by following the instructions at Share an Amazon Bedrock Studio project.
-
Next step: Add a guardrail to your app by following the instructions at Add a guardrail to your chat app.
Add a guardrail to your chat app
Guardrails for Amazon Bedrock lets you implement safeguards for your Amazon Bedrock Studio app based on your use cases and responsible AI policies. You can create multiple guardrails tailored to different use cases and apply them across multiple foundation models, providing a consistent user experience and standardizing safety controls across generative AI apps. You can configure denied topics to disallow undesirable topics and content filters to block harmful content in the prompts you send to a model and to the responses you get from a model. You can use guardrails with text-only foundation models. For more information, see Safeguard your app with a guardrail.
Add a guardrail
This procedure shows you how to use a guardrail to safeguard the app you created in Create an initial chat app. The guardrail prevents inappropriate language in song titles and filters out unwanted music genres.
If you just completed Create an initial chat app, Bedrock Studio should be open on the app page and you don't need to do steps 1-3.
To add a guardrail to an Amazon Bedrock Studio app
Open your Amazon Bedrock Studio workspace.
Make sure that you are in Build mode, by choosing Build at the top right of the page.
Open the app that you created in Create an initial chat app.
-
In the Configs pane, choose Guardrails and then Create new guardrail.
-
For Guardrail name, enter
prevent_unwanted_songs
. -
For Guardrail description, enter
Prevents inappropriate songs.
. -
In Content filters make sure Enable content filters is selected. For more information, see Content filters.
-
In Filter for prompts make sure the filter for each category is set to High.
-
Make sure Apply the same filters for responses is selected.
In Blocked messsaging do the following.
-
For Blocked messaging for prompts, enter
Sorry, your prompt contained inappropriate text.
. Clear Apply the same message for blocked responses.
-
For Blocked messaging for responses, enter
Sorry, but I can't respond with information that contains inappropriate text.
.
-
Choose Create to create the guardrail.
In the Configs pane, make sure that the selected guardail in Guardrails is the guardrail you just created.
Test the guardrail by entering
Create a list of 10 songs where each song has a swear word in the title.
In the prompt edit box.-
Choose the run button to send the prompt to the model. The model should respond with the message Sorry, but I can't respond with information that contains inappropriate text.
-
Use a denied topic filter to prevent requests for music from a specific music genere. For information about denied topics, see Denied topics.
To add the filter, do the following.
-
In the Guardrails section of the Configs pane, select the guardrail and choose Preview.
-
Choose Edit to edit the guardrail.
-
In Denied topics, choose Add topic.
-
For Name, enter
heavy metal
. -
For Definition for topic, enter
Avoid mentioning songs that are from the heavy metal genre of music.
. -
For in Sample phrases - optional, enter
Create a playlist of heavy metal songs
. Choose Add phrase.
-
Choose Save.
-
Om the Edit guardrail page, choose Update to update the guardrail.
-
Test the guardrail by entering
Create a list of heavy metal songs.
in the prompt edit box. -
Choose the run button to send the prompt to the model. The model should respond with the message Sorry, but I can't respond with information that contains inappropriate text.
-
-
Next step: Add a data source to your app by following the instructions at Add a document data source to your chat app.
Add a document data source to your chat app
You can use your own data into your application by adding a data source to your app. Doing this allows your app to access to information that is only available to you. When your app passes a query to a data source, Amazon Bedrock Studio generates a response that include the query results from the data source. A data source can be a document or an Amazon Bedrock Knowledge Base. For more information, see Add a data source to your app.
In this topic, you update the app you created in Create an initial chat app to use a CSV file as a document data source. The CSV file includes information about bands that don't have public meta data such song length, or music genre. The user can use the app to create a playlist for a radio show based on criteria such as song length or music genre.
To add your own data to an Amazon Bedrock Studio app
-
Create a CSV file name songs.csv and fill with the following ficticious CSV data.
song,artist,genre,length-seconds "Celestial Odyssey","Starry Renegades","Cosmic Rock",240 "Neon Rapture","Synthwave Siren","Synthwave Pop",300 "Wordsmith Warriors","Lyrical Legions","Lyrical Flow",180 "Nebula Shredders","Galactic Axemen","Cosmic Rock",270 "Electro Euphoria","Neon Nomads","Synthwave Pop",210 "Rhythm Renegades","Percussive Pioneers","Lyrical Flow",240 "Stardust Rift","Cosmic Crusaders","Cosmic Rock",180 "Synthwave Serenade","Electro Enchanters","Synthwave Pop",300 "Lyrical Legends","Rhyme Royale","Lyrical Flow",240 "Supernova Shredders","Amplified Ascension","Cosmic Rock",300 "Celestial Chords","Ethereal Echoes","Cosmic Rock",240 "Neon Nirvana","Synthwave Sirens","Synthwave Pop",270 "Verbal Virtuoso","Lyrical Maestros","Lyrical Flow",210 "Cosmic Collision","Stellar Insurgents","Cosmic Rock",180 "Pop Paradox","Melodic Mavericks","Synthwave Pop",240 "Flow Fusion","Verbal Virtuosos","Lyrical Flow",300 "Shredding Shadows","Crimson Crusaders","Cosmic Rock",270 "Synth Serenade","Electro Enchanters","Synthwave Pop",180 "Wordsmith Warlords","Lyrical Legionnaires","Lyrical Flow",240 "Sonic Supernova","Amplified Ascension","Cosmic Rock",210 "Celestial Symphony","Ethereal Ensemble","Cosmic Rock",300 "Electro Euphoria","Neon Nomads","Synthwave Pop",180 "Lyrical Legends","Rhyme Royale","Lyrical Flow",270 "Crimson Crescendo","Scarlet Serenaders","Cosmic Rock",240 "Euphoric Tides","Melodic Mystics","Synthwave Pop",210 "Rhythm Renegades","Percussive Pioneers","Lyrical Flow",180 "Cosmic Collision","Stellar Insurgents","Cosmic Rock",300 "Stardust Serenade","Celestial Crooners","Synthwave Pop",240 "Wordsmith Warriors","Lyrical Legions","Lyrical Flow",270 "Sonic Supernova III","Amplified Ascension","Cosmic Rock",180
-
Open your Amazon Bedrock Studio workspace.
-
Make sure that you are in Build mode, by choosing Build at the top right of the page.
-
Open the app that you created in Create an initial chat app.
Disable any guardrails that you have enabled by choosing None selected in Guardrails.
-
For Data, choose Use single file only.
For Add data sources, choose Click to upload and upload the CSV file you created in step 1. Alternatively, add your source documents by dragging and dropping the CSV from your computer.
-
Test the data source by entering
Create a playlist of songs in the Lyrical Flow genre
in the prompt text box. -
Choose the run button to send the prompt to the model. The model should respond with a playlist of songs from the Lyrical Flow genre that the CSV file contains.
Add a function call to your chat app
Amazon Bedrock Studio functions let a model include information that it has no previous knowledge of in its response. For example, you can use a function to include dynamic information in a model's response such as a weather forecast, sports results, or traffic conditions.To use a function in Amazon Bedrock Studio you add a function component to your app. For more information, see Call functions from your app.
In Amazon Bedrock Studio, a function calls an API hosted outside of Amazon Bedrock Studio. You either create the API yourself, or use an existing API. To create an API, you can use Amazon API Gateway.
In this procedure, you add a function to the app that you created in Create an initial chat app. so that users can get a list of the top 10 songs played on the radio station that day.
To add a function to an Amazon Bedrock Studio app
Create a HTTPS server that implements a
TopSongs
function. Make sure the function adheres to the following schema.openapi: 3.0.0 info: title: Top Songs API description: API to retrieve the top 10 songs played today version: 1.0.0 paths: /top-songs: get: summary: Get the top 10 songs played today description: > This endpoint returns an array of the top 10 songs played today, ordered by popularity. The first element in the array (index 0) represents the most popular song, and the last element (index 9) represents the 10th most popular song. responses: '200': description: Successful response content: application/json: schema: $ref: '#/components/schemas/TopSongs' components: schemas: TopSongs: type: array items: $ref: '#/components/schemas/Song' description: > An array containing the top 10 songs played today. The first element (index 0) is the most popular song, and the last element (index 9) is the 10th most popular song. example: - title: 'Song Title 1' artist: 'Artist Name 1' album: 'Album Name 1' - title: 'Song Title 2' artist: 'Artist Name 2' album: 'Album Name 2' # ... up to 10 songs Song: type: object properties: title: type: string description: The title of the song artist: type: string description: The name of the artist or band album: type: string description: The name of the album the song is from required: - title - artist - album
-
Open your Amazon Bedrock Studio workspace.
-
Make sure that you are in Build mode, by choosing Build at the top right of the page.
-
Open the app that you created in Create an initial chat app.
-
In Models, choose a model that supports functions, such as Anthropic Claude 2.1.
In Functions, choose Create new function.
Alternatively, if you want to use a function that you have previously created, choose the function in the Functions dropdown list. You don't need to do the next step.
-
In the Create function pane, do the following.
-
For in Function name, enter
Top_ten_songs_today
. -
For Function description (optional), enter
Today's top 10 songs.
. -
For Function schema, enter the OpenAPI schema from step one.
Choose Validate schema to validate the schema.
-
In Authentication method choose the authentication method for your HTTP server. For more information, see Authentication methods.
-
In API servers, enter the URL for your server in Server URL. This value is autopopulated if the server URL is in the schema.
-
Choose Create to create your function.
-
-
For System prompt and examples, update the system prompt so that it describes the function. Use the following text:
You are an app that creates 2 hour long playlists for a radio station that plays rock and pop music. The function Top_ten_songs_today gets the most popular song played on the radio station.
. -
Test the function by doing the following.
-
Enter
What are today's top 10 songs?
in the prompt edit box. -
Choose the run button to send the prompt to the model. The model should respond with the list of today's top 10 songs.
-