Test a prompt flow in Amazon Bedrock - Amazon Bedrock

Test a prompt flow in Amazon Bedrock

Note

Amazon Bedrock Prompt flows is in preview and is subject to change.

After you’ve created a prompt flow, you will have a working draft. The working draft is a version of the prompt flow that you can iteratively build and test. Each time you make changes to your flow, the working draft is updated.

When you test your flow Amazon Bedrock first verifies the following and throws an exception if the verification fails:

  • Connectivity between all flow nodes.

  • At least one flow output node is configured.

  • Input and output variable types are matched as required.

  • Condition expressions are valid and a default outcome is provided.

If the verification fails, you'll need to fix the errors before you can test and validate the performance of your flow. Following are steps for testing your flow, select the tab corresponding to your method of choice and follow the steps:

Console
To test your flow
  1. If you're not already in the Prompt flow builder, do the following:

    1. Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at Getting Started with the AWS Management Console.

    2. Select Amazon Bedrock Prompt flows from the left navigation pane. Then, in the Amazon Bedrock Prompt flows section, select a prompt flow you want to test.

    3. Choose Edit in prompt flow builder.

  2. In the Prompt flow builder page, in the right pane, enter an input to invoke your flow. Check that the input data type matches the output data type that you configured for the flow input node.

  3. Choose Run

  4. You’ll see a banner at the top if the prompt flow configuration has any errors. Read the error message, fix the identified issues, save the prompt flow, and run your test again.

    Note

    You must save the prompt flow for the changes you made to be applied when you test the flow.

  5. After you are satisfied with your prompt flow performance, choose Save and exit.

  6. You can continue to iterate on building your flow. When you're satisfied with it and are ready to deploy it to production, create a version of the flow and an alias to point to the version. For more information, see Deploy a prompt flow to your application using versions and aliases.

API

To test your prompt flow, send an InvokeFlow request (see link for request and response formats and field details) with an Agents for Amazon Bedrock runtime endpoint. Include the ARN or ID of the prompt flow in the flowIdentifier field and the ARN or ID of the alias to use in the flowAliasIdentifier field.

The request body specifies the input for the flow and is of the following format:

{ "inputs": [ { "content": { "document": "JSON-formatted string" }, "nodeName": "string", "nodeOutputName": "string" } ] }

Provide the input in the document field, provide a name for the input in the nodeName field, and provide a name for the input in the nodeOutputName field.

The response is returned in a stream. Each event returned contains output from a node in the document field, the node that was processed in the nodeName field, and the type of node in the nodeType field. These events are of the following format:

{ "flowOutputEvent": { "content": { "document": "JSON-formatted string" }, "nodeName": "string", "nodeType": "string" } }

If the prompt flow finishes, a flowCompletionEvent field with the completionReason is also returned. If there's an error, the corresponding error field is returned.