

# Reuse and share Amazon Bedrock prompts
Reuse and share prompts

You can create and manage reusable prompts for use in a flow app or you can share them with other users. With a flow app you can pre-configure a prompt for a flow, by choosing the model and inference parameters that the model uses. You can also customize the prompt for different use cases by using variables. For example, you could have a prompt that creates a playlist of songs about topics that a user chooses. You can also share prompts that you create with other users. 

**Topics**
+ [

# Create an Amazon Bedrock prompt
](creating-a-prompt.md)
+ [

# Add an Amazon Bedrock prompt to a flow app
](add-prompt-to-prompt-flow-app.md)
+ [

# Modify an Amazon Bedrock prompt
](editing-a-prompt.md)
+ [

# Delete an Amazon Bedrock prompt
](deleting-a-prompt.md)
+ [

# Share an Amazon Bedrock prompt version
](sharing-a-prompt.md)

# Create an Amazon Bedrock prompt
Create a prompt

When you create a prompt, you select a model for it and can modify inference parameters. To adjust the prompt for different use cases, you can include up to 5 variables. 

You define variables in a prompt by surrounding them in double curly braces `{{variable}}`. For example, the following prompt defines two variables, `topic` and `location`. 

*Generate a playlist of songs about \$1\$1`topic`\$1\$1. Make sure each song is by artists from \$1\$1`location`\$1\$1.*

When you run the prompt, you supply values for the variables. Amazon Bedrock in SageMaker Unified Studio fills the prompt with the variable values and then passes the prompt to the model. For example, if you supply a `topic` value of *castle* and a `location` value of *Wales*, the model generates a playlist of songs about castles by Welsh artists.

You initially create a draft of your prompt. You can then test your prompt by inputing test values for the variables and running the prompt. These values are only for temporary testing and aren't saved to your prompt.

You can create variants of your prompt that use different messages, models, or configurations so that you can compare their outputs to decide the best variant for your use case.

 When you are ready, you can create a version of your prompt for use in a flow app. You can create multiple versions of a prompt, but you can only [edit](editing-a-prompt.md) the latest version. When you [delete](deleting-a-prompt.md) a prompt, it deletes all versions of the prompt.

**Warning**  
Generative AI may give inaccurate responses. Avoid sharing sensitive information. Chats may be visible to others in your organization.

**To create a prompt**

1. Navigate to the Amazon SageMaker Unified Studio landing page by using the URL from your administrator.

1. Access Amazon SageMaker Unified Studio using your IAM or single sign-on (SSO) credentials. For more information, see [Access Amazon SageMaker Unified Studio](getting-started-access-the-portal.md).

1. On the Amazon SageMaker Unified Studio home page, navigate to the **Generative AI app development** tile.

   For the **Build chat agent app** button dropdown, select **Build prompt**. You can also create a prompt from the **Build** menu at the top of the page.  
![\[Amazon Bedrock in SageMaker Unified Studio tile.\]](http://docs.aws.amazon.com/sagemaker-unified-studio/latest/userguide/images/bedrock/bedrock-ide-build-prompt.png)

1. In the **Select or create a new project to continue** dialog box, do one of the following:
   + If you want to use a new project, follow the instructions at [Create a new project](create-new-project.md). For the **Project profile** in step 1, choose **Generative AI application development**.
   + If you want to use an existing project, select the project that you want to use and then choose **Continue**. 

1. Choose the prompt name (**Untitled Prompt-nnnn**) and enter a name for the prompt. 

1. In the **Configs** section, do the following:

   1. For **Model**, select the model that you want to use.

   1. (Optional) In **Parameters**, set the inference parameters values that you want to use. If you don't make changes, the prompt uses the default values for the model. For more information, see [Inference parameters](explore-prompts.md#inference-parameters).

   1. (Optional) In **System instructions**, enter any overarching system prompts that you want the model to apply for future interactions. For more information, see [System instructions](explore-prompts.md#system-prompts).

1. In the center pane, enter **Generate a playlist of songs about \$1\$1topic\$1\$1. Make sure each song is by artists from \$1\$1location\$1\$1.** in the **Prompt message** text box. 

1. Choose **Save** to save a draft of your prompt.

1. Test your prompt by doing the following:

   1. On right side of the page, choose **<** to open the test pane.

   1. For **Test variable values**, enter the following values for your prompt variables. 
      + **topic**– Enter **castles**.
      + **location**– Enter **Wales**.

   1. Choose **Run** to test your prompt. You should see your prompt, with populated variables, in the **Test** section. Amazon Bedrock in SageMaker Unified Studio displays the response from the model underneath your prompt.

   1. (Optional) Choose **Reset** to clear previously shown test results.

1. (Optional) Compare the prompt with up to 2 variants by doing the following:

   1. Choose **Compare variants**

   1. In **Variant\$11** enter the model and prompt message that you want to use. Also Add the test variable values.

   1. Choose **Run all** to run and compare the results.

   1. (Optional) choose **Add variant\$12** to add another prompt variant to compare. 

   1. Decide which prompt you want to save and choose **Save**. 

   1. Choose **Exit comparison** to finish comparing the prompts.

   1. In the **Exit comparison** dialog box decide whether you want to continue with the original prompt or continue with a variant of the prompt. Choose **Exit**.

1. Continue to make changes to the prompt and variables until you are satisfied with the results. You can choose **Reset** to clear previously shown test results.

1. When you are ready, choose **Create version** to create a version of your prompt. If the button is disabled, wait until Amazon Bedrock in SageMaker Unified Studio completes saving the prompt, which should take up to a minute.

1. Add your prompt to a [flow app](add-prompt-to-prompt-flow-app.md).

# Add an Amazon Bedrock prompt to a flow app
Add a prompt to a flow app

In this procedure, you add a prompt to an existing [flow app](create-flows-app.md).

**To add a prompt to a flow app**

1. Navigate to the Amazon SageMaker Unified Studio landing page by using the URL from your administrator.

1. Access Amazon SageMaker Unified Studio using your IAM or single sign-on (SSO) credentials. For more information, see [Access Amazon SageMaker Unified Studio](getting-started-access-the-portal.md).

1. If the project that you want to use isn't already open, do the following:

   1. Choose the current project at the top of the page. If a project isn't already open, choose **Select a project**.

   1. Select **Browse all projects**. 

   1. In **Projects** select the project that you want to use.

1. Choose the **Build** menu option at the top of the page.

1. In **MACHINE LEARNING & GENERATIVE AI** choose **My apps**.

1. In **Apps** choose the flow app that you want to add the prompt to.

1. In the **flow builder** pane, select the **Nodes** tab.

1. From the **Orchestration** section, drag a **Prompt** node onto the flow builder canvas.

1. In the the flow builder, select the Prompt node that you just added. 

1. In the **flow builder** pane, choose the **Configure** tab and do the following:

   1. For **Node name**, enter a name for the Prompt node. 

   1. For **Prompt** in the **Prompt details** section, select the prompt that you want to add.

   1. For **Version**, select the version of the prompt that you want to add.

   1. (Optional) In **Select guardrail** select an existing guardrail. For more information, see [Safeguard your Amazon Bedrock app with a guardrail](guardrails.md).

   1. If you want to identify specific data from the upstream node that the prompt should use, change the value in **Expression**. For more information, see [Define inputs with expressions](flows-expressions.md). 

1. The circles on the nodes are connection points. For each variable, draw a line from the circle on the upstream node (such as the **Flow input** node) to the circle for the variable in the **Input** section of the prompt node. 

1. Connect the **Output** of the prompt node to the downstream node that you want the prompt to send its output to. The flow should look similar to the following image:  
![\[Connect an Amazon Bedrock in SageMaker Unified Studio prompt node to a downstream node.\]](http://docs.aws.amazon.com/sagemaker-unified-studio/latest/userguide/images/bedrock/add-prompt-flow-app.png)

1. Choose **Save** to save your changes.

# Modify an Amazon Bedrock prompt
Modify a prompt

You can modify the current draft of a prompt or modify previous versions of a prompt. To modify a prompt, you select the version of the prompt (or current working draft prompt) that you want to modify. You then work on a draft update of the prompt. You can change the configuration for different versions of a prompt. For example, different versions of a prompt can use different Amazon Bedrock in SageMaker Unified Studio models or use different inference parameters.

After testing the draft prompt, you can then save the draft as a new version of the prompt. If you want to use a new version of a prompt in a flow app, update the version of the prompt in the app configuration. For more information, see [Step 3: Add a prompt to your flow app](build-flow.md#build-flow-prompt).

Creating a new prompt version for an already shared prompt doesn't update the users that have access to the prompt version.

 For more information about the changes you can make, see [Create an Amazon Bedrock prompt](creating-a-prompt.md).

**To modify a prompt**

1. Navigate to the Amazon SageMaker Unified Studio landing page by using the URL from your administrator.

1. Access Amazon SageMaker Unified Studio using your IAM or single sign-on (SSO) credentials. For more information, see [Access Amazon SageMaker Unified Studio](getting-started-access-the-portal.md).

1. Choose the **Build** menu at the top of the page.

1. In the **MACHINE LEARNING & GENERATIVE AI** section, choose **My apps**.

1. In the **Select or create a new project to continue** dialog box, select the project that contains the prompt.

1. In the left pane, choose **Asset gallery** and then **My prompts**.

1. In **Prompts**, select the prompt that you want to modify.

1. In **Configs** make changes to the model and inference parameters. 

1. For **Prompt message**, use the text box to make changes to the prompt message.

1. (Optional) Choose **Save** to save the draft of your prompt.

1. In **Test** enter values for the prompt variables and choose run to test your changes. 

1. When you are satisfied with your changes, choose **Create version** to create a new version of your prompt.

# Delete an Amazon Bedrock prompt
Delete a prompt

You can delete prompts that you have previously created. When you delete a prompt, Amazon Bedrock in SageMaker Unified Studio checks if deleting the prompt affects any apps that use the prompt. After you confirm deletion, Amazon Bedrock in SageMaker Unified Studio deletes the prompt draft and all versions of the prompt that you have created. 

**To delete a prompt**

1. Navigate to the Amazon SageMaker Unified Studio landing page by using the URL from your administrator.

1. Access Amazon SageMaker Unified Studio using your IAM or single sign-on (SSO) credentials. For more information, see [Access Amazon SageMaker Unified Studio](getting-started-access-the-portal.md).

1. Choose the **Build** menu at the top of the page.

1. In the **MACHINE LEARNING & GENERATIVE AI** section, choose **My apps**.

1. In the **Select or create a new project to continue** dialog box, select the project that contains the prompt.

1. In the left pane, choose **Asset gallery** and then **My prompts**.

1. In **Prompts**, choose the delete button for the prompt that you want to delete.

1. In the **Delete** dialog box, check if deleting the prompt affects any of your apps. You can still delete the prompt, but you will need to make changes to the apps that use the prompt.

1. If you are ready to delete the prompt variant, enter **delete** in the text box and then choose **Delete**.

# Share an Amazon Bedrock prompt version
Share a prompt version

You can share versions of prompts that you have previously created. You can share a prompt version with all members of your Amazon SageMaker Unified Studio domain, or with specific users or groups in your Amazon SageMaker Unified Studio domain.

When you first share a prompt version, you get a share link to the prompt version that you can send to users. If you share the prompt version with all users, Amazon SageMaker Unified Studio grants permission to a user, when they first open the share link. Amazon SageMaker Unified Studio also adds the prompt version to the user's shared assets list. If you share the prompt version with specific users and groups, the prompt version is immediately available in their shared assets list. They can also use the share link to access the prompt. By default, sharing a prompt version is restricted to only those users or groups that you select. 

If you need the share link again after sharing the prompt version, get the share link by choosing to share prompt version again and copying the share link. You can also change the users that you share with the prompt version with.

To see which prompt versions you have shared, Open the project, choose **Asset gallery** and then **My prompts**. Check the **Share status** column for the prompt.

**To share a prompt version**

1. Navigate to the Amazon SageMaker Unified Studio landing page by using the URL from your administrator.

1. Access Amazon SageMaker Unified Studio using your IAM or single sign-on (SSO) credentials. For more information, see [Access Amazon SageMaker Unified Studio](getting-started-access-the-portal.md).

1. Choose the **Build** menu at the top of the page.

1. In the **MACHINE LEARNING & GENERATIVE AI** section, choose **My apps**.

1. In the **Select or create a new project to continue** dialog box, select the project that contains the prompt.

1. In the left pane, choose **Asset gallery** and then **My prompts**.

1. In **Prompts**, select the prompt that you want to share.

1. If you haven't previously created a version of your prompt, choose **Create version** to create a version of your prompt.

1. Choose the menu option, and choose choose **Share prompt version** to open the prompt sharing pane.

1. In **Version to publish**, select the version of the prompt that you want to share

1. Do one of the following:
   + If you want to share the prompt version with all members of your Amazon SageMaker Unified Studio domain, turn on **Grant access with link**.
   + If you want to share the prompt version with specific Amazon SageMaker Unified Studio domain users or groups, do the following in **Share with specific users or groups**:

     1. For **Member type** choose **Individual user** or **Group**, depending on the type of member that you want share the app with.

     1. Search for the users or groups that you want to share the app with by entering the user name or group in the **Search by alias to invite members** text box.

     1. In the drop down list, select the matching user name or group that want to share the app with. 

     1. Choose **Add** to add the user or group.

1. Choose **Share** to share the prompt. 

1. When the success message appears, choose **Copy link** and send the link to the users that you are sharing the prompt version with. If **Grant access with link** is off, the link only works for users that you have explicitly granted access to the prompt. 