Skip to content

Amazon Bedrock playlist flow #7358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 18, 2025
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
24f40b5
work on python hello bedrock example
AWSChris Jan 24, 2025
65ae500
fixed metadata
AWSChris Jan 24, 2025
11462df
removed AWS reference
AWSChris Jan 24, 2025
81e943e
reformatted string
AWSChris Jan 24, 2025
7bbb1a7
updated readme
AWSChris Jan 24, 2025
f93e0b0
updated readme
AWSChris Jan 24, 2025
2ba04d9
updated readme
AWSChris Jan 24, 2025
9fb3e7d
updated readme
AWSChris Jan 24, 2025
7944fe8
ran writeme script to update bedrock readme
AWSChris Jan 25, 2025
17f5a18
removed region declaration
AWSChris Jan 27, 2025
f0098bb
Merge branch 'awsdocs:main' into main
AWSChris Jan 28, 2025
6e564f8
Merge branch 'awsdocs:main' into main
AWSChris Jan 30, 2025
65c627c
Merge branch 'awsdocs:main' into main
AWSChris Jan 31, 2025
d90d701
Merge branch 'awsdocs:main' into main
AWSChris Feb 12, 2025
05cfaac
Merge branch 'awsdocs:main' into main
AWSChris Feb 13, 2025
8c5e8a9
Merge branch 'awsdocs:main' into main
AWSChris Feb 22, 2025
dd1f4d9
Merge branch 'awsdocs:main' into main
AWSChris Mar 3, 2025
a5ca8b2
Merge branch 'awsdocs:main' into main
AWSChris Mar 21, 2025
2ce3337
Merge branch 'awsdocs:main' into main
AWSChris Mar 26, 2025
048a4c4
added flow example files
Apr 2, 2025
fd6b163
flows examples
Apr 3, 2025
e75243e
work on clean up
Apr 4, 2025
7ace2b8
simplified clean up
Apr 4, 2025
60c338c
various clean up
AWSChris Apr 7, 2025
beecdf2
Merge branch 'main' into playlist-flow
AWSChris Apr 7, 2025
e347884
Update python/example_code/bedrock-agent/README.md
AWSChris Apr 15, 2025
5670430
Update python/example_code/bedrock-agent/flows/flow-conversation.py
AWSChris Apr 15, 2025
5486d4f
Update python/example_code/bedrock-agent/test/test_playlist_flow.py
AWSChris Apr 15, 2025
b8b8850
Merge branch 'main' into playlist-flow
AWSChris Apr 15, 2025
d3d8a85
work on list flows calling code
AWSChris Apr 15, 2025
51f23de
list flows example
AWSChris Apr 15, 2025
6e2c843
updated readme for list flows example
AWSChris Apr 15, 2025
374c464
fixed broken snippet name
AWSChris Apr 17, 2025
f7acedc
Merge branch 'main' into playlist-flow
rlhagerm Apr 18, 2025
bb3d18b
Metadata fixes.
rlhagerm Apr 18, 2025
12ecb00
Merge branch 'playlist-flow' of https://github.com/AWSChris/aws-doc-s…
rlhagerm Apr 18, 2025
c945f6a
Yaml updates.
rlhagerm Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 224 additions & 0 deletions .doc_gen/metadata/bedrock-agent_metadata.yaml
Original file line number Diff line number Diff line change
@@ -185,6 +185,8 @@ bedrock-agent_PrepareAgent:
- python.example_code.bedrock-agent.PrepareAgent
services:
bedrock-agent: {PrepareAgent}


bedrock-agent_GettingStartedWithBedrockAgents:
title: An end-to-end example showing how to create and invoke &BRA; using an &AWS; SDK
title_abbrev: Create and invoke an agent
@@ -209,3 +211,225 @@ bedrock-agent_GettingStartedWithBedrockAgents:
services:
bedrock-agent: {CreateAgent, CreateAgentActionGroup, CreateAgentAlias, DeleteAgent, DeleteAgentAlias, GetAgent, ListAgentActionGroups,
ListAgents, ListAgentKnowledgeBases, PrepareAgent}



bedrock-agent_GettingStartedWithBedrockFlows:
title: An end-to-end example showing how to create and invoke an Amazon Bedrock flow using an &AWS; SDK
title_abbrev: Create and invoke a flow
synopsis_list:
- Create an execution role for the flow.
- Create the flow.
- Deploy the fully configured flow.
- Invoke the flow with user-provided prompts.
- Delete all created resources.
category: Scenarios
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Generates a music playlist based on user-specified genre and number of songs.
snippet_tags:
- python.example_code.bedrock-agent-runtime.Scenario_GettingStartedBedrockFlows
- python.example_code.bedrock-agent-runtime.flow_invoke_flow
- python.example_code.bedrock-agent-runtime.run_playlist_flow
- python.example_code.bedrock-agent-runtime.Scenario_GettingStartedBedrockFlows_iam_role

services:
bedrock-agent: {CreateFlow, CreateFlowAlias, CreateFlowVersion, DeleteFlow, DeleteFlowVersion, DeleteFlowAlias, GetFlow, GetFlowAlias,
GetFlowVersion, PrepareFlow}
bedrock-agent-runtime: {InvokeFlow}


bedrock-agent_CreateFlow:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Create an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.create_flow
services:
bedrock-agent: {CreateFlow}

bedrock-agent_PrepareFlow:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Prepare an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.prepare_flow
services:
bedrock-agent: {PrepareFlow}

bedrock-agent_UpdateFlow:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Update an Amazon Bedrock Flow.
snippet_tags:
- python.example_code.bedrock-agent.update_flow
services:
bedrock-agent: {UpdateFlow}

bedrock-agent_DeleteFlow:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Delete an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.delete_flow
services:
bedrock-agent: {DeleteFlow}

bedrock-agent_GetFlow:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Get an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.get_flow
services:
bedrock-agent: {GetFlow}

bedrock-agent_ListFlows:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: List Amazon Bedrock flows.
snippet_tags:
- python.example_code.bedrock-agent.list_flows

services:
bedrock-agent: {ListFlows}

bedrock-agent_CreateFlowAlias:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Create an alias for an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.create_flow_alias

services:
bedrock-agent: {CreateFlowAlias}

bedrock-agent_UpdateFlowAlias:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Update an alias for an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.update_flow_alias

services:
bedrock-agent: {UpdateFlowAlias}

bedrock-agent_DeleteFlowAlias:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Delete an alias for an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.delete_flow_alias

services:
bedrock-agent: {DeleteFlowAlias}

bedrock-agent_ListFlowAliases:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: List the aliases for an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.list_flow_aliases

services:
bedrock-agent: {ListFlowAliases}

bedrock-agent_CreateFlowVersion:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Create a version of an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.create_flow_version

services:
bedrock-agent: {CreateFlowVersion}

bedrock-agent_GetFlowVersion:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Get a version of an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.get_flow_version

services:
bedrock-agent: {GetFlowVersion}

bedrock-agent_DeleteFlowVersion:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: Delete a version of an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.delete_flow_version

services:
bedrock-agent: {DeleteFlowVersion}

bedrock-agent_ListFlowVersions:
languages:
Python:
versions:
- sdk_version: 3
github: python/example_code/bedrock-agent
excerpts:
- description: List the versions of an Amazon Bedrock flow.
snippet_tags:
- python.example_code.bedrock-agent.list_flow_versions

services:
bedrock-agent: {ListFlowVersions}
49 changes: 49 additions & 0 deletions python/example_code/bedrock-agent/README.md
Original file line number Diff line number Diff line change
@@ -48,13 +48,31 @@ Code excerpts that show you how to call individual service functions.
- [ListAgentKnowledgeBases](bedrock_agent_wrapper.py#L237)
- [ListAgents](bedrock_agent_wrapper.py#L185)
- [PrepareAgent](bedrock_agent_wrapper.py#L266)
- [InvokeFlow](flows/run_flow.py#L23)
- [CreateFlow](flows/flow.py#L18)
- [PrepareFlow](flows/flow.py#L58)
- [UpdateFlow](flows/flow.py#L112)
- [DeleteFlow](flows/flow.py#L156)
- [GetFlow](flows/flow.py#L192)
- [ListFlows](flows/flow.py#L229)
- [CreateFlowVersion](flows/flow_version.py#L18)
- [GetFlowVersion](flows/flow_version.py#L54)
- [DeleteFlowVersion](flows/flow_version.py#L91)
- [ListFlowVersions](flows/flow_version.py#L128)
- [CreateFlowAlias](flows/flow_alias.py#L15)
- [UpdateFlowAlias](flows/flow_alias.py#L55)
- [DeleteFlowAlias](flows/flow_alias.py#L98)
- [ListFlowAliases](flows/flow_alias.py#L132)



### Scenarios

Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

- [Create and invoke an agent](scenario_get_started_with_agents.py)
- [Create and invoke a flow](flows/playlist_flow.py)


<!--custom.examples.start-->
@@ -95,6 +113,37 @@ python scenario_get_started_with_agents.py
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.start-->
<!--custom.scenarios.bedrock-agent_GettingStartedWithBedrockAgents.end-->


#### Create and invoke a flow

Shows how to create a simple flow that generates music playlists.
The flow includes a prompt node that generates a playlist for a chosen genre
and number of songs. The example creates the nodes and permissions
for the flow.

Start the example by running the following at a command prompt:

```
python flows/playlist_flow.py
```
When prompted, enter the genre of music and the number of songs you want
in the playlist.
Optionally, the script can delete the resources that it creates. If you want to use the flow later, such as in the Amazon Bedrock console, enter `n` when the script prompts you to delete resources. Note that you will then need to manually delete the resources.



#### List flows

Shows how to List Amazon Bedrock flows, versions of a flow, and aliases of a flow.

Start the example by running the following at a command prompt:

```
python flows/list_flows.py
```
The example first lists the flows in the current AWS Region. It
then prompts for a flow ID, which you can get from the list of flows. Finally, the example lists the flow versions and flow aliases for the flow ID that you entered.

### Tests

⚠ Running tests might result in charges to your AWS account.
Loading